diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-29 21:15:52 +0300 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-11-29 21:15:52 +0300 |
commit | c6ce8733dda7e6f9146e0a040048aebea0c2e589 (patch) | |
tree | fb5fd16229f7c9f34423c4f27ed47cc19e7434df /util-linux/ipcrm.c | |
parent | a35c9e91ba53073ff797d1d68d0d4e1836d934f0 (diff) |
cut 0.5k off mkfs.minix
assorted strtoul fixes (that's what brought me into minix)...
Diffstat (limited to 'util-linux/ipcrm.c')
-rw-r--r-- | util-linux/ipcrm.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c index 8ea9627c1..507e58fe3 100644 --- a/util-linux/ipcrm.c +++ b/util-linux/ipcrm.c @@ -39,19 +39,16 @@ typedef enum type_id { static int remove_ids(type_id type, int argc, char **argv) { - int id; + unsigned long id; int ret = 0; /* silence gcc */ - char *end; int nb_errors = 0; union semun arg; arg.val = 0; while (argc) { - - id = strtoul(argv[0], &end, 10); - - if (*end != 0) { + id = bb_strtoul(argv[0], NULL, 10); + if (errno || id > INT_MAX) { bb_error_msg("invalid id: %s", argv[0]); nb_errors++; } else { @@ -91,11 +88,13 @@ int ipcrm_main(int argc, char **argv) type_id what = 0; /* silence gcc */ char w; - if ((((w=argv[1][0]) == 'm' && argv[1][1] == 's' && argv[1][2] == 'g') - || (argv[1][0] == 's' - && ((w=argv[1][1]) == 'h' || w == 'e') - && argv[1][2] == 'm')) - && argv[1][3] == '\0') { + w=argv[1][0]; + if ( ((w == 'm' && argv[1][1] == 's' && argv[1][2] == 'g') + || (argv[1][0] == 's' + && ((w=argv[1][1]) == 'h' || w == 'e') + && argv[1][2] == 'm') + ) && argv[1][3] == '\0' + ) { if (argc < 3) bb_show_usage(); @@ -140,7 +139,7 @@ int ipcrm_main(int argc, char **argv) if (iskey) { /* keys are in hex or decimal */ - key_t key = strtoul(optarg, NULL, 0); + key_t key = xstrtoul(optarg, 0); if (key == IPC_PRIVATE) { error++; @@ -176,7 +175,7 @@ int ipcrm_main(int argc, char **argv) } } else { /* ids are in decimal */ - id = strtoul(optarg, NULL, 10); + id = xatoul(optarg); } result = ((c == 'q') ? msgctl(id, IPC_RMID, NULL) : |