[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] ubi_tools: enhance -s option to allow size multiplier to match mtd-utils
From: Mike Frysinger <vapier () gentoo ! org>
Date: 2013-05-31 23:34:09
Message-ID: 201305311934.11052.vapier () gentoo ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
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
["signature.asc" (application/pgp-signature)]
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic