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

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