[21/21] benchtests: fix warn unused result

Message ID 20230620181910.1506893-22-fberat@redhat.com
State Committed
Commit 99f9ae4ed0ba9f2c84520b78fd0eeed96a7ed40e
Headers
Series Allow glibc to be built with _FORTIFY_SOURCE |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Testing failed

Commit Message

Frederic Berat June 20, 2023, 6:19 p.m. UTC
  Few tests needed to properly check for asprintf and system calls return
values with _FORTIFY_SOURCE enabled.
---
 benchtests/bench-strcoll.c                            | 6 +++++-
 sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Siddhesh Poyarekar June 21, 2023, 11:42 a.m. UTC | #1
On 2023-06-20 14:19, Frédéric Bérat wrote:
> Few tests needed to properly check for asprintf and system calls return
> values with _FORTIFY_SOURCE enabled.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> ---
>   benchtests/bench-strcoll.c                            | 6 +++++-
>   sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c | 3 ++-
>   2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/benchtests/bench-strcoll.c b/benchtests/bench-strcoll.c
> index b3cd5ce8a9..0bd9ada5f6 100644
> --- a/benchtests/bench-strcoll.c
> +++ b/benchtests/bench-strcoll.c
> @@ -254,7 +254,11 @@ main (void)
>   	}
>   
>         char *filename;
> -      asprintf (&filename, INPUT_PREFIX "%s", input_files[i]);
> +      if (asprintf (&filename, INPUT_PREFIX "%s", input_files[i]) < 0)
> +	{
> +	  printf ("asprintf failed, aborting!\n");
> +	  return ERROR_FILENAME;
> +	}
>         result = bench_file (json_ctx, input_files[i], filename, locale + 1);
>   
>         if (result != OK)
> diff --git a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
> index e5cdb2b2a1..4631ec9f0b 100644
> --- a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
> +++ b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
> @@ -24,6 +24,7 @@
>   #include <sys/types.h>
>   #include <sys/uio.h>
>   #include <elf.h>
> +#include <support/xstdlib.h>
>   #include <support/xunistd.h>
>   #include <support/check.h>
>   #include <string.h>
> @@ -44,7 +45,7 @@ tracee_func (int pid)
>     char str[80];
>     sprintf (str, "cat /proc/%d/maps", pid);
>     puts (str);
> -  system (str);
> +  xsystem (str);
>     fflush (stdout);
>   
>     TEST_VERIFY_EXIT (ptrace (PTRACE_TRACEME) == 0);
  

Patch

diff --git a/benchtests/bench-strcoll.c b/benchtests/bench-strcoll.c
index b3cd5ce8a9..0bd9ada5f6 100644
--- a/benchtests/bench-strcoll.c
+++ b/benchtests/bench-strcoll.c
@@ -254,7 +254,11 @@  main (void)
 	}
 
       char *filename;
-      asprintf (&filename, INPUT_PREFIX "%s", input_files[i]);
+      if (asprintf (&filename, INPUT_PREFIX "%s", input_files[i]) < 0)
+	{
+	  printf ("asprintf failed, aborting!\n");
+	  return ERROR_FILENAME;
+	}
       result = bench_file (json_ctx, input_files[i], filename, locale + 1);
 
       if (result != OK)
diff --git a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
index e5cdb2b2a1..4631ec9f0b 100644
--- a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
+++ b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
@@ -24,6 +24,7 @@ 
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <elf.h>
+#include <support/xstdlib.h>
 #include <support/xunistd.h>
 #include <support/check.h>
 #include <string.h>
@@ -44,7 +45,7 @@  tracee_func (int pid)
   char str[80];
   sprintf (str, "cat /proc/%d/maps", pid);
   puts (str);
-  system (str);
+  xsystem (str);
   fflush (stdout);
 
   TEST_VERIFY_EXIT (ptrace (PTRACE_TRACEME) == 0);