aboutsummaryrefslogtreecommitdiff
path: root/util-linux/renice.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/renice.c')
-rw-r--r--util-linux/renice.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/util-linux/renice.c b/util-linux/renice.c
index 70c494b3d..46704591f 100644
--- a/util-linux/renice.c
+++ b/util-linux/renice.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10/* Notes: 9/* Notes:
11 * Setting an absolute priority was obsoleted in SUSv2 and removed 10 * Setting an absolute priority was obsoleted in SUSv2 and removed
12 * in SUSv3. However, the common linux version of renice does 11 * in SUSv3. However, the common linux version of renice does
@@ -42,10 +41,6 @@
42#include "libbb.h" 41#include "libbb.h"
43#include <sys/resource.h> 42#include <sys/resource.h>
44 43
45void BUG_bad_PRIO_PROCESS(void);
46void BUG_bad_PRIO_PGRP(void);
47void BUG_bad_PRIO_USER(void);
48
49int renice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 44int renice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
50int renice_main(int argc UNUSED_PARAM, char **argv) 45int renice_main(int argc UNUSED_PARAM, char **argv)
51{ 46{
@@ -59,12 +54,9 @@ int renice_main(int argc UNUSED_PARAM, char **argv)
59 char *arg; 54 char *arg;
60 55
61 /* Yes, they are not #defines in glibc 2.4! #if won't work */ 56 /* Yes, they are not #defines in glibc 2.4! #if won't work */
62 if (PRIO_PROCESS < CHAR_MIN || PRIO_PROCESS > CHAR_MAX) 57 BUILD_BUG_ON(PRIO_PROCESS < CHAR_MIN || PRIO_PROCESS > CHAR_MAX);
63 BUG_bad_PRIO_PROCESS(); 58 BUILD_BUG_ON(PRIO_PGRP < CHAR_MIN || PRIO_PGRP > CHAR_MAX);
64 if (PRIO_PGRP < CHAR_MIN || PRIO_PGRP > CHAR_MAX) 59 BUILD_BUG_ON(PRIO_USER < CHAR_MIN || PRIO_USER > CHAR_MAX);
65 BUG_bad_PRIO_PGRP();
66 if (PRIO_USER < CHAR_MIN || PRIO_USER > CHAR_MAX)
67 BUG_bad_PRIO_USER();
68 60
69 arg = *++argv; 61 arg = *++argv;
70 62
@@ -102,6 +94,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv)
102 /* Process an ID arg. */ 94 /* Process an ID arg. */
103 if (which == PRIO_USER) { 95 if (which == PRIO_USER) {
104 struct passwd *p; 96 struct passwd *p;
97 /* NB: use of getpwnam makes it risky to be NOFORK, switch to getpwnam_r? */
105 p = getpwnam(arg); 98 p = getpwnam(arg);
106 if (!p) { 99 if (!p) {
107 bb_error_msg("unknown user %s", arg); 100 bb_error_msg("unknown user %s", arg);