[PATCH] ubi_tools: enhance -s option to allow size multiplier to match mtd-utils

Paul B. Henson henson at acm.org
Sat Jun 1 02:28:03 UTC 2013


On 5/31/2013 4:34 PM, Mike Frysinger wrote:

>> +static int get_bytes(const char *str)
[...]
> 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

I don't see one. Is there an existing libbb source file you think would 
be suitable to add this function to, or would it be better to add a new 
file?

This particular internal to ubi_tools implementation was specifically 
tailored to exactly match the mtd-utils implementation, presumably if 
it's going to be made into a general utility function it should be a bit 
more flexible.

As is, it returns an int and expects a string that exactly matches 
\d+(.{3})?, where the three character suffix is one of case sensitive 
"KiB", "MiB", or "GiB". As a more general utility function, should it 
still return int or another type? Should it be more flexible and accept 
mixed case suffixes, as well as accept the commonly used KB, MB, and GB 
suffixes?

If the ubi_tools -s option uses a more general libbb get_bytes function, 
should it make some effort on its own to restrict the input values to 
those that the full mtd-utils tool would accept, or allow options to the 
busybox applet versions that would cause errors in the full versions?

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

I'll try to remember that, it's hard to keep track of different style 
standards as you jump between projects :).


More information about the busybox mailing list