regex.3: don't use z length modifier with unsigned int
PATCH 1/1 regex.3: don't use z length modifier with unsigned int
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
| %uSigned-off-by Arkadiusz Drabczyk <[email protected]>
--- man/man3/regex.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man/man3/regex.3 +1 -1
@@ -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);
Signature · 1 line
2.45.2
Alejandro Colomar
maintainerHi Arkadiusz,
Quoted 19 lines · Arkadiusz Drabczyk
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
Quoted 1 line
Signed-off-by Arkadiusz Drabczyk <[email protected]>
Thanks! I've applied the patch:
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=6f71d1e4958bd327b4cea006d27a854e66b85380>
I also added a Fixes tag:
Fixes b42296e4feaf (2022-09-15; "Various pages: EXAMPLES: Use unsigned types for loop iterators")
Have a lovely night!
Alex
Quoted 21 lines
--- man/man3/regex.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)man/man3/regex.3 +1
-1@@ -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);Signature · 1 line
2.45.2
Signature · 1 line
<https://www.alejandro-colomar.es/>