summaryrefslogtreecommitdiff
path: root/procps/renice.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-08 12:49:22 +0000
committerDenis Vlasenko2006-10-08 12:49:22 +0000
commit1385899416a4396385ad421ae1f532be7103738a (patch)
treefc4d14a910593d1235318bb36abe5e9f72d2039e /procps/renice.c
parent5625415085e68ac5e150f54e685417c866620d76 (diff)
downloadbusybox-1385899416a4396385ad421ae1f532be7103738a.zip
busybox-1385899416a4396385ad421ae1f532be7103738a.tar.gz
attempt to regularize atoi mess.
Diffstat (limited to 'procps/renice.c')
-rw-r--r--procps/renice.c18
1 files changed, 8 insertions, 10 deletions
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;
}