[4/4] string: Fix tester build with fortify enable with gcc 6

Message ID 20230725151641.923083-5-adhemerval.zanella@linaro.org
State Committed
Commit 784ae968113011ce832b1808d4d42369f5d2e320
Headers
Series Fix i386 build with --enable-fortify-source |

Checks

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

Commit Message

Adhemerval Zanella Netto July 25, 2023, 3:16 p.m. UTC
  When building with fortify enabled, GCC 6 issues an warning the fortify
wrapper might overflow the destination buffer.  However, GCC does not
provide a specific flag to disable the warning (the failure is tied to
-Werror).  So to avoid disable all errors, only enable the check for
GCC 7 or newer.

Checked on i686-linux-gnu.
---
 string/tester.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Carlos O'Donell July 26, 2023, 1:51 a.m. UTC | #1
On 7/25/23 11:16, Adhemerval Zanella via Libc-alpha wrote:
> When building with fortify enabled, GCC 6 issues an warning the fortify
> wrapper might overflow the destination buffer.  However, GCC does not
> provide a specific flag to disable the warning (the failure is tied to
> -Werror).  So to avoid disable all errors, only enable the check for
> GCC 7 or newer.

It's not normal to disable a part of a test depending on the gcc version.

However, keeping the test is better for coverage rather than moving to UNSUPPORTED.

Andreas, As the RM is this OK to push?

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> Checked on i686-linux-gnu.
> ---
>  string/tester.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/string/tester.c b/string/tester.c
> index da42c72141..f7d4bac5a8 100644
> --- a/string/tester.c
> +++ b/string/tester.c
> @@ -385,8 +385,17 @@ test_strncat (void)
>  
>    (void) strcpy (one, "gh");
>    (void) strcpy (two, "ef");
> +  /* When building with fortify enabled, GCC 6 issues an warning the fortify
> +     wrapper might overflow the destination buffer.  However, GCC does not
> +     provide a specific flag to disable the warning (the failure is tied to
> +     -Werror).  So to avoid disable all errors, only enable the check for
> +     GCC 7 or newer.  */
> +#if __GNUC_PREREQ (7, 0)

OK. Disabled test for < GCC 7. This works.

>    (void) strncat (one, two, 99);
>    equal (one, "ghef", 5);			/* Basic test encore. */
> +#else
> +  equal (one, "gh", 2);
> +#endif
>    equal (two, "ef", 6);			/* Stomped on source? */
>  
>    (void) strcpy (one, "");
  
Andreas K. Huettel July 26, 2023, 9:18 a.m. UTC | #2
Am Mittwoch, 26. Juli 2023, 03:51:45 CEST schrieb Carlos O'Donell:
> On 7/25/23 11:16, Adhemerval Zanella via Libc-alpha wrote:
> > When building with fortify enabled, GCC 6 issues an warning the fortify
> > wrapper might overflow the destination buffer.  However, GCC does not
> > provide a specific flag to disable the warning (the failure is tied to
> > -Werror).  So to avoid disable all errors, only enable the check for
> > GCC 7 or newer.
> 
> It's not normal to disable a part of a test depending on the gcc version.
> 
> However, keeping the test is better for coverage rather than moving to UNSUPPORTED.
> 
> Andreas, As the RM is this OK to push?
> 
> LGTM.
> 
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>

Yes please go ahead.

> 
> > 
> > Checked on i686-linux-gnu.
> > ---
> >  string/tester.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/string/tester.c b/string/tester.c
> > index da42c72141..f7d4bac5a8 100644
> > --- a/string/tester.c
> > +++ b/string/tester.c
> > @@ -385,8 +385,17 @@ test_strncat (void)
> >  
> >    (void) strcpy (one, "gh");
> >    (void) strcpy (two, "ef");
> > +  /* When building with fortify enabled, GCC 6 issues an warning the fortify
> > +     wrapper might overflow the destination buffer.  However, GCC does not
> > +     provide a specific flag to disable the warning (the failure is tied to
> > +     -Werror).  So to avoid disable all errors, only enable the check for
> > +     GCC 7 or newer.  */
> > +#if __GNUC_PREREQ (7, 0)
> 
> OK. Disabled test for < GCC 7. This works.
> 
> >    (void) strncat (one, two, 99);
> >    equal (one, "ghef", 5);			/* Basic test encore. */
> > +#else
> > +  equal (one, "gh", 2);
> > +#endif
> >    equal (two, "ef", 6);			/* Stomped on source? */
> >  
> >    (void) strcpy (one, "");
> 
>
  

Patch

diff --git a/string/tester.c b/string/tester.c
index da42c72141..f7d4bac5a8 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -385,8 +385,17 @@  test_strncat (void)
 
   (void) strcpy (one, "gh");
   (void) strcpy (two, "ef");
+  /* When building with fortify enabled, GCC 6 issues an warning the fortify
+     wrapper might overflow the destination buffer.  However, GCC does not
+     provide a specific flag to disable the warning (the failure is tied to
+     -Werror).  So to avoid disable all errors, only enable the check for
+     GCC 7 or newer.  */
+#if __GNUC_PREREQ (7, 0)
   (void) strncat (one, two, 99);
   equal (one, "ghef", 5);			/* Basic test encore. */
+#else
+  equal (one, "gh", 2);
+#endif
   equal (two, "ef", 6);			/* Stomped on source? */
 
   (void) strcpy (one, "");