diff options
-rw-r--r-- | src/mknod.c | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/src/mknod.c b/src/mknod.c index a9becb330..ae79a8493 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -36,6 +36,7 @@ #include "modechange.h" #include "version.h" #include "error.h" +#include "xstrtol.h" static void usage (); @@ -56,34 +57,6 @@ static struct option const longopts[] = {NULL, 0, NULL, 0} }; -static int -my_strtol (str, ptr, base, result) - const char *str; - const char **ptr; - int base; - long int *result; -{ - long int val; - char *terminator; - int return_code; - - return_code = 0; - - errno = 0; - val = strtol (str, &terminator, base); - - if (terminator == str - || (ptr == NULL && *terminator != '\0') - || errno == ERANGE) - return_code = 1; - - if (ptr != NULL) - *ptr = terminator; - - *result = val; - return return_code; -} - void main (argc, argv) int argc; @@ -165,11 +138,11 @@ numbers must be specified"); } s = argv[optind + 2]; - if (my_strtol (s, NULL, 0, &tmp_major)) + if (xstrtol (s, NULL, 0, &tmp_major, NULL) != LONGINT_OK) error (1, 0, "invalid major device number `%s'", s); s = argv[optind + 3]; - if (my_strtol (s, NULL, 0, &tmp_minor)) + if (xstrtol (s, NULL, 0, &tmp_minor, NULL) != LONGINT_OK) error (1, 0, "invalid minor device number `%s'", s); i_major = (int) tmp_major; @@ -194,11 +167,11 @@ numbers must be specified"); } s = argv[optind + 2]; - if (my_strtol (s, NULL, 0, &tmp_major)) + if (xstrtol (s, NULL, 0, &tmp_major, NULL) != LONGINT_OK) error (1, 0, "invalid major device number `%s'", s); s = argv[optind + 3]; - if (my_strtol (s, NULL, 0, &tmp_minor)) + if (xstrtol (s, NULL, 0, &tmp_minor, NULL) != LONGINT_OK) error (1, 0, "invalid minor device number `%s'", s); i_major = (int) tmp_major; |