Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:
stratcliff.c: In function ‘do_test’:
cc1: error: assuming signed overflow does not occur when assuming that (X
- c) <= X is always true [-Werror=strict-overflow]
OK for master?
H.J.
---
[BZ #21982]
* string/stratcliff.c (do_test): Declare size, nchars, inner,
middle and outer with size_t instead of int. Repleace %d with
%Zd in printf.
---
string/stratcliff.c | 72
++++++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/string/stratcliff.c b/string/stratcliff.c
index e28b0c5058..ae780379cb 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -58,8 +58,8 @@
int
do_test (void)
{
- int size = sysconf (_SC_PAGESIZE);
- int nchars = size / sizeof (CHAR);
+ size_t size = sysconf (_SC_PAGESIZE);
+ size_t nchars = size / sizeof (CHAR);
CHAR *adr;
CHAR *dest;
int result = 0;
@@ -80,7 +80,7 @@ do_test (void)
}
else
{
- int inner, middle, outer;
+ size_t inner, middle, outer;
mprotect (adr, size, PROT_NONE);
mprotect (adr + 2 * nchars, size, PROT_NONE);
@@ -101,7 +101,7 @@ do_test (void)
if (STRLEN (&adr[outer]) != (size_t) (inner - outer))
{
- printf ("%s flunked for outer = %d, inner = %d\n",
+ printf ("%s flunked for outer = %Zd, inner = %Zd\n",
STRINGIFY (STRLEN), outer, inner);
result = 1;
}
{
- printf ("%s flunked for outer = %d, middle = %d\n",
+ printf ("%s flunked for outer = %Zd, middle = %Zd\n",
STRINGIFY (rawmemchr), outer, middle);
result = 1;
}
Hi H.J. Lu,