Skip to content

Commit f352e84

Browse files
geertugregkh
authored andcommitted
selftests: gpio-mockup-chardev: Check asprintf() for error
[ 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>
1 parent 357d9c7 commit f352e84

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎tools/testing/selftests/gpio/gpio-mockup-chardev.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int get_debugfs(char **path)
3737
struct libmnt_table *tb;
3838
struct libmnt_iter *itr = NULL;
3939
struct libmnt_fs *fs;
40-
int found = 0;
40+
int found = 0, ret;
4141

4242
cxt = mnt_new_context();
4343
if (!cxt)
@@ -58,8 +58,11 @@ static int get_debugfs(char **path)
5858
break;
5959
}
6060
}
61-
if (found)
62-
asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
61+
if (found) {
62+
ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
63+
if (ret < 0)
64+
err(EXIT_FAILURE, "failed to format string");
65+
}
6366

6467
mnt_free_iter(itr);
6568
mnt_free_context(cxt);

0 commit comments

Comments
 (0)