Hi

This patch fix a bug where an error message is printed when 
attaching more than one UBI device. ubi_attach_mtd_dev() returns
the UBI device number (>=0) on success.

Signed-off-by: Xavier Douville <[email protected]>
---
 commands/ubi.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/commands/ubi.c b/commands/ubi.c
index 1653eaa..8dc95ee 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -71,15 +71,19 @@ static int do_ubiattach(int argc, char *argv[])
        }
 
        ret = ioctl(fd, MEMGETINFO, &user);
-       if (!ret)
+       if (!ret) {
                ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0);
+               if (ret >= 0) {
+                       close(fd);
+                       return 0;
+               }
+       }
 
-       if (ret)
-               printf("failed to attach: %s\n", strerror(-ret));
+       printf("failed to attach: %s\n", strerror(ret));
 
        close(fd);
 
-       return ret ? 1 : 0;
+       return 1;
 }
 
 static const __maybe_unused char cmd_ubiattach_help[] =
-- 
1.7.9.5

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to