]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/man3/regex.3: EXAMPLES: Don't use z length modifier with unsigned int
authorArkadiusz Drabczyk <arkadiusz@drabczyk.org>
Fri, 7 Feb 2025 21:16:28 +0000 (22:16 +0100)
committerAlejandro Colomar <alx@kernel.org>
Mon, 10 Feb 2025 11:42:47 +0000 (12:42 +0100)
GCC and Clang print warnings:

    $ clang main.c -Wall
    main.c:30:23: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'unsigned int' [-Wformat]
       30 |     printf("#%zu:\n", i);
          |              ~~~      ^
          |              %u
    1 warning generated.

    $ gcc main.c -Wall
    main.c: In function ‘main’:
    main.c:30:16: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘unsigned int’ [-Wformat=]
       30 |     printf("#%zu:\n", i);
          |              ~~^      ~
          |                |      |
          |                |      unsigned int
          |                long unsigned int
          |              %u

Fixes: b42296e4feaf (2022-09-15; "Various pages: EXAMPLES: Use unsigned types for loop iterators")
Signed-off-by: Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
Message-ID: <20250207211628.25164-1-arkadiusz@drabczyk.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man3/regex.3

index 3069489cbd8e0ff42ac8ed1ddb097aadc7bc72b9..a094c3b209f998720e190d0e242f0dcdc70c94b2 100644 (file)
@@ -392,7 +392,7 @@ int main(void)
 \&
         off = pmatch[0].rm_so + (s \- str);
         len = pmatch[0].rm_eo \- pmatch[0].rm_so;
-        printf("#%zu:\[rs]n", i);
+        printf("#%u:\[rs]n", i);
         printf("offset = %jd; length = %jd\[rs]n", (intmax_t) off,
                 (intmax_t) len);
         printf("substring = \[rs]"%.*s\[rs]"\[rs]n", len, s + pmatch[0].rm_so);