ubiattach command: Properly check return values
- print error when ioctl fails, not a combined message when one of ioctl or ubi_attach_mtd_dev failed. - ubi_attach_mtd_dev() returns the ubi number for success, not 0, so check for ret < 0 to detect errors. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
675ef4770f
commit
56ac905457
|
@ -71,12 +71,17 @@ static int do_ubiattach(int argc, char *argv[])
|
|||
}
|
||||
|
||||
ret = ioctl(fd, MEMGETINFO, &user);
|
||||
if (!ret)
|
||||
ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0);
|
||||
if (ret) {
|
||||
printf("MEMGETINFO failed: %s\n", strerror(-ret));
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0);
|
||||
if (ret < 0)
|
||||
printf("failed to attach: %s\n", strerror(-ret));
|
||||
|
||||
else
|
||||
ret = 0;
|
||||
err:
|
||||
close(fd);
|
||||
|
||||
return ret ? 1 : 0;
|
||||
|
|
Loading…
Reference in New Issue