From a052e0b60a33e6c94e87235b70001143702f72c4 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Tue, 21 Apr 2015 10:33:54 -0600 Subject: [PATCH] check return code of asprintf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On ubuntu (gcc 4.9.2), I get: mount.c: In function ‘add_fsname_auto’: mount.c:1414:3: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] asprintf(&fsauto_names, "%s,%s", old, names); ^ cc1: all warnings being treated as errors Signed-off-by: Tycho Andersen Signed-off-by: Pavel Emelyanov --- mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mount.c b/mount.c index 65f897ba8..1d41d82e6 100644 --- a/mount.c +++ b/mount.c @@ -1411,7 +1411,10 @@ bool add_fsname_auto(const char *names) fsauto_names = xstrdup(names); else { fsauto_names = NULL; - asprintf(&fsauto_names, "%s,%s", old, names); + if (asprintf(&fsauto_names, "%s,%s", old, names) < 0) { + fsauto_names = old; + return false; + } } xfree(old);