From: Diego Nieto Cid <[email protected]>

    ../../libps/../utils/msgids.c: In function 'msgid_info':
    ../../libps/../utils/msgids.c:114:15: warning: ignoring return value of 
'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result]
  114 |               asprintf (&reply_info->name, "%s-reply", info->name);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 utils/msgids.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/utils/msgids.c b/utils/msgids.c
index 81b49c59..d50a736a 100644
--- a/utils/msgids.c
+++ b/utils/msgids.c
@@ -109,11 +109,18 @@ msgid_info (mach_msg_id_t msgid)
          struct msgid_info *reply_info = malloc (sizeof *info);
          if (reply_info != 0)
            {
+             int err;
              reply_info->subsystem = strdup (info->subsystem);
              reply_info->name = 0;
-             asprintf (&reply_info->name, "%s-reply", info->name);
-             hurd_ihash_add (&msgid_ihash, msgid, reply_info);
-             info = reply_info;
+             err = asprintf (&reply_info->name, "%s-reply", info->name);
+             if (err == -1)
+               /* asprintf may fail with ENOMEM, react the same way to malloc 
failing */
+               info = 0;
+             else
+               {
+                 hurd_ihash_add (&msgid_ihash, msgid, reply_info);
+                 info = reply_info;
+               }
            }
          else
            info = 0;
-- 
2.51.0


Reply via email to