On 05/28/2013 09:27 AM, Kevin Wolf wrote: > No reason to implement the same thing multiple times. A nice side effect > is that fractional numbers like 0.5M can be used in qemu-io now. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > cmd.c | 37 ------------------------------------- > cmd.h | 1 - > qemu-io.c | 6 ++++++ > 3 files changed, 6 insertions(+), 38 deletions(-)
> - > - i = strtoll(s, &sp, 0); > - if (i == 0 && sp == s) > - return -1LL; > - if (*sp == '\0') > - return i; Another nice side effect: you are also getting rid of poor handling that fails to check for errors after strtoll() (such as clamping at INT64_MAX on EOVERFLOW). On the other hand, strtosz_suffix uses strtod() which may inadvertently cause rounding of low-order bits of large input numbers (that is, parsing with only 53 significant bits instead of 64 may cause us to round a value that was previously exact); but I'd rather deal with consistent behavior even if it rounds some values, than question which of multiple slightly different implementations will be parsing my values (we can also argue that perhaps strtosz_suffix could be improved to guarantee 64 bits of precision if there is no '.' in the value being parsed, while still providing the flexibility of 0.5G parsing when precision isn't important). Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature