aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/kill.c4
-rw-r--r--procps/pidof.c10
-rw-r--r--procps/renice.c18
-rw-r--r--procps/top.c8
4 files changed, 19 insertions, 21 deletions
diff --git a/procps/kill.c b/procps/kill.c
index 2408a70ca..b29f61b58 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -47,7 +47,7 @@ int kill_main(int argc, char **argv)
47 } else { /* -l <sig list> */ 47 } else { /* -l <sig list> */
48 while ((arg = *++argv)!=NULL) { 48 while ((arg = *++argv)!=NULL) {
49 if (isdigit(arg[0])) { 49 if (isdigit(arg[0])) {
50 signo = atoi(arg); 50 signo = xatoi_u(arg);
51 name = get_signame(signo); 51 name = get_signame(signo);
52 } else { 52 } else {
53 signo = get_signum(arg); 53 signo = get_signum(arg);
@@ -140,7 +140,7 @@ do_it_now:
140 while (arg) { 140 while (arg) {
141 if (!isdigit(arg[0]) && arg[0]!='-') 141 if (!isdigit(arg[0]) && arg[0]!='-')
142 bb_error_msg_and_die("bad pid '%s'", arg); 142 bb_error_msg_and_die("bad pid '%s'", arg);
143 pid = strtol(arg, NULL, 0); 143 pid = xatou(arg);
144 /* FIXME: better overflow check? */ 144 /* FIXME: better overflow check? */
145 if (kill(pid, signo)!=0) { 145 if (kill(pid, signo)!=0) {
146 bb_perror_msg("cannot kill pid %ld", (long)pid); 146 bb_perror_msg("cannot kill pid %ld", (long)pid);
diff --git a/procps/pidof.c b/procps/pidof.c
index e6c954843..62c590fd8 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -14,7 +14,7 @@
14#define SINGLE (1<<0) 14#define SINGLE (1<<0)
15#else 15#else
16#define _SINGLE_COMPL(a) 16#define _SINGLE_COMPL(a)
17#define SINGLE (0) 17#define SINGLE 0
18#endif 18#endif
19 19
20#if ENABLE_FEATURE_PIDOF_OMIT 20#if ENABLE_FEATURE_PIDOF_OMIT
@@ -56,7 +56,7 @@ int pidof_main(int argc, char **argv)
56 /* are we asked to exclude the parent's process ID? */ 56 /* are we asked to exclude the parent's process ID? */
57 if (!strncmp(omits_p->data, "%PPID", 5)) { 57 if (!strncmp(omits_p->data, "%PPID", 5)) {
58 llist_pop(&omits_p); 58 llist_pop(&omits_p);
59 snprintf(getppid_str, sizeof(getppid_str), "%d", getppid()); 59 snprintf(getppid_str, sizeof(getppid_str), "%ld", (long)getppid());
60 llist_add_to(&omits_p, getppid_str); 60 llist_add_to(&omits_p, getppid_str);
61 } 61 }
62 omits_p = omits_p->link; 62 omits_p = omits_p->link;
@@ -64,19 +64,19 @@ int pidof_main(int argc, char **argv)
64 } 64 }
65#endif 65#endif
66 /* Looks like everything is set to go. */ 66 /* Looks like everything is set to go. */
67 while(optind < argc) { 67 while (optind < argc) {
68 long *pidList; 68 long *pidList;
69 long *pl; 69 long *pl;
70 70
71 /* reverse the pidlist like GNU pidof does. */ 71 /* reverse the pidlist like GNU pidof does. */
72 pidList = pidlist_reverse(find_pid_by_name(argv[optind])); 72 pidList = pidlist_reverse(find_pid_by_name(argv[optind]));
73 for(pl = pidList; *pl > 0; pl++) { 73 for (pl = pidList; *pl > 0; pl++) {
74#if ENABLE_FEATURE_PIDOF_OMIT 74#if ENABLE_FEATURE_PIDOF_OMIT
75 unsigned omitted = 0; 75 unsigned omitted = 0;
76 if (opt & OMIT) { 76 if (opt & OMIT) {
77 llist_t *omits_p = omits; 77 llist_t *omits_p = omits;
78 while (omits_p) 78 while (omits_p)
79 if (strtol(omits_p->data, NULL, 10) == *pl) { 79 if (xatoul(omits_p->data) == *pl) {
80 omitted = 1; break; 80 omitted = 1; break;
81 } else 81 } else
82 omits_p = omits_p->link; 82 omits_p = omits_p->link;
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
54int renice_main(int argc, char **argv) 54int 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 }
diff --git a/procps/top.c b/procps/top.c
index be1c45faa..14a3870a1 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -384,8 +384,8 @@ static void sig_catcher(int sig ATTRIBUTE_UNUSED)
384int top_main(int argc, char **argv) 384int top_main(int argc, char **argv)
385{ 385{
386 int count, lines, col; 386 int count, lines, col;
387 int interval = 5; /* default update rate is 5 seconds */ 387 unsigned interval = 5; /* default update rate is 5 seconds */
388 int iterations = -1; /* 2^32 iterations by default :) */ 388 unsigned iterations = UINT_MAX; /* 2^32 iterations by default :) */
389 char *sinterval, *siterations; 389 char *sinterval, *siterations;
390#ifdef CONFIG_FEATURE_USE_TERMIOS 390#ifdef CONFIG_FEATURE_USE_TERMIOS
391 struct termios new_settings; 391 struct termios new_settings;
@@ -399,8 +399,8 @@ int top_main(int argc, char **argv)
399 opt_complementary = "-"; 399 opt_complementary = "-";
400 getopt32(argc, argv, "d:n:b", 400 getopt32(argc, argv, "d:n:b",
401 &sinterval, &siterations); 401 &sinterval, &siterations);
402 if (option_mask32 & 0x1) interval = atoi(sinterval); // -d 402 if (option_mask32 & 0x1) interval = xatou(sinterval); // -d
403 if (option_mask32 & 0x2) iterations = atoi(siterations); // -n 403 if (option_mask32 & 0x2) iterations = xatou(siterations); // -n
404 //if (option_mask32 & 0x4) // -b 404 //if (option_mask32 & 0x4) // -b
405 405
406 /* change to /proc */ 406 /* change to /proc */