From: Diego Nieto Cid <[email protected]>
../../init/init.c: In function 'sigchld_handler':
../../init/init.c:91:13: warning: ignoring return value of 'asprintf'
declared with attribute 'warn_unused_result' [-Wunused-result]
../../init/init.c:94:13: warning: ignoring return value of 'asprintf'
declared with attribute 'warn_unused_result' [-Wunused-result]
../../init/init.c:99:13: warning: ignoring return value of 'asprintf'
declared with attribute 'warn_unused_result' [-Wunused-result]
---
init/init.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/init/init.c b/init/init.c
index ca40d527..8b897c2d 100644
--- a/init/init.c
+++ b/init/init.c
@@ -86,18 +86,22 @@ sigchld_handler(int signal)
/* The big magilla bit the dust. */
child_pid = -1;
+ error_t err;
char *desc = NULL;
if (WIFSIGNALED (status))
- asprintf (&desc, "terminated abnormally (%s)",
- strsignal (WTERMSIG (status)));
+ err = asprintf (&desc, "terminated abnormally (%s)",
+ strsignal (WTERMSIG (status)));
else if (WIFSTOPPED (status))
- asprintf (&desc, "stopped abnormally (%s)",
- strsignal (WTERMSIG (status)));
+ err = asprintf (&desc, "stopped abnormally (%s)",
+ strsignal (WTERMSIG (status)));
else if (WEXITSTATUS (status) == 0)
- desc = strdup ("finished");
+ desc = strdup ("finished"), err = (desc == 0 ? -1 : 0);
else
- asprintf (&desc, "exited with status %d",
- WEXITSTATUS (status));
+ err = asprintf (&desc, "exited with status %d",
+ WEXITSTATUS (status));
+
+ if (err == -1)
+ desc = "couldn't allocate exit reason message";
error (0, 0, "child %s", desc);
free (desc);
--
2.51.0