Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
selftests: gpio-mockup-chardev: Check asprintf() for error
Browse files Browse the repository at this point in the history
[ Upstream commit 508cacd ]

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: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
geertu authored and gregkh committed Mar 5, 2019
1 parent 357d9c7 commit f352e84
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/testing/selftests/gpio/gpio-mockup-chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int get_debugfs(char **path)
struct libmnt_table *tb;
struct libmnt_iter *itr = NULL;
struct libmnt_fs *fs;
int found = 0;
int found = 0, ret;

cxt = mnt_new_context();
if (!cxt)
Expand All @@ -58,8 +58,11 @@ static int get_debugfs(char **path)
break;
}
}
if (found)
asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
if (found) {
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_context(cxt);
Expand Down

0 comments on commit f352e84

Please sign in to comment.