9
0
Fork 0

dfu command: check return values

Check the return value of usb_dfu_register and bail out
with an error if it fails. Also return successfully if it succeeds
instead of returning 1 unconditionally.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-02-13 10:31:08 +01:00
parent 1a3315ad7d
commit 4435836ec2
1 changed files with 6 additions and 3 deletions

View File

@ -101,7 +101,7 @@ static int do_dfu(int argc, char *argv[])
char *manufacturer = "barebox";
const char *productname = barebox_get_model();
u16 idVendor = 0, idProduct = 0;
int ret;
while((opt = getopt(argc, argv, "m:p:V:P:")) > 0) {
switch(opt) {
@ -134,6 +134,7 @@ static int do_dfu(int argc, char *argv[])
dfu_alts = xrealloc(dfu_alts, sizeof(*dfu_alts) * (n + 1));
if (dfu_do_parse_one(argstr, &endptr, &dfu_alts[n])) {
printf("parse error\n");
ret = -EINVAL;
goto out;
}
argstr = endptr;
@ -147,7 +148,7 @@ static int do_dfu(int argc, char *argv[])
pdata.idVendor = idVendor;
pdata.idProduct = idProduct;
usb_dfu_register(&pdata);
ret = usb_dfu_register(&pdata);
out:
while (n) {
@ -155,8 +156,10 @@ out:
free(dfu_alts[n].name);
free(dfu_alts[n].dev);
};
free(dfu_alts);
return 1;
return ret;
}
BAREBOX_CMD_HELP_START(dfu)