• M
    cutils: Make strtosz & friends leave follow set to callers · eba90e4e
    Markus Armbruster 提交于
    strtosz() & friends require the size to be at the end of the string,
    or be followed by whitespace or ','.  I find this surprising, because
    the name suggests it works like strtol().
    
    The check simplifies callers that accept exactly that follow set
    slightly.  No such callers exist.
    
    The check is redundant for callers that accept a smaller follow set,
    and thus need to check themselves anyway.  Right now, this is the case
    for all but one caller.  All of them neglected to check, or checked
    incorrectly, but the previous few commits fixed them up.
    
    Finally, the check is problematic for callers that accept a larger
    follow set.  This is the case in monitor_parse_command().
    Fortunately, the problems there are relatively harmless.
    
    monitor_parse_command() uses strtosz() for argument type 'o'.  When
    the last argument is of type 'o', a trailing ',' is diagnosed
    differently than other trailing junk:
    
        (qemu) migrate_set_speed 1x
        invalid size
        (qemu) migrate_set_speed 1,
        migrate_set_speed: extraneous characters at the end of line
    
    A related inconsistency exists with non-last arguments.  No such
    command exists, but let's use memsave to explore the inconsistency.
    
    The monitor permits, but does not require whitespace between
    arguments.  For instance, "memsave (1-1)1024foo" is parsed as command
    memsave with three arguments 0, 1024 and "foo".  Yes, this is daft,
    but at least it's consistently daft.
    
    If I change memsave's second argument from 'i' to 'o', then "memsave
    (1-1)1foo" is rejected, because the size is followed by an 'f'.  But
    "memsave (1-1)1," is still accepted, and duly saves to file ",".
    
    We don't have any users of strtosz that profit from the check.  In the
    users we have, it appears to encourage sloppy error checking, or gets
    in the way.  Drop the bothersome check.
    Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
    eba90e4e
cutils.c 9.4 KB