diff options
Diffstat (limited to 'procps/renice.c')
-rw-r--r-- | procps/renice.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/procps/renice.c b/procps/renice.c index 53dc57855..a91328f53 100644 --- a/procps/renice.c +++ b/procps/renice.c | |||
@@ -53,13 +53,13 @@ static inline int int_add_no_wrap(int a, int b) | |||
53 | 53 | ||
54 | int renice_main(int argc, char **argv) | 54 | int renice_main(int argc, char **argv) |
55 | { | 55 | { |
56 | static const char Xetpriority_msg[] = "%d : %cetpriority"; | 56 | static const char Xetpriority_msg[] = "%d: %cetpriority"; |
57 | 57 | ||
58 | int retval = EXIT_SUCCESS; | 58 | int retval = EXIT_SUCCESS; |
59 | int which = PRIO_PROCESS; /* Default 'which' value. */ | 59 | int which = PRIO_PROCESS; /* Default 'which' value. */ |
60 | int use_relative = 0; | 60 | int use_relative = 0; |
61 | int adjustment, new_priority; | 61 | int adjustment, new_priority; |
62 | id_t who; | 62 | unsigned who; |
63 | 63 | ||
64 | ++argv; | 64 | ++argv; |
65 | 65 | ||
@@ -74,15 +74,15 @@ int renice_main(int argc, char **argv) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | /* Get the priority adjustment (absolute or relative). */ | 76 | /* Get the priority adjustment (absolute or relative). */ |
77 | adjustment = bb_xgetlarg(*argv, 10, INT_MIN, INT_MAX); | 77 | adjustment = xatoi(*argv); |
78 | 78 | ||
79 | while (*++argv) { | 79 | while (*++argv) { |
80 | /* Check for a mode switch. */ | 80 | /* Check for a mode switch. */ |
81 | if ((argv[0][0] == '-') && argv[0][1] && !argv[0][2]) { | 81 | if ((argv[0][0] == '-') && argv[0][1] && !argv[0][2]) { |
82 | static const char opts[] | 82 | static const char opts[] |
83 | = { 'p', 'g', 'u', 0, PRIO_PROCESS, PRIO_PGRP, PRIO_USER }; | 83 | = { 'p', 'g', 'u', 0, PRIO_PROCESS, PRIO_PGRP, PRIO_USER }; |
84 | const char *p; | 84 | const char *p = strchr(opts, argv[0][1]); |
85 | if ((p = strchr(opts, argv[0][1]))) { | 85 | if (p) { |
86 | which = p[4]; | 86 | which = p[4]; |
87 | continue; | 87 | continue; |
88 | } | 88 | } |
@@ -91,16 +91,14 @@ int renice_main(int argc, char **argv) | |||
91 | /* Process an ID arg. */ | 91 | /* Process an ID arg. */ |
92 | if (which == PRIO_USER) { | 92 | if (which == PRIO_USER) { |
93 | struct passwd *p; | 93 | struct passwd *p; |
94 | if (!(p = getpwnam(*argv))) { | 94 | p = getpwnam(*argv); |
95 | if (!p) { | ||
95 | bb_error_msg("unknown user: %s", *argv); | 96 | bb_error_msg("unknown user: %s", *argv); |
96 | goto HAD_ERROR; | 97 | goto HAD_ERROR; |
97 | } | 98 | } |
98 | who = p->pw_uid; | 99 | who = p->pw_uid; |
99 | } else { | 100 | } else { |
100 | char *e; | 101 | if (safe_strtou(*argv, &who)) { |
101 | errno = 0; | ||
102 | who = strtoul(*argv, &e, 10); | ||
103 | if (*e || (*argv == e) || errno) { | ||
104 | bb_error_msg("bad value: %s", *argv); | 102 | bb_error_msg("bad value: %s", *argv); |
105 | goto HAD_ERROR; | 103 | goto HAD_ERROR; |
106 | } | 104 | } |