From 29e25f6f136182fb3756d51e03dea7c4d1919dd9 Mon Sep 17 00:00:00 2001 From: Frédéric Bérat Date: Thu, 1 Jun 2023 16:27:47 +0200 Subject: tests: fix warn unused results With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar --- stdlib/test-canon.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'stdlib') diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c index 4edee73dd8..bf19b1f1b1 100644 --- a/stdlib/test-canon.c +++ b/stdlib/test-canon.c @@ -123,8 +123,13 @@ do_test (int argc, char ** argv) int i, errors = 0; char buf[PATH_MAX]; - getcwd (cwd, sizeof (buf)); - cwd_len = strlen (cwd); + if (getcwd (cwd, sizeof (buf))) + cwd_len = strlen (cwd); + else + { + printf ("%s: current working directory couldn't be retrieved\n", argv[0]); + ++errors; + } errno = 0; if (realpath (NULL, buf) != NULL || errno != EINVAL) @@ -205,7 +210,12 @@ do_test (int argc, char ** argv) free (result2); } - getcwd (buf, sizeof (buf)); + if (!getcwd (buf, sizeof (buf))) + { + printf ("%s: current working directory couldn't be retrieved\n", argv[0]); + ++errors; + } + if (strcmp (buf, cwd)) { printf ("%s: current working directory changed from %s to %s\n", -- cgit 1.4.1