diff options
Diffstat (limited to 'ubi-utils/src/ubiattach.c')
-rw-r--r-- | ubi-utils/src/ubiattach.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/src/ubiattach.c index d2f191b..9297b56 100644 --- a/ubi-utils/src/ubiattach.c +++ b/ubi-utils/src/ubiattach.c @@ -91,8 +91,7 @@ static const struct option long_options[] = { static int parse_opt(int argc, char * const argv[]) { while (1) { - int key; - char *endp; + int key, error = 0; key = getopt_long(argc, argv, "p:m:d:O:hV", long_options, NULL); if (key == -1) @@ -103,22 +102,22 @@ static int parse_opt(int argc, char * const argv[]) args.dev = optarg; break; case 'd': - args.devn = strtoul(optarg, &endp, 0); - if (*endp != '\0' || endp == optarg || args.devn < 0) + args.devn = simple_strtoul(optarg, &error); + if (error || args.devn < 0) return errmsg("bad UBI device number: \"%s\"", optarg); break; case 'm': - args.mtdn = strtoul(optarg, &endp, 0); - if (*endp != '\0' || endp == optarg || args.mtdn < 0) + args.mtdn = simple_strtoul(optarg, &error); + if (error || args.mtdn < 0) return errmsg("bad MTD device number: \"%s\"", optarg); break; case 'O': - args.vidoffs = strtoul(optarg, &endp, 0); - if (*endp != '\0' || endp == optarg || args.vidoffs <= 0) + args.vidoffs = simple_strtoul(optarg, &error); + if (error || args.vidoffs <= 0) return errmsg("bad VID header offset: \"%s\"", optarg); break; |