diff options
author | Denis Vlasenko | 2006-10-08 12:49:22 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-10-08 12:49:22 +0000 |
commit | 1385899416a4396385ad421ae1f532be7103738a (patch) | |
tree | fc4d14a910593d1235318bb36abe5e9f72d2039e /procps | |
parent | 5625415085e68ac5e150f54e685417c866620d76 (diff) | |
download | busybox-1385899416a4396385ad421ae1f532be7103738a.zip busybox-1385899416a4396385ad421ae1f532be7103738a.tar.gz |
attempt to regularize atoi mess.
Diffstat (limited to 'procps')
-rw-r--r-- | procps/kill.c | 4 | ||||
-rw-r--r-- | procps/pidof.c | 10 | ||||
-rw-r--r-- | procps/renice.c | 18 | ||||
-rw-r--r-- | procps/top.c | 8 |
4 files changed, 19 insertions, 21 deletions
diff --git a/procps/kill.c b/procps/kill.c index 2408a70..b29f61b 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -47,7 +47,7 @@ int kill_main(int argc, char **argv) } else { /* -l <sig list> */ while ((arg = *++argv)!=NULL) { if (isdigit(arg[0])) { - signo = atoi(arg); + signo = xatoi_u(arg); name = get_signame(signo); } else { signo = get_signum(arg); @@ -140,7 +140,7 @@ do_it_now: while (arg) { if (!isdigit(arg[0]) && arg[0]!='-') bb_error_msg_and_die("bad pid '%s'", arg); - pid = strtol(arg, NULL, 0); + pid = xatou(arg); /* FIXME: better overflow check? */ if (kill(pid, signo)!=0) { bb_perror_msg("cannot kill pid %ld", (long)pid); diff --git a/procps/pidof.c b/procps/pidof.c index e6c9548..62c590f 100644 --- a/procps/pidof.c +++ b/procps/pidof.c @@ -14,7 +14,7 @@ #define SINGLE (1<<0) #else #define _SINGLE_COMPL(a) -#define SINGLE (0) +#define SINGLE 0 #endif #if ENABLE_FEATURE_PIDOF_OMIT @@ -56,7 +56,7 @@ int pidof_main(int argc, char **argv) /* are we asked to exclude the parent's process ID? */ if (!strncmp(omits_p->data, "%PPID", 5)) { llist_pop(&omits_p); - snprintf(getppid_str, sizeof(getppid_str), "%d", getppid()); + snprintf(getppid_str, sizeof(getppid_str), "%ld", (long)getppid()); llist_add_to(&omits_p, getppid_str); } omits_p = omits_p->link; @@ -64,19 +64,19 @@ int pidof_main(int argc, char **argv) } #endif /* Looks like everything is set to go. */ - while(optind < argc) { + while (optind < argc) { long *pidList; long *pl; /* reverse the pidlist like GNU pidof does. */ pidList = pidlist_reverse(find_pid_by_name(argv[optind])); - for(pl = pidList; *pl > 0; pl++) { + for (pl = pidList; *pl > 0; pl++) { #if ENABLE_FEATURE_PIDOF_OMIT unsigned omitted = 0; if (opt & OMIT) { llist_t *omits_p = omits; while (omits_p) - if (strtol(omits_p->data, NULL, 10) == *pl) { + if (xatoul(omits_p->data) == *pl) { omitted = 1; break; } else omits_p = omits_p->link; diff --git a/procps/renice.c b/procps/renice.c index 53dc578..a91328f 100644 --- a/procps/renice.c +++ b/procps/renice.c @@ -53,13 +53,13 @@ static inline int int_add_no_wrap(int a, int b) int renice_main(int argc, char **argv) { - static const char Xetpriority_msg[] = "%d : %cetpriority"; + static const char Xetpriority_msg[] = "%d: %cetpriority"; int retval = EXIT_SUCCESS; int which = PRIO_PROCESS; /* Default 'which' value. */ int use_relative = 0; int adjustment, new_priority; - id_t who; + unsigned who; ++argv; @@ -74,15 +74,15 @@ int renice_main(int argc, char **argv) } /* Get the priority adjustment (absolute or relative). */ - adjustment = bb_xgetlarg(*argv, 10, INT_MIN, INT_MAX); + adjustment = xatoi(*argv); while (*++argv) { /* Check for a mode switch. */ if ((argv[0][0] == '-') && argv[0][1] && !argv[0][2]) { static const char opts[] = { 'p', 'g', 'u', 0, PRIO_PROCESS, PRIO_PGRP, PRIO_USER }; - const char *p; - if ((p = strchr(opts, argv[0][1]))) { + const char *p = strchr(opts, argv[0][1]); + if (p) { which = p[4]; continue; } @@ -91,16 +91,14 @@ int renice_main(int argc, char **argv) /* Process an ID arg. */ if (which == PRIO_USER) { struct passwd *p; - if (!(p = getpwnam(*argv))) { + p = getpwnam(*argv); + if (!p) { bb_error_msg("unknown user: %s", *argv); goto HAD_ERROR; } who = p->pw_uid; } else { - char *e; - errno = 0; - who = strtoul(*argv, &e, 10); - if (*e || (*argv == e) || errno) { + if (safe_strtou(*argv, &who)) { bb_error_msg("bad value: %s", *argv); goto HAD_ERROR; } diff --git a/procps/top.c b/procps/top.c index be1c45f..14a3870 100644 --- a/procps/top.c +++ b/procps/top.c @@ -384,8 +384,8 @@ static void sig_catcher(int sig ATTRIBUTE_UNUSED) int top_main(int argc, char **argv) { int count, lines, col; - int interval = 5; /* default update rate is 5 seconds */ - int iterations = -1; /* 2^32 iterations by default :) */ + unsigned interval = 5; /* default update rate is 5 seconds */ + unsigned iterations = UINT_MAX; /* 2^32 iterations by default :) */ char *sinterval, *siterations; #ifdef CONFIG_FEATURE_USE_TERMIOS struct termios new_settings; @@ -399,8 +399,8 @@ int top_main(int argc, char **argv) opt_complementary = "-"; getopt32(argc, argv, "d:n:b", &sinterval, &siterations); - if (option_mask32 & 0x1) interval = atoi(sinterval); // -d - if (option_mask32 & 0x2) iterations = atoi(siterations); // -n + if (option_mask32 & 0x1) interval = xatou(sinterval); // -d + if (option_mask32 & 0x2) iterations = xatou(siterations); // -n //if (option_mask32 & 0x4) // -b /* change to /proc */ |