summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ubi-utils/src/ubiattach.c40
-rw-r--r--ubi-utils/src/ubicrc32.c6
-rw-r--r--ubi-utils/src/ubidetach.c32
-rw-r--r--ubi-utils/src/ubimkvol.c88
-rw-r--r--ubi-utils/src/ubinfo.c50
-rw-r--r--ubi-utils/src/ubirmvol.c24
-rw-r--r--ubi-utils/src/ubiupdate.c56
7 files changed, 148 insertions, 148 deletions
diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/src/ubiattach.c
index c146e76..2e6c20d 100644
--- a/ubi-utils/src/ubiattach.c
+++ b/ubi-utils/src/ubiattach.c
@@ -42,7 +42,7 @@ struct args {
const char *node;
};
-static struct args myargs = {
+static struct args args = {
.devn = UBI_DEV_NUM_AUTO,
.mtdn = -1,
.vidoffs = 0,
@@ -57,7 +57,7 @@ static const char *optionsstr =
" (the number is assigned automatically if this is not\n"
" specified\n"
"-m, --mtdn=<MTD device number> MTD device number to attach\n"
-"-o, --vid-hdr-offset VID header offset (do not specify this unless you\n"
+"-O, --vid-hdr-offset VID header offset (do not specify this unless you\n"
" really know what you do and the optimal defaults will\n"
" be used)\n"
"-h, --help print help message\n"
@@ -73,7 +73,7 @@ static const char *usage =
static const struct option long_options[] = {
{ .name = "devn", .has_arg = 1, .flag = NULL, .val = 'd' },
{ .name = "mtdn", .has_arg = 1, .flag = NULL, .val = 'm' },
- { .name = "vid-hdr-offset", .has_arg = 1, .flag = NULL, .val = 'o' },
+ { .name = "vid-hdr-offset", .has_arg = 1, .flag = NULL, .val = 'O' },
{ .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
{ NULL, 0, NULL, 0},
@@ -85,14 +85,14 @@ static int parse_opt(int argc, char * const argv[])
int key;
char *endp;
- key = getopt_long(argc, argv, "m:d:ohV", long_options, NULL);
+ key = getopt_long(argc, argv, "m:d:OhV", long_options, NULL);
if (key == -1)
break;
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;
}
@@ -100,8 +100,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;
}
@@ -109,8 +109,8 @@ static int parse_opt(int argc, char * const argv[])
break;
case 'o':
- myargs.vidoffs = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.vidoffs <= 0) {
+ args.vidoffs = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.vidoffs <= 0) {
errmsg("bad VID header offset: \"%s\"", optarg);
return -1;
}
@@ -121,11 +121,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");
@@ -133,7 +133,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
@@ -145,12 +145,12 @@ static int parse_opt(int argc, char * const argv[])
return -1;
}
- if (myargs.mtdn == -1) {
+ if (args.mtdn == -1) {
errmsg("MTD device number was not specified (use -h for help)");
return -1;
}
- myargs.node = argv[optind];
+ args.node = argv[optind];
return 0;
}
@@ -188,13 +188,13 @@ int main(int argc, char * const argv[])
goto out_libubi;
}
- req.dev_num = myargs.devn;
- req.mtd_num = myargs.mtdn;
- req.vid_hdr_offset = myargs.vidoffs;
+ req.dev_num = args.devn;
+ req.mtd_num = args.mtdn;
+ req.vid_hdr_offset = args.vidoffs;
- err = ubi_attach_mtd(libubi, myargs.node, &req);
+ err = ubi_attach_mtd(libubi, args.node, &req);
if (err) {
- errmsg("cannot attach mtd%d", myargs.mtdn);
+ errmsg("cannot attach mtd%d", args.mtdn);
perror("ubi_attach_mtd");
goto out_libubi;
}
diff --git a/ubi-utils/src/ubicrc32.c b/ubi-utils/src/ubicrc32.c
index cde3104..0f10b31 100644
--- a/ubi-utils/src/ubicrc32.c
+++ b/ubi-utils/src/ubicrc32.c
@@ -69,11 +69,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");
@@ -81,7 +81,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
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;
}
diff --git a/ubi-utils/src/ubimkvol.c b/ubi-utils/src/ubimkvol.c
index 42b61b8..c4079e6 100644
--- a/ubi-utils/src/ubimkvol.c
+++ b/ubi-utils/src/ubimkvol.c
@@ -49,7 +49,7 @@ struct args {
int maxavs;
};
-static struct args myargs = {
+static struct args args = {
.vol_type = UBI_DYNAMIC_VOLUME,
.bytes = -1,
.lebs = -1,
@@ -104,24 +104,24 @@ static int param_sanity_check(void)
{
int len;
- if (myargs.bytes == -1 && !myargs.maxavs && myargs.lebs == -1) {
+ if (args.bytes == -1 && !args.maxavs && args.lebs == -1) {
errmsg("volume size was not specified (use -h for help)");
return -1;
}
- if ((myargs.bytes != -1 && (myargs.maxavs || myargs.lebs != -1)) ||
- (myargs.lebs != -1 && (myargs.maxavs || myargs.bytes != -1)) ||
- (myargs.maxavs && (myargs.bytes != -1 || myargs.lebs != -1))) {
+ if ((args.bytes != -1 && (args.maxavs || args.lebs != -1)) ||
+ (args.lebs != -1 && (args.maxavs || args.bytes != -1)) ||
+ (args.maxavs && (args.bytes != -1 || args.lebs != -1))) {
errmsg("size specified with more then one option");
return -1;
}
- if (myargs.name == NULL) {
+ if (args.name == NULL) {
errmsg("volume name was not specified (use -h for help)");
return -1;
}
- len = strlen(myargs.name);
+ len = strlen(args.name);
if (len > UBI_MAX_VOLUME_NAME) {
errmsg("too long name (%d symbols), max is %d",
len, UBI_MAX_VOLUME_NAME);
@@ -144,9 +144,9 @@ static int parse_opt(int argc, char * const argv[])
switch (key) {
case 't':
if (!strcmp(optarg, "dynamic"))
- myargs.vol_type = UBI_DYNAMIC_VOLUME;
+ args.vol_type = UBI_DYNAMIC_VOLUME;
else if (!strcmp(optarg, "static"))
- myargs.vol_type = UBI_STATIC_VOLUME;
+ args.vol_type = UBI_STATIC_VOLUME;
else {
errmsg("bad volume type: \"%s\"", optarg);
return -1;
@@ -154,8 +154,8 @@ static int parse_opt(int argc, char * const argv[])
break;
case 's':
- myargs.bytes = strtoull(optarg, &endp, 0);
- if (endp == optarg || myargs.bytes <= 0) {
+ args.bytes = strtoull(optarg, &endp, 0);
+ if (endp == optarg || args.bytes <= 0) {
errmsg("bad volume size: \"%s\"", optarg);
return -1;
}
@@ -167,51 +167,51 @@ static int parse_opt(int argc, char * const argv[])
"should be 'KiB', 'MiB' or 'GiB'", endp);
return -1;
}
- myargs.bytes *= mult;
+ args.bytes *= mult;
}
break;
case 'S':
- myargs.lebs = strtoull(optarg, &endp, 0);
- if (endp == optarg || myargs.lebs <= 0 || *endp != '\0') {
+ args.lebs = strtoull(optarg, &endp, 0);
+ if (endp == optarg || args.lebs <= 0 || *endp != '\0') {
errmsg("bad volume size: \"%s\"", optarg);
return -1;
}
break;
case 'a':
- myargs.alignment = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.alignment <= 0) {
+ args.alignment = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.alignment <= 0) {
errmsg("bad volume alignment: \"%s\"", optarg);
return -1;
}
break;
case 'n':
- myargs.vol_id = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.vol_id < 0) {
+ args.vol_id = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.vol_id < 0) {
errmsg("bad volume ID: " "\"%s\"", optarg);
return -1;
}
break;
case 'N':
- myargs.name = optarg;
- myargs.nlen = strlen(myargs.name);
+ args.name = optarg;
+ args.nlen = strlen(args.name);
break;
case 'h':
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 'm':
- myargs.maxavs = 1;
+ args.maxavs = 1;
break;
case ':':
@@ -220,7 +220,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
@@ -232,7 +232,7 @@ static int parse_opt(int argc, char * const argv[])
return -1;
}
- myargs.node = argv[optind];
+ args.node = argv[optind];
if (param_sanity_check())
return -1;
@@ -259,52 +259,52 @@ int main(int argc, char * const argv[])
return -1;
}
- err = ubi_node_type(libubi, myargs.node);
+ err = ubi_node_type(libubi, args.node);
if (err == 2) {
errmsg("\"%s\" is an UBI volume node, not an UBI device node",
- myargs.node);
+ args.node);
goto out_libubi;
} else if (err < 0) {
- errmsg("\"%s\" is not an UBI device node", myargs.node);
+ errmsg("\"%s\" is not an UBI device node", args.node);
goto out_libubi;
}
- err = ubi_get_dev_info(libubi, myargs.node, &dev_info);
+ err = ubi_get_dev_info(libubi, args.node, &dev_info);
if (err) {
errmsg("cannot get information about UBI device \"%s\"",
- myargs.node);
+ args.node);
perror("ubi_get_dev_info");
goto out_libubi;
}
- if (myargs.maxavs) {
- myargs.bytes = dev_info.avail_bytes;
+ if (args.maxavs) {
+ args.bytes = dev_info.avail_bytes;
printf("Set volume size to %lld\n", req.bytes);
}
- if (myargs.lebs != -1) {
- myargs.bytes = dev_info.leb_size;
- myargs.bytes -= dev_info.leb_size % myargs.alignment;
- myargs.bytes *= myargs.lebs;
+ if (args.lebs != -1) {
+ args.bytes = dev_info.leb_size;
+ args.bytes -= dev_info.leb_size % args.alignment;
+ args.bytes *= args.lebs;
}
- req.vol_id = myargs.vol_id;
- req.alignment = myargs.alignment;
- req.bytes = myargs.bytes;
- req.vol_type = myargs.vol_type;
- req.name = myargs.name;
+ req.vol_id = args.vol_id;
+ req.alignment = args.alignment;
+ req.bytes = args.bytes;
+ req.vol_type = args.vol_type;
+ req.name = args.name;
- err = ubi_mkvol(libubi, myargs.node, &req);
+ err = ubi_mkvol(libubi, args.node, &req);
if (err < 0) {
errmsg("cannot UBI create volume");
perror("ubi_mkvol");
goto out_libubi;
}
- myargs.vol_id = req.vol_id;
+ args.vol_id = req.vol_id;
/* Print information about the created device */
- err = ubi_get_vol_info1(libubi, dev_info.dev_num, myargs.vol_id, &vol_info);
+ err = ubi_get_vol_info1(libubi, dev_info.dev_num, args.vol_id, &vol_info);
if (err) {
errmsg("cannot get information about newly created UBI volume");
perror("ubi_get_vol_info1");
diff --git a/ubi-utils/src/ubinfo.c b/ubi-utils/src/ubinfo.c
index 247e2eb..07b1790 100644
--- a/ubi-utils/src/ubinfo.c
+++ b/ubi-utils/src/ubinfo.c
@@ -42,7 +42,7 @@ struct args {
const char *node;
};
-static struct args myargs = {
+static struct args args = {
.vol_id = -1,
.devn = -1,
.all = 0,
@@ -94,20 +94,20 @@ static int parse_opt(int argc, char * const argv[])
switch (key) {
case 'a':
- myargs.all = 1;
+ args.all = 1;
break;
case 'n':
- myargs.vol_id = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.vol_id < 0) {
+ args.vol_id = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.vol_id < 0) {
errmsg("bad volume ID: " "\"%s\"", optarg);
return -1;
}
break;
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;
}
@@ -118,11 +118,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");
@@ -130,12 +130,12 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
if (optind == argc - 1) {
- myargs.node = argv[optind];
+ args.node = argv[optind];
} else if (optind < argc) {
errmsg("more then one UBI devices specified (use -h for help)");
return -1;
@@ -170,7 +170,7 @@ static int translate_dev(libubi_t libubi, const char *node)
return -1;
}
- myargs.devn = dev_info.dev_num;
+ args.devn = dev_info.dev_num;
} else {
struct ubi_vol_info vol_info;
@@ -182,15 +182,15 @@ static int translate_dev(libubi_t libubi, const char *node)
return -1;
}
- if (myargs.vol_id != -1) {
+ if (args.vol_id != -1) {
errmsg("both volume character device node (\"%s\") and "
"volume ID (%d) are specify, use only one of them"
- "(use -h for help)", node, myargs.vol_id);
+ "(use -h for help)", node, args.vol_id);
return -1;
}
- myargs.devn = vol_info.dev_num;
- myargs.vol_id = vol_info.vol_id;
+ args.devn = vol_info.dev_num;
+ args.vol_id = vol_info.vol_id;
}
return 0;
@@ -402,7 +402,7 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- if (!myargs.node && myargs.devn != -1) {
+ if (!args.node && args.devn != -1) {
errmsg("specify either device number or node file (use -h for help)");
return -1;
}
@@ -414,31 +414,31 @@ int main(int argc, char * const argv[])
return -1;
}
- if (myargs.node) {
+ if (args.node) {
/*
* A character device was specified, translate this into UBI
* device number and volume ID.
*/
- err = translate_dev(libubi, myargs.node);
+ err = translate_dev(libubi, args.node);
if (err)
goto out_libubi;
}
- if (myargs.vol_id != -1 && myargs.devn == -1) {
+ if (args.vol_id != -1 && args.devn == -1) {
errmsg("volume ID is specified, but UBI device number is not "
"(use -h for help)\n");
goto out_libubi;
}
- if (myargs.devn != -1 && myargs.vol_id != -1) {
- print_vol_info(libubi, myargs.devn, myargs.vol_id);
+ if (args.devn != -1 && args.vol_id != -1) {
+ print_vol_info(libubi, args.devn, args.vol_id);
goto out;
}
- if (myargs.devn == -1 && myargs.vol_id == -1)
- err = print_general_info(libubi, myargs.all);
- else if (myargs.devn != -1 && myargs.vol_id == -1)
- err = print_dev_info(libubi, myargs.devn, myargs.all);
+ if (args.devn == -1 && args.vol_id == -1)
+ err = print_general_info(libubi, args.all);
+ else if (args.devn != -1 && args.vol_id == -1)
+ err = print_dev_info(libubi, args.devn, args.all);
if (err)
goto out_libubi;
diff --git a/ubi-utils/src/ubirmvol.c b/ubi-utils/src/ubirmvol.c
index 60bcdc0..7eb7f5b 100644
--- a/ubi-utils/src/ubirmvol.c
+++ b/ubi-utils/src/ubirmvol.c
@@ -42,7 +42,7 @@ struct args {
const char *node;
};
-static struct args myargs = {
+static struct args args = {
.vol_id = -1,
.node = NULL,
};
@@ -69,7 +69,7 @@ static const struct option long_options[] = {
static int param_sanity_check(void)
{
- if (myargs.vol_id == -1) {
+ if (args.vol_id == -1) {
errmsg("volume ID is was not specified");
return -1;
}
@@ -90,8 +90,8 @@ static int parse_opt(int argc, char * const argv[])
switch (key) {
case 'n':
- myargs.vol_id = strtoul(optarg, &endp, 0);
- if (*endp != '\0' || endp == optarg || myargs.vol_id < 0) {
+ args.vol_id = strtoul(optarg, &endp, 0);
+ if (*endp != '\0' || endp == optarg || args.vol_id < 0) {
errmsg("bad volume ID: " "\"%s\"", optarg);
return -1;
}
@@ -101,11 +101,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");
@@ -113,7 +113,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
@@ -125,7 +125,7 @@ static int parse_opt(int argc, char * const argv[])
return -1;
}
- myargs.node = argv[optind];
+ args.node = argv[optind];
if (param_sanity_check())
return -1;
@@ -149,17 +149,17 @@ int main(int argc, char * const argv[])
return -1;
}
- err = ubi_node_type(libubi, myargs.node);
+ err = ubi_node_type(libubi, args.node);
if (err == 2) {
errmsg("\"%s\" is an UBI volume node, not an UBI device node",
- myargs.node);
+ args.node);
goto out_libubi;
} else if (err < 0) {
- errmsg("\"%s\" is not an UBI device node", myargs.node);
+ errmsg("\"%s\" is not an UBI device node", args.node);
goto out_libubi;
}
- err = ubi_rmvol(libubi, myargs.node, myargs.vol_id);
+ err = ubi_rmvol(libubi, args.node, args.vol_id);
if (err) {
errmsg("cannot UBI remove volume");
perror("ubi_rmvol");
diff --git a/ubi-utils/src/ubiupdate.c b/ubi-utils/src/ubiupdate.c
index 75222d4..6898119 100644
--- a/ubi-utils/src/ubiupdate.c
+++ b/ubi-utils/src/ubiupdate.c
@@ -47,7 +47,7 @@ struct args {
const char *img;
};
-static struct args myargs = {
+static struct args args = {
.truncate = 0,
.node = NULL,
.img = NULL,
@@ -86,18 +86,18 @@ static int parse_opt(int argc, char * const argv[])
switch (key) {
case 't':
- myargs.truncate = 1;
+ args.truncate = 1;
break;
case 'h':
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");
@@ -105,7 +105,7 @@ static int parse_opt(int argc, char * const argv[])
default:
fprintf(stderr, "Use -h for help\n");
- exit(-1);
+ return -1;
}
}
@@ -118,8 +118,8 @@ static int parse_opt(int argc, char * const argv[])
return -1;
}
- myargs.node = argv[optind];
- myargs.img = argv[optind + 1];
+ args.node = argv[optind];
+ args.img = argv[optind + 1];
return 0;
}
@@ -128,16 +128,16 @@ static int truncate_volume(libubi_t libubi)
{
int err, fd;
- fd = open(myargs.node, O_RDWR);
+ fd = open(args.node, O_RDWR);
if (fd == -1) {
- errmsg("cannot open \"%s\"", myargs.node);
+ errmsg("cannot open \"%s\"", args.node);
perror("open");
return -1;
}
err = ubi_update_start(libubi, fd, 0);
if (err) {
- errmsg("cannot truncate volume \"%s\"", myargs.node);
+ errmsg("cannot truncate volume \"%s\"", args.node);
perror("ubi_update_start");
close(fd);
return -1;
@@ -159,14 +159,14 @@ static int ubi_write(int fd, const void *buf, int len)
continue;
}
errmsg("cannot write %d bytes to volume \"%s\"",
- len, myargs.node);
+ len, args.node);
perror("write");
return -1;
}
if (ret == 0) {
errmsg("cannot write %d bytes to volume \"%s\"",
- len, myargs.node);
+ len, args.node);
return -1;
}
@@ -190,36 +190,36 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
return -1;
}
- err = stat(myargs.img, &st);
+ err = stat(args.img, &st);
if (err < 0) {
- errmsg("stat failed on \"%s\"", myargs.node);
+ errmsg("stat failed on \"%s\"", args.node);
goto out_free;
}
bytes = st.st_size;
if (bytes > vol_info->rsvd_bytes) {
errmsg("\"%s\" (size %lld) will not fit volume \"%s\" (size %lld)",
- myargs.img, bytes, myargs.node, vol_info->rsvd_bytes);
+ args.img, bytes, args.node, vol_info->rsvd_bytes);
goto out_free;
}
- fd = open(myargs.node, O_RDWR);
+ fd = open(args.node, O_RDWR);
if (fd == -1) {
- errmsg("cannot open UBI volume \"%s\"", myargs.node);
+ errmsg("cannot open UBI volume \"%s\"", args.node);
perror("open");
goto out_free;
}
- ifd = open(myargs.img, O_RDONLY);
+ ifd = open(args.img, O_RDONLY);
if (ifd == -1) {
- errmsg("cannot open \"%s\"", myargs.img);
+ errmsg("cannot open \"%s\"", args.img);
perror("open");
goto out_close1;
}
err = ubi_update_start(libubi, fd, bytes);
if (err) {
- errmsg("cannot start volume \"%s\" update", myargs.node);
+ errmsg("cannot start volume \"%s\" update", args.node);
perror("ubi_update_start");
goto out_close;
}
@@ -237,7 +237,7 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
continue;
} else {
errmsg("cannot read %d bytes from \"%s\"",
- tocopy, myargs.img);
+ tocopy, args.img);
perror("read");
goto out_close;
}
@@ -273,7 +273,7 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- if (!myargs.img && !myargs.truncate) {
+ if (!args.img && !args.truncate) {
errmsg("incorrect arguments, use -h for help");
return -1;
}
@@ -284,25 +284,25 @@ int main(int argc, char * const argv[])
goto out_libubi;
}
- err = ubi_node_type(libubi, myargs.node);
+ err = ubi_node_type(libubi, args.node);
if (err == 1) {
errmsg("\"%s\" is an UBI device node, not an UBI volume node",
- myargs.node);
+ args.node);
goto out_libubi;
} else if (err < 0) {
- errmsg("\"%s\" is not an UBI volume node", myargs.node);
+ errmsg("\"%s\" is not an UBI volume node", args.node);
goto out_libubi;
}
- err = ubi_get_vol_info(libubi, myargs.node, &vol_info);
+ err = ubi_get_vol_info(libubi, args.node, &vol_info);
if (err) {
errmsg("cannot get information about UBI volume \"%s\"",
- myargs.node);
+ args.node);
perror("ubi_get_dev_info");
goto out_libubi;
}
- if (myargs.truncate)
+ if (args.truncate)
err = truncate_volume(libubi);
else
err = update_volume(libubi, &vol_info);