attempt to regularize atoi mess.

This commit is contained in:
Denis Vlasenko
2006-10-08 12:49:22 +00:00
parent 5625415085
commit 1385899416
98 changed files with 814 additions and 860 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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 */