arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1505492-zerodiv-1.patch

147e83
commit c81e9deba2f73ddc6f62a9d41684824c854366c6
147e83
Author: Joseph Myers <joseph@codesourcery.com>
147e83
Date:   Wed Dec 10 00:43:36 2014 +0000
147e83
147e83
    Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c.
147e83
    
147e83
    This patch uses diagnostic control pragmas to disable some
147e83
    division-by-zero warnings in stdio-common/tst-unlockedio.c.  This is
147e83
    another test where disabling warnings using diagnostic pragmas seems
147e83
    appropriate (the warnings are not wildly inappropriate for what the
147e83
    test deliberately does; the deliberate use of unusual arguments to the
147e83
    macros being tested means that changing the arguments in a way that
147e83
    avoids the warning would also unduly perturb what is being tested).
147e83
    
147e83
    Tested for x86_64.
147e83
    
147e83
            * stdio-common/tst-unlockedio.c: Include <libc-internal.h>.
147e83
            (do_test): Disable -Wdiv-by-zero around some calls to
147e83
            fwrite_unlocked and fread_unlocked.
147e83
147e83
diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c
147e83
index 2e5848ec5f49b693..5ce02fe6f5c7ea5c 100644
147e83
--- a/stdio-common/tst-unlockedio.c
147e83
+++ b/stdio-common/tst-unlockedio.c
147e83
@@ -20,6 +20,7 @@
147e83
 #include <stdlib.h>
147e83
 #include <stdio.h>
147e83
 #include <string.h>
147e83
+#include <libc-internal.h>
147e83
 
147e83
 int fd;
147e83
 static void do_prepare (void);
147e83
@@ -44,6 +45,13 @@ do_test (void)
147e83
 
147e83
   f = fp;
147e83
   cp = blah;
147e83
+  /* These tests deliberately use fwrite_unlocked with the size
147e83
+     argument specified as 0, which results in "division by zero"
147e83
+     warnings from the expansion of that macro (in code that is not
147e83
+     evaluated for a size of 0).  This applies to the tests of
147e83
+     fread_unlocked below as well.  */
147e83
+  DIAG_PUSH_NEEDS_COMMENT;
147e83
+  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero");
147e83
   if (ftello (fp) != 0
147e83
       || fwrite_unlocked (blah, blah - blah, strlen (blah), f++) != 0
147e83
       || f != fp + 1
147e83
@@ -59,6 +67,7 @@ do_test (void)
147e83
       puts ("One of fwrite_unlocked tests failed");
147e83
       exit (1);
147e83
     }
147e83
+  DIAG_POP_NEEDS_COMMENT;
147e83
 
147e83
   if (fwrite_unlocked (blah, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
147e83
     {
147e83
@@ -93,6 +102,9 @@ do_test (void)
147e83
   f = fp;
147e83
   wp = buf;
147e83
   memset (buf, ' ', sizeof (buf));
147e83
+  /* See explanation above.  */
147e83
+  DIAG_PUSH_NEEDS_COMMENT;
147e83
+  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero");
147e83
   if (ftello (fp) != 0
147e83
       || fread_unlocked (buf, buf - buf, strlen (blah), f++) != 0
147e83
       || f != fp + 1
147e83
@@ -109,6 +121,7 @@ do_test (void)
147e83
       puts ("One of fread_unlocked tests failed");
147e83
       exit (1);
147e83
     }
147e83
+  DIAG_POP_NEEDS_COMMENT;
147e83
 
147e83
   if (fread_unlocked (buf, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
147e83
     {