AW: AW: [PATCH] ubimkvol: add -m option to create volume of maximum size

dietmar.schindler at manroland-web.com dietmar.schindler at manroland-web.com
Thu Jun 20 06:30:38 UTC 2013


> Von: Bernhard Reutner-Fischer [mailto:rep.dot.nop at gmail.com]
> Gesendet: Mittwoch, 19. Juni 2013 23:31
>
> On 5 June 2013 08:19:41 <dietmar.schindler at manroland-web.com> wrote:
> > ... Besides that, the
> > version with sscanf is far more readable, especially with multiple
> > conversions embedded in the format.
>
> xstrtou() is equally well readable.

Do you really think so?

sscanf:
-                       // Make assumption that device not is in normal format.
-                       // Removes need for scanning sysfs tree as full libubi does
-                       if (sscanf(ubi_ctrl, "/dev/ubi%u_%u", &ubinum, &volnum) != 2)
                                bb_error_msg_and_die("%s volume node not in correct format", "UBI");

xstrtou:
+                       // Make assumption that device node is in normal format
+                       // (/dev/ubi%d_%d), removes need for scanning sysfs
+                       // tree as full libubi does
+                       if (strncmp(ubi_ctrl, "/dev/ubi", 8) != 0 ||
+                           (input_data = strchr(ubi_ctrl+8, '_')) == NULL)
                                bb_error_msg_and_die("%s volume node not in correct format", "UBI");
+                       // temporarily tokenize for parsing
+                       *input_data = '\0';
+                       ubinum = xstrtou(ubi_ctrl+8, 10);
+                       volnum = xstrtou(input_data+1, 10);
+                       // restore original string
+                       *input_data = '_';

--
Regards
________________________________________
manroland web systems GmbH -- Managing Director: Eckhard Hoerner-Marass
Registered Office: Augsburg -- Trade Register: AG Augsburg -- HRB-No. 26816 -- VAT: DE281389840

Confidentiality note:
This eMail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use or dissemination of this communication is strictly prohibited. If you have received this eMail in error, then please delete this eMail.

! Please consider your environmental responsibility before printing this eMail
________________________________________


More information about the busybox mailing list