]> Savannah Git Hosting - gnulib.git/commitdiff
unistr/u{8,16,32}-chr tests: Fix some gcc -Wshadow warnings.
authorBruno Haible <bruno@clisp.org>
Mon, 4 Sep 2023 15:35:29 +0000 (17:35 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 4 Sep 2023 15:39:04 +0000 (17:39 +0200)
* tests/unistr/test-chr.h (main): Reduce of scope of local variables
'i' and 'page_boundary'.

ChangeLog
tests/unistr/test-chr.h

index 7ab50acc87597082505f402f8c73ba38c6588f7b..ec5ca2b68dff05d2c5c76be446d8244673c1117c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-09-04  Bruno Haible  <bruno@clisp.org>
 
+       unistr/u{8,16,32}-chr tests: Fix some gcc -Wshadow warnings.
+       * tests/unistr/test-chr.h (main): Reduce of scope of local variables
+       'i' and 'page_boundary'.
+
        pipe-filter-gi, pipe-filter-ii tests: Fix some gcc -Wshadow warnings.
        * tests/test-pipe-filter-gi1.c (main): Rename local variable 'argv' to
        'tr_argv'.
index 47d6612d7e4915cc45f8bf2dc0efb1a38163a5fe..7ee5dd2f84c9b73250e1936e90110804c19dec14 100644 (file)
@@ -20,7 +20,6 @@ int
 main (void)
 {
   size_t size = 0x100000;
-  size_t i;
   size_t length;
   UNIT *input;
   uint32_t *input32 = (uint32_t *) malloc (size * sizeof (uint32_t));
@@ -29,7 +28,7 @@ main (void)
   input32[0] = 'a';
   input32[1] = 'b';
   u32_set (input32 + 2, 'c', 1024);
-  for (i = 1026; i < size - 2; i += 63)
+  for (size_t i = 1026; i < size - 2; i += 63)
     {
       size_t last = i + 63 < size - 2 ? i + 63 : size - 2;
       ucs4_t uc = 'd' | (i - 1026);
@@ -48,9 +47,11 @@ main (void)
   ASSERT (U_CHR (input, length, 'a') == input);
 
   ASSERT (U_CHR (input, 0, 'a') == NULL);
-  void *page_boundary = zerosize_ptr ();
-  if (page_boundary)
-    ASSERT (U_CHR (page_boundary, 0, 'a') == NULL);
+  {
+    void *page_boundary = zerosize_ptr ();
+    if (page_boundary != NULL)
+      ASSERT (U_CHR (page_boundary, 0, 'a') == NULL);
+  }
 
   ASSERT (U_CHR (input, length, 'b') == input + 1);
   ASSERT (U_CHR (input, length, 'c') == input + 2);
@@ -59,7 +60,7 @@ main (void)
   {
     UNIT *exp = input + 1026;
     UNIT *prev = input + 1;
-    for (i = 1026; i < size - 2; i += 63)
+    for (size_t i = 1026; i < size - 2; i += 63)
       {
         UNIT c[6];
         size_t n;