- call cc-option to check if the compiler supports the flags we asked to use
[oweals/busybox.git] / procps / renice.c
index bcaa94cf1b57f07d954917416d1cd1475fdb8106..08e0dc264edd68486d32c64ddd32f81dd1efdedc 100644 (file)
  */
 
 #include "busybox.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <unistd.h>
 #include <sys/resource.h>
 
-#if (PRIO_PROCESS < CHAR_MIN) || (PRIO_PROCESS > CHAR_MAX)
-#error Assumption violated : PRIO_PROCESS value
-#endif
-#if (PRIO_PGRP < CHAR_MIN) || (PRIO_PGRP > CHAR_MAX)
-#error Assumption violated : PRIO_PGRP value
-#endif
-#if (PRIO_USER < CHAR_MIN) || (PRIO_USER > CHAR_MAX)
-#error Assumption violated : PRIO_USER value
-#endif
+void BUG_bad_PRIO_PROCESS(void);
+void BUG_bad_PRIO_PGRP(void);
+void BUG_bad_PRIO_USER(void);
 
 int renice_main(int argc, char **argv)
 {
@@ -49,6 +37,14 @@ int renice_main(int argc, char **argv)
        unsigned who;
        char *arg;
 
+       /* Yes, they are not #defines in glibc 2.4! #if won't work */
+       if (PRIO_PROCESS < CHAR_MIN || PRIO_PROCESS > CHAR_MAX)
+               BUG_bad_PRIO_PROCESS();
+       if (PRIO_PGRP < CHAR_MIN || PRIO_PGRP > CHAR_MAX)
+               BUG_bad_PRIO_PGRP();
+       if (PRIO_USER < CHAR_MIN || PRIO_USER > CHAR_MAX)
+               BUG_bad_PRIO_USER();
+
        arg = *++argv;
 
        /* Check if we are using a relative adjustment. */
@@ -91,7 +87,8 @@ int renice_main(int argc, char **argv)
                        }
                        who = p->pw_uid;
                } else {
-                       if (safe_strtou(arg, &who)) {
+                       who = bb_strtou(arg, NULL, 10);
+                       if (errno) {
                                bb_error_msg("bad value: %s", arg);
                                goto HAD_ERROR;
                        }