Skip to content
Snippets Groups Projects
  • Richard Henderson's avatar
    53645dc4
    util/selfmap: Discard mapping on error · 53645dc4
    Richard Henderson authored
    
    From clang-13:
    util/selfmap.c:26:21: error: variable 'errors' set but not used \
        [-Werror,-Wunused-but-set-variable]
    
    Quite right of course, but there's no reason not to check errors.
    
    First, incrementing errors is incorrect, because qemu_strtoul
    returns an errno not a count -- just or them together so that
    we have a non-zero value at the end.
    
    Second, if we have an error, do not add the struct to the list,
    but free it instead.
    
    Cc: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    53645dc4
    History
    util/selfmap: Discard mapping on error
    Richard Henderson authored
    
    From clang-13:
    util/selfmap.c:26:21: error: variable 'errors' set but not used \
        [-Werror,-Wunused-but-set-variable]
    
    Quite right of course, but there's no reason not to check errors.
    
    First, incrementing errors is incorrect, because qemu_strtoul
    returns an errno not a count -- just or them together so that
    we have a non-zero value at the end.
    
    Second, if we have an error, do not add the struct to the list,
    but free it instead.
    
    Cc: Alex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>