summaryrefslogtreecommitdiff
path: root/ubi-utils/src/ubidetach.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-18 11:43:45 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-18 11:43:45 +0200
commit6901377f66b867dcbdc1046c202ff72ab3ad5bff (patch)
tree9a500e62f39e4976537b769fde9d77f450b2a972 /ubi-utils/src/ubidetach.c
parentd40201ebec2cc12c10874bb561fb90378d4acee9 (diff)
ubi-utils: minor amendments
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/ubidetach.c')
-rw-r--r--ubi-utils/src/ubidetach.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/ubi-utils/src/ubidetach.c b/ubi-utils/src/ubidetach.c
index cde21d0..fe53997 100644
--- a/ubi-utils/src/ubidetach.c
+++ b/ubi-utils/src/ubidetach.c
@@ -41,7 +41,7 @@ struct args {
const char *node;
};
-static struct args myargs = {
+static struct args args = {
.devn = UBI_DEV_NUM_AUTO,
.mtdn = -1,
.node = NULL,
@@ -83,8 +83,8 @@ static int parse_opt(int argc, char * const argv[])
switch (key) {
case 'd':
- myargs.devn = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.devn < 0) {
+ args.devn = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.devn < 0) {
errmsg("bad UBI device number: \"%s\"", optarg);
return -1;
}
@@ -92,8 +92,8 @@ static int parse_opt(int argc, char * const argv[])
break;
case 'm':
- myargs.mtdn = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.mtdn < 0) {
+ args.mtdn = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.mtdn < 0) {
errmsg("bad MTD device number: \"%s\"", optarg);
return -1;
}
@@ -104,11 +104,11 @@ static int parse_opt(int argc, char * const argv[])
fprintf(stderr, "%s\n\n", doc);
fprintf(stderr, "%s\n\n", usage);
fprintf(stderr, "%s\n", optionsstr);
- exit(0);
+ exit(EXIT_SUCCESS);
case 'V':
fprintf(stderr, "%s\n", PROGRAM_VERSION);
- exit(0);
+ exit(EXIT_SUCCESS);
case ':':
errmsg("parameter is missing");
@@ -116,7 +116,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
@@ -128,17 +128,17 @@ static int parse_opt(int argc, char * const argv[])
return -1;
}
- if (myargs.mtdn == -1 && myargs.devn == -1) {
+ if (args.mtdn == -1 && args.devn == -1) {
errmsg("neither MTD nor UBI devices were specified (use -h for help)");
return -1;
}
- if (myargs.mtdn != -1 && myargs.devn != -1) {
+ if (args.mtdn != -1 && args.devn != -1) {
errmsg("specify either MTD or UBI device (use -h for help)");
return -1;
}
- myargs.node = argv[optind];
+ args.node = argv[optind];
return 0;
}
@@ -174,17 +174,17 @@ int main(int argc, char * const argv[])
goto out_libubi;
}
- if (myargs.devn != -1) {
- err = ubi_remove_dev(libubi, myargs.node, myargs.devn);
+ if (args.devn != -1) {
+ err = ubi_remove_dev(libubi, args.node, args.devn);
if (err) {
- errmsg("cannot remove ubi%d", myargs.devn);
+ errmsg("cannot remove ubi%d", args.devn);
perror("ubi_remove_dev");
goto out_libubi;
}
} else {
- err = ubi_detach_mtd(libubi, myargs.node, myargs.mtdn);
+ err = ubi_detach_mtd(libubi, args.node, args.mtdn);
if (err) {
- errmsg("cannot detach mtd%d", myargs.mtdn);
+ errmsg("cannot detach mtd%d", args.mtdn);
perror("ubi_detach_mtd");
goto out_libubi;
}