xen: introduce parse_size_and_unit_or_int
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 06.12.18 at 11:01, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Review unsigned long long parse_size_and_unit(const char *s,
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.12.18 at 09:06, <[email protected]> wrote:
(quoted diff) +0
-0@@ -477,7 +478,8 @@ unsigned long long parse_size_and_unit(const char *s,const char **ps)
Quoted 12 lines
Review unsigned long long parse_size_and_unit(const char *s, · line 483
Quoted 7 lines
(quoted diff) +2
-1s1++; break; default: - ret <<= 10; /* default to kB */ + if ( *s1 && *s1 != no_size ) + ret <<= 10; /* default to kB */ break;So did you figure anything wrong with simply special casing '%' here? '%' is a form of "unit", after all. Perhaps demanding "ps" to be non-NULL (to have some form of indication the caller will check the suffix char) might be reasonable.
Quoted 6 lines
Quoted 2 lines
I thought a more general approach would be better. I can use the simple '%' special case with the ps check in case you prefer that.
I'd indeed prefer that, first and foremost because that other function's name becomes too long for my taste, but give others a chance to voice differing opinions.
In case the function name is your main concern I could rename it to parse_size_or_int() or similar.
I'm fine either way, so lets wait for some days and act then according to the comments.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel