diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-04-08 17:58:55 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-04-09 17:49:22 +0300 |
commit | 924862c864da0b62cf93ba7abf2dc78a7e6ac48f (patch) | |
tree | 4d47039b5a095966b2551ffd9dfd0400fdbaeb55 /ubi-utils/src/ubiformat.c | |
parent | dd2a035dd6cb7408a99fac2052b6812e7f489de8 (diff) |
mtd-utils: switch ubi and ubifs tools to use common strtoX funcs
Instead of using strtol and Co directly, use our share simple_strtoX()
helpers. This is just a cleanup.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/ubiformat.c')
-rw-r--r-- | ubi-utils/src/ubiformat.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c index 098da7d..6e5cdb8 100644 --- a/ubi-utils/src/ubiformat.c +++ b/ubi-utils/src/ubiformat.c @@ -134,8 +134,7 @@ static int parse_opt(int argc, char * const argv[]) args.image_seq = rand(); while (1) { - int key; - char *endp; + int key, error = 0; unsigned long int image_seq; key = getopt_long(argc, argv, "nh?Vyqve:x:s:O:f:S:", long_options, NULL); @@ -152,14 +151,14 @@ static int parse_opt(int argc, char * const argv[]) break; case 'O': - args.vid_hdr_offs = strtoul(optarg, &endp, 0); - if (args.vid_hdr_offs <= 0 || *endp != '\0' || endp == optarg) + args.vid_hdr_offs = simple_strtoul(optarg, &error); + if (error || args.vid_hdr_offs <= 0) return errmsg("bad VID header offset: \"%s\"", optarg); break; case 'e': - args.ec = strtoull(optarg, &endp, 0); - if (args.ec < 0 || *endp != '\0' || endp == optarg) + args.ec = simple_strtoull(optarg, &error); + if (error || args.ec < 0) return errmsg("bad erase counter value: \"%s\"", optarg); if (args.ec >= EC_MAX) return errmsg("too high erase %llu, counter, max is %u", args.ec, EC_MAX); @@ -189,14 +188,14 @@ static int parse_opt(int argc, char * const argv[]) break; case 'x': - args.ubi_ver = strtoul(optarg, &endp, 0); - if (args.ubi_ver < 0 || *endp != '\0' || endp == optarg) + args.ubi_ver = simple_strtoul(optarg, &error); + if (error || args.ubi_ver < 0) return errmsg("bad UBI version: \"%s\"", optarg); break; case 'Q': - image_seq = strtoul(optarg, &endp, 0); - if (*endp != '\0' || endp == optarg || image_seq > 0xFFFFFFFF) + image_seq = simple_strtoul(optarg, &error); + if (error || image_seq > 0xFFFFFFFF) return errmsg("bad UBI image sequence number: \"%s\"", optarg); args.image_seq = image_seq; break; |