Commit f352e84e authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Greg Kroah-Hartman

selftests: gpio-mockup-chardev: Check asprintf() for error

[ Upstream commit 508cacd7 ]

With gcc 7.3.0:

    gpio-mockup-chardev.c: In function ‘get_debugfs’:
    gpio-mockup-chardev.c:62:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
       asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Handle asprintf() failures to fix this.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarShuah Khan <shuah@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 357d9c7a
...@@ -37,7 +37,7 @@ static int get_debugfs(char **path) ...@@ -37,7 +37,7 @@ static int get_debugfs(char **path)
struct libmnt_table *tb; struct libmnt_table *tb;
struct libmnt_iter *itr = NULL; struct libmnt_iter *itr = NULL;
struct libmnt_fs *fs; struct libmnt_fs *fs;
int found = 0; int found = 0, ret;
cxt = mnt_new_context(); cxt = mnt_new_context();
if (!cxt) if (!cxt)
...@@ -58,8 +58,11 @@ static int get_debugfs(char **path) ...@@ -58,8 +58,11 @@ static int get_debugfs(char **path)
break; break;
} }
} }
if (found) if (found) {
asprintf(path, "%s/gpio", mnt_fs_get_target(fs)); ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
if (ret < 0)
err(EXIT_FAILURE, "failed to format string");
}
mnt_free_iter(itr); mnt_free_iter(itr);
mnt_free_context(cxt); mnt_free_context(cxt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment