diff options
| author | Alex Colomar <alx.manpages@gmail.com> | 2022-09-15 16:40:27 +0200 |
|---|---|---|
| committer | Alex Colomar <alx.manpages@gmail.com> | 2022-09-15 18:07:48 +0200 |
| commit | b42296e4feaffd0ca4e5675fa181d19891f947ce (patch) | |
| tree | b16ebd13da8366c95ace85f538f32f3043dc12e3 /man5 | |
| parent | 489712257bb14b3674f9e9037c65b371b3f570c0 (diff) | |
| download | man-pages-b42296e4feaffd0ca4e5675fa181d19891f947ce.tar.gz | |
Various pages: EXAMPLES: Use unsigned types for loop iterators
Looping with unsigned types is safer. See the link below.
When the iterators are used for accessing an array, use size_t;
otherwise, use the most appropriate unsigned type, which in most
cases is just 'unsigned int'.
Also adjust other variables that have to interact with the
iterators, to avoid comparison of integers of different
signedness.
Link: <https://gustedt.wordpress.com/2013/07/15/a-praise-of-size_t-and-other-unsigned-types/>
Cc: Jens Gustedt <jens.gustedt@inria.fr>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'man5')
| -rw-r--r-- | man5/core.5 | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/man5/core.5 b/man5/core.5 index 04e34bbf9f..4df94d3c13 100644 --- a/man5/core.5 +++ b/man5/core.5 @@ -652,8 +652,8 @@ main(int argc, char *argv[]) pipe program. */ fprintf(fp, "argc=%d\en", argc); - for (int j = 0; j < argc; j++) - fprintf(fp, "argc[%d]=<%s>\en", j, argv[j]); + for (size_t j = 0; j < argc; j++) + fprintf(fp, "argc[%zu]=<%s>\en", j, argv[j]); /* Count bytes in standard input (the core dump). */ |
