> Gesendet: Sonntag, 2. Juni 2013 21:50 > An: [email protected] > Betreff: [PATCH] Convert sscanf to preferred xstrtou conversion. > > Signed-off-by: Paul B. Henson <[email protected]> > --- > miscutils/ubi_tools.c | 20 ++++++++++++++------ > 1 files changed, 14 insertions(+), 6 deletions(-) > > diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c > index dd99a44..f6dfcae 100644 > --- a/miscutils/ubi_tools.c > +++ b/miscutils/ubi_tools.c > @@ -234,16 +234,24 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv) > ssize_t len; > char *input_data; > > - // 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) > + // 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 = '_'; > ...
Please excuse my interfering... Did you verify that the version with xstrtou is indeed shorter (which was the motivation for the change, if I understood right)? I doubt it. Besides that, the version with sscanf is far more readable. -- Best regards, Dietmar Schindler ________________________________________ 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 ________________________________________ _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
