diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-12 16:14:45 +0400 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-12 16:14:45 +0400 |
commit | 7783248eaac715b813f0635b06cc140ea99bb4d9 (patch) | |
tree | b7c3acbdf7e45afdb31a721a693f0a8a65f80730 | |
parent | 7bfbbd434a6f435b0287cd25406927c630b03f68 (diff) |
*: s/xatoi_u/xatoi_positive/g - I got bored of mistyping xatoi_u as xatou_i
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/cut.c | 4 | ||||
-rw-r--r-- | coreutils/date.c | 2 | ||||
-rw-r--r-- | debianutils/start_stop_daemon.c | 2 | ||||
-rw-r--r-- | e2fsprogs/fsck.c | 4 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/mke2fs.c | 6 | ||||
-rw-r--r-- | findutils/find.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 11 | ||||
-rw-r--r-- | libbb/getopt32.c | 6 | ||||
-rw-r--r-- | libbb/xatonum.c | 2 | ||||
-rw-r--r-- | miscutils/fbsplash.c | 2 | ||||
-rw-r--r-- | miscutils/hdparm.c | 4 | ||||
-rw-r--r-- | miscutils/ionice.c | 2 | ||||
-rw-r--r-- | miscutils/makedevs.c | 8 | ||||
-rw-r--r-- | miscutils/mt.c | 2 | ||||
-rw-r--r-- | miscutils/rfkill.c | 2 | ||||
-rw-r--r-- | networking/brctl.c | 2 | ||||
-rw-r--r-- | networking/ftpd.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 2 | ||||
-rw-r--r-- | printutils/lpd.c | 2 | ||||
-rw-r--r-- | procps/iostat.c | 4 | ||||
-rw-r--r-- | procps/mpstat.c | 6 | ||||
-rw-r--r-- | procps/nmeter.c | 2 | ||||
-rw-r--r-- | runit/svlogd.c | 6 | ||||
-rw-r--r-- | shell/hush.c | 2 | ||||
-rw-r--r-- | util-linux/flock.c | 2 | ||||
-rw-r--r-- | util-linux/hexdump.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 2 |
27 files changed, 49 insertions, 44 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c index 696478bb2..b7a3cfabb 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -224,7 +224,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv) if (!ntok[0]) { s = BOL; } else { - s = xatoi_u(ntok); + s = xatoi_positive(ntok); /* account for the fact that arrays are zero based, while * the user expects the first char on the line to be char #1 */ if (s != 0) @@ -237,7 +237,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv) } else if (!ltok[0]) { e = EOL; } else { - e = xatoi_u(ltok); + e = xatoi_positive(ltok); /* if the user specified and end position of 0, * that means "til the end of the line" */ if (e == 0) diff --git a/coreutils/date.c b/coreutils/date.c index cb41724af..3ce352c8d 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -300,7 +300,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) scale = 1; pres = 9; if (n) { - pres = xatoi_u(p); + pres = xatoi_positive(p); if (pres == 0) pres = 9; m = 9 - pres; diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 665f38fbd..568f32eec 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c @@ -373,7 +373,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) // IF_FEATURE_START_STOP_DAEMON_FANCY( // if (retry_arg) -// retries = xatoi_u(retry_arg); +// retries = xatoi_positive(retry_arg); // ) //argc -= optind; argv += optind; diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index 7c449e3e7..d694bb110 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c @@ -972,13 +972,13 @@ int fsck_main(int argc UNUSED_PARAM, char **argv) case 'C': progress = 1; if (arg[++j]) { /* -Cn */ - progress_fd = xatoi_u(&arg[j]); + progress_fd = xatoi_positive(&arg[j]); goto next_arg; } /* -C n */ if (!*++argv) bb_show_usage(); - progress_fd = xatoi_u(*argv); + progress_fd = xatoi_positive(*argv); goto next_arg; #endif case 'V': diff --git a/e2fsprogs/old_e2fsprogs/mke2fs.c b/e2fsprogs/old_e2fsprogs/mke2fs.c index 520364550..f1e97b96a 100644 --- a/e2fsprogs/old_e2fsprogs/mke2fs.c +++ b/e2fsprogs/old_e2fsprogs/mke2fs.c @@ -895,7 +895,7 @@ static int PRS(int argc, char **argv) creator_os = optarg; break; case 'r': - param.s_rev_level = xatoi_u(optarg); + param.s_rev_level = xatoi_positive(optarg); if (param.s_rev_level == EXT2_GOOD_OLD_REV) { param.s_feature_incompat = 0; param.s_feature_compat = 0; @@ -912,11 +912,11 @@ static int PRS(int argc, char **argv) break; #ifdef EXT2_DYNAMIC_REV case 'I': - inode_size = xatoi_u(optarg); + inode_size = xatoi_positive(optarg); break; #endif case 'N': - num_inodes = xatoi_u(optarg); + num_inodes = xatoi_positive(optarg); break; case 'v': quiet = 0; diff --git a/findutils/find.c b/findutils/find.c index 297081489..d4bcd6545 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -1210,7 +1210,7 @@ IF_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,) if (opt == OPT_MINDEPTH || opt == OPT_MINDEPTH + 1) { if (!argp[1]) bb_show_usage(); - minmaxdepth[opt - OPT_MINDEPTH] = xatoi_u(argp[1]); + minmaxdepth[opt - OPT_MINDEPTH] = xatoi_positive(argp[1]); argp[0] = (char*)"-a"; argp[1] = (char*)"-a"; argp++; diff --git a/include/libbb.h b/include/libbb.h index 118d777bc..03fc5d44b 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -190,7 +190,7 @@ typedef unsigned long long uoff_t; /* While sizeof(off_t) == sizeof(int), off_t is typedef'ed to long anyway. * gcc will throw warnings on printf("%d", off_t). Crap... */ typedef unsigned long uoff_t; -# define XATOOFF(a) xatoi_u(a) +# define XATOOFF(a) xatoi_positive(a) # define BB_STRTOOFF bb_strtou # define STRTOOFF strtol # define OFF_FMT "l" @@ -765,11 +765,16 @@ struct suffix_mult { }; #include "xatonum.h" /* Specialized: */ + /* Using xatoi() instead of naive atoi() is not always convenient - * in many places people want *non-negative* values, but store them * in signed int. Therefore we need this one: - * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */ -int xatoi_u(const char *numstr) FAST_FUNC; + * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc. + * It should really be named xatoi_nonnegative (since it allows 0), + * but that would be too long. + */ +int xatoi_positive(const char *numstr) FAST_FUNC; + /* Useful for reading port numbers */ uint16_t xatou16(const char *numstr) FAST_FUNC; diff --git a/libbb/getopt32.c b/libbb/getopt32.c index b5f83c127..8c87fe3f0 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -233,7 +233,7 @@ Special characters: "a+" A plus after a char in opt_complementary means that the parameter for this option is a nonnegative integer. It will be processed - with xatoi_u() - allowed range is 0..INT_MAX. + with xatoi_positive() - allowed range is 0..INT_MAX. int param; // "unsigned param;" will also work opt_complementary = "p+"; @@ -579,8 +579,8 @@ getopt32(char **argv, const char *applet_opts, ...) llist_add_to_end((llist_t **)(on_off->optarg), optarg); } else if (on_off->param_type == PARAM_INT) { if (optarg) -//TODO: xatoi_u indirectly pulls in printf machinery - *(unsigned*)(on_off->optarg) = xatoi_u(optarg); +//TODO: xatoi_positive indirectly pulls in printf machinery + *(unsigned*)(on_off->optarg) = xatoi_positive(optarg); } else if (on_off->optarg) { if (optarg) *(char **)(on_off->optarg) = optarg; diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 3cdf63425..60b65f525 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -59,7 +59,7 @@ unsigned bb_strtoui(const char *str, char **end, int b) /* A few special cases */ -int FAST_FUNC xatoi_u(const char *numstr) +int FAST_FUNC xatoi_positive(const char *numstr) { return xatou_range(numstr, 0, INT_MAX); } diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index e370d207b..a031cbd3a 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c @@ -311,7 +311,7 @@ static void init(const char *cfg_filename) parser_t *parser = config_open2(cfg_filename, xfopen_stdin); while (config_read(parser, token, 2, 2, "#=", (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) { - unsigned val = xatoi_u(token[1]); + unsigned val = xatoi_positive(token[1]); int i = index_in_strings(param_names, token[0]); if (i < 0) bb_error_msg_and_die("syntax error: %s", token[0]); diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 236b1749c..c6ca3af80 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -2055,8 +2055,8 @@ int hdparm_main(int argc, char **argv) #if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF if (c == 'R') { scan_hwif = parse_opts_0_INTMAX(&hwif_data); - hwif_ctrl = xatoi_u((argv[optind]) ? argv[optind] : ""); - hwif_irq = xatoi_u((argv[optind+1]) ? argv[optind+1] : ""); + hwif_ctrl = xatoi_positive((argv[optind]) ? argv[optind] : ""); + hwif_irq = xatoi_positive((argv[optind+1]) ? argv[optind+1] : ""); /* Move past the 2 additional arguments */ argv += 2; argc -= 2; diff --git a/miscutils/ionice.c b/miscutils/ionice.c index 52e51b908..6b791c491 100644 --- a/miscutils/ionice.c +++ b/miscutils/ionice.c @@ -73,7 +73,7 @@ int ionice_main(int argc UNUSED_PARAM, char **argv) if (!(opt & (OPT_n|OPT_c))) { if (!(opt & OPT_p) && *argv) - pid = xatoi_u(*argv); + pid = xatoi_positive(*argv); pri = ioprio_get(IOPRIO_WHO_PROCESS, pid); if (pri == -1) diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index abf505770..0578d9251 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c @@ -36,10 +36,10 @@ int makedevs_main(int argc, char **argv) basedev = argv[1]; buf = xasprintf("%s%u", argv[1], (unsigned)-1); type = argv[2]; - Smajor = xatoi_u(argv[3]); - Sminor = xatoi_u(argv[4]); - S = xatoi_u(argv[5]); - E = xatoi_u(argv[6]); + Smajor = xatoi_positive(argv[3]); + Sminor = xatoi_positive(argv[4]); + S = xatoi_positive(argv[5]); + E = xatoi_positive(argv[6]); nodname = argv[7] ? basedev : buf; mode = 0660; diff --git a/miscutils/mt.c b/miscutils/mt.c index 586373d13..8df2b75f7 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c @@ -106,7 +106,7 @@ int mt_main(int argc UNUSED_PARAM, char **argv) op.mt_op = opcode_value[idx]; if (argv[2]) - op.mt_count = xatoi_u(argv[2]); + op.mt_count = xatoi_positive(argv[2]); else op.mt_count = 1; /* One, not zero, right? */ diff --git a/miscutils/rfkill.c b/miscutils/rfkill.c index 0f5817b76..7d8ad1cfc 100644 --- a/miscutils/rfkill.c +++ b/miscutils/rfkill.c @@ -53,7 +53,7 @@ int rfkill_main(int argc UNUSED_PARAM, char **argv) rf_name = "uwb"; rf_type = index_in_strings(rfkill_types, rf_name); if (rf_type < 0) { - rf_idx = xatoi_u(rf_name); + rf_idx = xatoi_positive(rf_name); } } diff --git a/networking/brctl.c b/networking/brctl.c index a36ab45c3..0f56412ce 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -271,7 +271,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv) } } arg1 = port; - arg2 = xatoi_u(*argv); + arg2 = xatoi_positive(*argv); if (key == ARG_setbridgeprio) { arg1 = arg2; arg2 = 0; diff --git a/networking/ftpd.c b/networking/ftpd.c index e8cae0a36..0daf9f7a3 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c @@ -534,7 +534,7 @@ static void handle_rest(void) { /* When ftp_arg == NULL simply restart from beginning */ - G.restart_pos = G.ftp_arg ? xatoi_u(G.ftp_arg) : 0; + G.restart_pos = G.ftp_arg ? xatoi_positive(G.ftp_arg) : 0; WRITE_OK(FTP_RESTOK); } diff --git a/networking/wget.c b/networking/wget.c index fb8e51317..784e405da 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -213,7 +213,7 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp, char *buf) } while (!isdigit(buf[0]) || buf[3] != ' '); buf[3] = '\0'; - result = xatoi_u(buf); + result = xatoi_positive(buf); buf[3] = ' '; return result; } diff --git a/printutils/lpd.c b/printutils/lpd.c index d91491f1b..54ff2227e 100644 --- a/printutils/lpd.c +++ b/printutils/lpd.c @@ -135,7 +135,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[]) while (1) { char *fname; int fd; - // int is easier than ssize_t: can use xatoi_u, + // int is easier than ssize_t: can use xatoi_positive, // and can correctly display error returns (-1) int expected_len, real_len; diff --git a/procps/iostat.c b/procps/iostat.c index 573419e1c..8641c2391 100644 --- a/procps/iostat.c +++ b/procps/iostat.c @@ -539,12 +539,12 @@ int iostat_main(int argc, char **argv) if (*argv) { /* Get interval */ - interval = xatoi_u(*argv); + interval = xatoi_positive(*argv); count = interval ? -1 : 1; argv++; if (*argv) /* Get count value */ - count = xatoi_u(*argv); + count = xatoi_positive(*argv); } /* Allocate space for device stats */ diff --git a/procps/mpstat.c b/procps/mpstat.c index 7610a68fb..85cbb45db 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c @@ -930,14 +930,14 @@ int mpstat_main(int UNUSED_PARAM argc, char **argv) if (*argv) { /* Get interval */ - G.interval = xatoi_u(*argv); + G.interval = xatoi_positive(*argv); G.count = -1; argv++; if (*argv) { /* Get count value */ if (G.interval == 0) bb_show_usage(); - G.count = xatoi_u(*argv); + G.count = xatoi_positive(*argv); //if (*++argv) // bb_show_usage(); } @@ -979,7 +979,7 @@ int mpstat_main(int UNUSED_PARAM argc, char **argv) memset(G.cpu_bitmap, 0xff, G.cpu_bitmap_len); } else { /* Get CPU number */ - unsigned n = xatoi_u(t); + unsigned n = xatoi_positive(t); if (n >= G.cpu_nr) bb_error_msg_and_die("not that many processors"); n++; diff --git a/procps/nmeter.c b/procps/nmeter.c index bb1e819a6..930585695 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c @@ -422,7 +422,7 @@ static s_stat* init_int(const char *param) if (param[0] == '\0') { s->no = 1; } else { - int n = xatoi_u(param); + int n = xatoi_positive(param); s->no = n + 2; } return (s_stat*)s; diff --git a/runit/svlogd.c b/runit/svlogd.c index 9fe81b900..1f0a77cc2 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -688,10 +688,10 @@ static NOINLINE unsigned logdir_open(struct logdir *ld, const char *fn) break; } case 'n': - ld->nmax = xatoi_u(&s[1]); + ld->nmax = xatoi_positive(&s[1]); break; case 'N': - ld->nmin = xatoi_u(&s[1]); + ld->nmin = xatoi_positive(&s[1]); break; case 't': { static const struct suffix_mult mh_suffixes[] = { @@ -981,7 +981,7 @@ int svlogd_main(int argc, char **argv) linemax = 256; } ////if (opt & 8) { // -b - //// buflen = xatoi_u(b); + //// buflen = xatoi_positive(b); //// if (buflen == 0) buflen = 1024; ////} //if (opt & 0x10) timestamp++; // -t diff --git a/shell/hush.c b/shell/hush.c index 0a420f685..df4058998 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2788,7 +2788,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char /* lookup the variable in question */ if (isdigit(var[0])) { /* parse_dollar() should have vetted var for us */ - i = xatoi_u(var); + i = xatoi_positive(var); if (i < G.global_argc) val = G.global_argv[i]; /* else val remains NULL: $N with too big N */ diff --git a/util-linux/flock.c b/util-linux/flock.c index 78b1e4ba3..be3d552fa 100644 --- a/util-linux/flock.c +++ b/util-linux/flock.c @@ -40,7 +40,7 @@ int flock_main(int argc UNUSED_PARAM, char **argv) bb_perror_msg_and_die("can't open '%s'", argv[0]); //TODO? close_on_exec_on(fd); } else { - fd = xatoi_u(argv[0]); + fd = xatoi_positive(argv[0]); } argv++; diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index 2eb5e57ae..7b89e6fdc 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c @@ -90,7 +90,7 @@ int hexdump_main(int argc, char **argv) bb_dump_addfile(dumper, optarg); } /* else */ if (ch == 'n') { - dumper->dump_length = xatoi_u(optarg); + dumper->dump_length = xatoi_positive(optarg); } /* else */ if (ch == 's') { /* compat: -s accepts hex numbers too */ dumper->dump_skip = xstrtoul_range_sfx(optarg, /*base:*/ 0, /*lo:*/ 0, /*hi:*/ LONG_MAX, suffixes); diff --git a/util-linux/mount.c b/util-linux/mount.c index 9107e4308..aa17872da 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -1147,7 +1147,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) continue; } - val = xatoi_u(opteq); + val = xatoi_positive(opteq); switch (idx) { case 0: // "rsize" data.rsize = val; |