public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c
@ 2014-11-26  1:27 Joseph Myers
  2014-12-02 19:23 ` Roland McGrath
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2014-11-26  1:27 UTC (permalink / raw)
  To: libc-alpha

This patch, relative to a tree with
<https://sourceware.org/ml/libc-alpha/2014-11/msg00736.html> (pending
review) applied, uses diagnostic control pragmas to disable some
division-by-zero warnings in stdio-common/tst-unlockedio.c.  This is
another test where disabling warnings using diagnostic pragmas seems
appropriate (the warnings are not wildly inappropriate for what the
test deliberately does; the deliberate use of unusual arguments to the
macros being tested means that changing the arguments in a way that
avoids the warning would also unduly perturb what is being tested).

Tested for x86_64.

2014-11-26  Joseph Myers  <joseph@codesourcery.com>

	* stdio-common/tst-unlockedio.c: Include <libc-internal.h>.
	(do_test): Disable -Wdiv-by-zero around some calls to
	fwrite_unlocked and fread_unlocked.

diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c
index 4d17a4c..e557b59 100644
--- a/stdio-common/tst-unlockedio.c
+++ b/stdio-common/tst-unlockedio.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-internal.h>
 
 int fd;
 static void do_prepare (void);
@@ -44,6 +45,13 @@ do_test (void)
 
   f = fp;
   cp = blah;
+  /* These tests deliberately use fwrite_unlocked with the size
+     argument specified as 0, which results in "division by zero"
+     warnings from the expansion of that macro (in code that is not
+     evaluated for a size of 0).  This applies to the tests of
+     fread_unlocked below as well.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero");
   if (ftello (fp) != 0
       || fwrite_unlocked (blah, blah - blah, strlen (blah), f++) != 0
       || f != fp + 1
@@ -59,6 +67,7 @@ do_test (void)
       puts ("One of fwrite_unlocked tests failed");
       exit (1);
     }
+  DIAG_POP_NEEDS_COMMENT;
 
   if (fwrite_unlocked (blah, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
     {
@@ -93,6 +102,9 @@ do_test (void)
   f = fp;
   wp = buf;
   memset (buf, ' ', sizeof (buf));
+  /* See explanation above.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero");
   if (ftello (fp) != 0
       || fread_unlocked (buf, buf - buf, strlen (blah), f++) != 0
       || f != fp + 1
@@ -109,6 +121,7 @@ do_test (void)
       puts ("One of fread_unlocked tests failed");
       exit (1);
     }
+  DIAG_POP_NEEDS_COMMENT;
 
   if (fread_unlocked (buf, 1, strlen (blah) - 2, fp) != strlen (blah) - 2)
     {

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c
  2014-11-26  1:27 Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c Joseph Myers
@ 2014-12-02 19:23 ` Roland McGrath
  2014-12-05 16:21   ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Roland McGrath @ 2014-12-02 19:23 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

OK

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c
  2014-12-02 19:23 ` Roland McGrath
@ 2014-12-05 16:21   ` Joseph Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2014-12-05 16:21 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-alpha

On Tue, 2 Dec 2014, Roland McGrath wrote:

> OK

Note that this can't go in without the macro definitions in 
<https://sourceware.org/ml/libc-alpha/2014-11/msg00736.html> - if the 
macros are OK but the use for scanf tests needs further consideration, I'd 
welcome review of the macro definitions on their own to unblock other 
changes using them (including warning avoidance using the macros in 
architecture-specific files).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-05 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26  1:27 Disable -Wdiv-by-zero for some tests in stdio-common/tst-unlockedio.c Joseph Myers
2014-12-02 19:23 ` Roland McGrath
2014-12-05 16:21   ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).