On Tuesday 28 May 2013 21:17:42 Paul B. Henson wrote:
> +static int get_bytes(const char *str)
> +{
> +     int found;
> +     int size = 0;
> +     char multiplier[4];
> +
> +     found = sscanf(str, "%d%3s", &size, multiplier);
> +
> +     if (found == 2) {
> +             if (!strcmp(multiplier, "KiB")) {
> +                     size *= 1024;
> +             } else
> +             if (!strcmp(multiplier, "MiB")) {
> +                     size *= 1024*1024;
> +             } else
> +             if (!strcmp(multiplier, "GiB")) {
> +                     size *= 1024*1024*1024;

the style is wrong, but ignoring that, this seems like it'd be prime for 
adding to common libbb code if there isn't a func in there already

> +             if (opts & OPTION_s) {
> +                     size_bytes = get_bytes(size_str);
> +             } else {
>                       bb_error_msg_and_die("%s size not specified", "UBI");
> +             }

no need for those braces.  we generally omit them when there's only one 
statement.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to