Skip to content
  • Eric Blake's avatar
    b87ac966
    cutils: Use parse_uint in qemu_strtosz for negative rejection · b87ac966
    Eric Blake authored
    
    
    Rather than open-coding two different ways to check for an unwanted
    negative sign, reuse the same code in both functions.  That way, if we
    decide down the road to accept "-0" instead of rejecting it, we have
    fewer places to change.  Also, it means we now get ERANGE instead of
    EINVAL for negative values in qemu_strtosz, which is reasonable for
    what it represents.  This in turn changes the expected output of a
    couple of iotests.
    
    The change is not quite complete: negative fractional scaled values
    can trip us up.  This will be fixed in a later patch addressing other
    issues with fractional scaled values.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarHanna Czenczek <hreitz@redhat.com>
    Message-Id: <20230522190441.64278-18-eblake@redhat.com>
    b87ac966
    cutils: Use parse_uint in qemu_strtosz for negative rejection
    Eric Blake authored
    
    
    Rather than open-coding two different ways to check for an unwanted
    negative sign, reuse the same code in both functions.  That way, if we
    decide down the road to accept "-0" instead of rejecting it, we have
    fewer places to change.  Also, it means we now get ERANGE instead of
    EINVAL for negative values in qemu_strtosz, which is reasonable for
    what it represents.  This in turn changes the expected output of a
    couple of iotests.
    
    The change is not quite complete: negative fractional scaled values
    can trip us up.  This will be fixed in a later patch addressing other
    issues with fractional scaled values.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarHanna Czenczek <hreitz@redhat.com>
    Message-Id: <20230522190441.64278-18-eblake@redhat.com>
Loading