From: Paul Eggert Date: Mon, 31 Jul 2023 23:35:32 +0000 (-0700) Subject: dircolors,du,expr: prefer signed types X-Git-Tag: v9.4~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e20d63c442b0365cc1a7cb236a63412523784e0a;p=thirdparty%2Fcoreutils.git dircolors,du,expr: prefer signed types * src/dircolors.c (dc_parse_stream): * src/du.c (max_depth, main): * src/expr.c (main): Prefer signed types. --- diff --git a/src/dircolors.c b/src/dircolors.c index 17b3c8b3fd..8a86efb76f 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -264,7 +264,7 @@ append_entry (char prefix, char const *item, char const *arg) static bool dc_parse_stream (FILE *fp, char const *filename) { - size_t line_number = 0; + idx_t line_number = 0; char const *next_G_line = G_line; char *input_line = nullptr; size_t input_line_size = 0; @@ -322,8 +322,8 @@ dc_parse_stream (FILE *fp, char const *filename) if (arg == nullptr) { - error (0, 0, _("%s:%lu: invalid line; missing second token"), - quotef (filename), (unsigned long int) line_number); + error (0, 0, _("%s:%td: invalid line; missing second token"), + quotef (filename), line_number); ok = false; free (keywd); continue; @@ -377,9 +377,9 @@ dc_parse_stream (FILE *fp, char const *filename) if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES)) { - error (0, 0, _("%s:%lu: unrecognized keyword %s"), + error (0, 0, _("%s:%td: unrecognized keyword %s"), (filename ? quotef (filename) : _("")), - (unsigned long int) line_number, keywd); + line_number, keywd); ok = false; } diff --git a/src/du.c b/src/du.c index 3d098bb326..1e88b29ba9 100644 --- a/src/du.c +++ b/src/du.c @@ -150,7 +150,7 @@ static bool opt_separate_dirs = false; /* Show the total for each directory (and file if --all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so 'du --max-depth=0' is equivalent to 'du -s'. */ -static size_t max_depth = SIZE_MAX; +static idx_t max_depth = IDX_MAX; /* Only output entries with at least this SIZE if positive, or at most if negative. See --threshold option. */ @@ -806,9 +806,9 @@ main (int argc, char **argv) case 'd': /* --max-depth=N */ { - uintmax_t tmp; - if (xstrtoumax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK - && tmp <= SIZE_MAX) + intmax_t tmp; + if (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK + && tmp <= IDX_MAX) { max_depth_specified = true; max_depth = tmp; @@ -940,8 +940,8 @@ main (int argc, char **argv) if (opt_summarize_only && max_depth_specified && max_depth != 0) { - unsigned long int d = max_depth; - error (0, 0, _("warning: summarizing conflicts with --max-depth=%lu"), d); + error (0, 0, _("warning: summarizing conflicts with --max-depth=%td"), + max_depth); usage (EXIT_FAILURE); } @@ -1107,8 +1107,8 @@ main (int argc, char **argv) /* Using the standard 'filename:line-number:' prefix here is not totally appropriate, since NUL is the separator, not NL, but it might be better than nothing. */ - unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quotef (files_from), + idx_t file_number = argv_iter_n_args (ai); + error (0, 0, "%s:%td: %s", quotef (files_from), file_number, _("invalid zero-length file name")); } skip_file = true; diff --git a/src/expr.c b/src/expr.c index 8a76cbf7ce..eeb4e13cca 100644 --- a/src/expr.c +++ b/src/expr.c @@ -333,14 +333,13 @@ main (int argc, char **argv) /* The above handles --help and --version. Since there is no other invocation of getopt, handle '--' here. */ - unsigned int u_argc = argc; - if (1 < u_argc && STREQ (argv[1], "--")) + if (1 < argc && STREQ (argv[1], "--")) { - --u_argc; + --argc; ++argv; } - if (u_argc <= 1) + if (argc <= 1) { error (0, 0, _("missing operand")); usage (EXPR_INVALID);