1 From bb7b0b44666c0bd9d92ba745288132f96f62195e Mon Sep 17 00:00:00 2001
2 From: Geert Uytterhoeven <geert+renesas@glider.be>
3 Date: Mon, 14 Jan 2019 14:51:33 +0100
4 Subject: selftests: gpio-mockup-chardev: Check asprintf() for error
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 [ Upstream commit 508cacd7da6659ae7b7bdd0a335f675422277758 ]
13 gpio-mockup-chardev.c: In function ‘get_debugfs’:
14 gpio-mockup-chardev.c:62:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
15 asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
16 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 Handle asprintf() failures to fix this.
20 Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
21 Signed-off-by: Shuah Khan <shuah@kernel.org>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 tools/testing/selftests/gpio/gpio-mockup-chardev.c | 9 ++++++---
25 1 file changed, 6 insertions(+), 3 deletions(-)
27 diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
28 index f8d468f54e986..aaa1e9f083c37 100644
29 --- a/tools/testing/selftests/gpio/gpio-mockup-chardev.c
30 +++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
31 @@ -37,7 +37,7 @@ static int get_debugfs(char **path)
32 struct libmnt_table *tb;
33 struct libmnt_iter *itr = NULL;
38 cxt = mnt_new_context();
40 @@ -58,8 +58,11 @@ static int get_debugfs(char **path)
45 - asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
47 + ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
49 + err(EXIT_FAILURE, "failed to format string");
53 mnt_free_context(cxt);