attempt to regularize atoi mess.
This commit is contained in:
@@ -12,10 +12,6 @@
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/timex.h>
|
||||
|
||||
static const struct {int bit; const char *name;} statlist[] = {
|
||||
@@ -58,19 +54,19 @@ int adjtimex_main(int argc, char **argv)
|
||||
&opt_o, &opt_f, &opt_p, &opt_t);
|
||||
//if (opt & 0x1) // -q
|
||||
if (opt & 0x2) { // -o
|
||||
txc.offset = atoi(opt_o);
|
||||
txc.offset = xatoi(opt_o);
|
||||
txc.modes |= ADJ_OFFSET_SINGLESHOT;
|
||||
}
|
||||
if (opt & 0x4) { // -f
|
||||
txc.freq = atoi(opt_f);
|
||||
txc.freq = xatou(opt_f);
|
||||
txc.modes |= ADJ_FREQUENCY;
|
||||
}
|
||||
if (opt & 0x8) { // -p
|
||||
txc.constant = atoi(opt_p);
|
||||
txc.constant = xatoi(opt_p);
|
||||
txc.modes |= ADJ_TIMECONST;
|
||||
}
|
||||
if (opt & 0x10) { // -t
|
||||
txc.tick = atoi(opt_t);
|
||||
txc.tick = xatoi(opt_t);
|
||||
txc.modes |= ADJ_TICK;
|
||||
}
|
||||
if (argc != optind) { /* no valid non-option parameters */
|
||||
|
@@ -65,10 +65,10 @@ typedef struct CronLine {
|
||||
#define DaemonUid 0
|
||||
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
static short DebugOpt;
|
||||
static unsigned DebugOpt;
|
||||
#endif
|
||||
|
||||
static short LogLevel = 8;
|
||||
static unsigned LogLevel = 8;
|
||||
static const char *LogFile;
|
||||
static const char *CDir = CRONTABS;
|
||||
|
||||
@@ -155,7 +155,7 @@ int crond_main(int ac, char **av)
|
||||
#endif
|
||||
);
|
||||
if (opt & 1) {
|
||||
LogLevel = atoi(lopt);
|
||||
LogLevel = xatou(lopt);
|
||||
}
|
||||
if (opt & 2) {
|
||||
if (*Lopt != 0) {
|
||||
@@ -169,7 +169,7 @@ int crond_main(int ac, char **av)
|
||||
}
|
||||
#if ENABLE_DEBUG_CROND_OPTION
|
||||
if (opt & 64) {
|
||||
DebugOpt = atoi(dopt);
|
||||
DebugOpt = xatou(dopt);
|
||||
LogLevel = 0;
|
||||
}
|
||||
#endif
|
||||
|
@@ -171,7 +171,7 @@ static void stack_machine(const char *argument)
|
||||
}
|
||||
o++;
|
||||
}
|
||||
bb_error_msg_and_die("%s: syntax error.", argument);
|
||||
bb_error_msg_and_die("%s: syntax error", argument);
|
||||
}
|
||||
|
||||
/* return pointer to next token in buffer and set *buffer to one char
|
||||
|
@@ -2063,7 +2063,7 @@ static void parse_opts(unsigned long *get, unsigned long *set, unsigned long *va
|
||||
}
|
||||
if (optarg) {
|
||||
*set = 1;
|
||||
*value = bb_xgetlarg(optarg, 10, min, max);
|
||||
*value = xatol_range(optarg, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2154,8 +2154,8 @@ int hdparm_main(int argc, char **argv)
|
||||
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
|
||||
if (c == 'R') {
|
||||
parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX);
|
||||
hwif_ctrl = bb_xgetlarg((argv[optind]) ? argv[optind] : "", 10, 0, INT_MAX);
|
||||
hwif_irq = bb_xgetlarg((argv[optind+1]) ? argv[optind+1] : "", 10, 0, INT_MAX);
|
||||
hwif_ctrl = xatoi_u((argv[optind]) ? argv[optind] : "");
|
||||
hwif_irq = xatoi_u((argv[optind+1]) ? argv[optind+1] : "");
|
||||
/* Move past the 2 additional arguments */
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
|
@@ -21,10 +21,10 @@ int makedevs_main(int argc, char **argv)
|
||||
|
||||
basedev = argv[1];
|
||||
type = argv[2];
|
||||
Smajor = atoi(argv[3]);
|
||||
Sminor = atoi(argv[4]);
|
||||
S = atoi(argv[5]);
|
||||
E = atoi(argv[6]);
|
||||
Smajor = xatoi_u(argv[3]);
|
||||
Sminor = xatoi_u(argv[4]);
|
||||
S = xatoi_u(argv[5]);
|
||||
E = xatoi_u(argv[6]);
|
||||
nodname = argc == 8 ? basedev : buf;
|
||||
|
||||
mode = 0660;
|
||||
|
@@ -84,7 +84,7 @@ int mt_main(int argc, char **argv)
|
||||
|
||||
op.mt_op = code->value;
|
||||
if (argc >= 3)
|
||||
op.mt_count = atoi(argv[2]);
|
||||
op.mt_count = xatoi_u(argv[2]);
|
||||
else
|
||||
op.mt_count = 1; /* One, not zero, right? */
|
||||
|
||||
|
@@ -34,7 +34,7 @@ int strings_main(int argc, char **argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
n = bb_xgetlarg(n_arg, 10, 1, INT_MAX);
|
||||
n = xatoul_range(n_arg, 1, INT_MAX);
|
||||
string = xzalloc(n + 1);
|
||||
n--;
|
||||
|
||||
@@ -45,7 +45,8 @@ int strings_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
if ((file = bb_wfopen(*argv, "r"))) {
|
||||
file = bb_wfopen(*argv, "r");
|
||||
if (file) {
|
||||
PIPE:
|
||||
count = 0;
|
||||
do {
|
||||
|
@@ -26,13 +26,13 @@ static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused)
|
||||
int watchdog_main(int argc, char **argv)
|
||||
{
|
||||
unsigned opts;
|
||||
unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */
|
||||
unsigned timer_duration = 30; /* Userspace timer duration, in seconds */
|
||||
char *t_arg;
|
||||
|
||||
opts = getopt32(argc, argv, "Ft:", &t_arg);
|
||||
|
||||
if (opts & OPT_TIMER)
|
||||
timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX);
|
||||
timer_duration = xatou(t_arg);
|
||||
|
||||
/* We're only interested in the watchdog device .. */
|
||||
if (optind < argc - 1 || argc == 1)
|
||||
|
Reference in New Issue
Block a user