Skip to content
  • Markus Armbruster's avatar
    939caddc
    qga-win: Fix guest-get-devices error API violations · 939caddc
    Markus Armbruster authored
    
    
    The Error ** argument must be NULL, &error_abort, &error_fatal, or a
    pointer to a variable containing NULL.  Passing an argument of the
    latter kind twice without clearing it in between is wrong: if the
    first call sets an error, it no longer points to NULL for the second
    call.
    
    qmp_guest_get_devices() is wrong that way: it calls error_setg() in a
    loop.
    
    If no iteration fails, the function returns a value and sets no error.
    Okay.
    
    If exactly one iteration fails, the function returns a value and sets
    an error.  Wrong.
    
    If multiple iterations fail, the function trips error_setv()'s
    assertion.
    
    Fix it to return immediately on error.
    
    Perhaps the failure to convert the driver version to UTF-8 should not
    be an error.  We could simply not report the botched version string
    instead.
    
    Drop a superfluous continue while there.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Signed-off-by: default avatarMichael Roth <michael.roth@amd.com>
    939caddc
    qga-win: Fix guest-get-devices error API violations
    Markus Armbruster authored
    
    
    The Error ** argument must be NULL, &error_abort, &error_fatal, or a
    pointer to a variable containing NULL.  Passing an argument of the
    latter kind twice without clearing it in between is wrong: if the
    first call sets an error, it no longer points to NULL for the second
    call.
    
    qmp_guest_get_devices() is wrong that way: it calls error_setg() in a
    loop.
    
    If no iteration fails, the function returns a value and sets no error.
    Okay.
    
    If exactly one iteration fails, the function returns a value and sets
    an error.  Wrong.
    
    If multiple iterations fail, the function trips error_setv()'s
    assertion.
    
    Fix it to return immediately on error.
    
    Perhaps the failure to convert the driver version to UTF-8 should not
    be an error.  We could simply not report the botched version string
    instead.
    
    Drop a superfluous continue while there.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Signed-off-by: default avatarMichael Roth <michael.roth@amd.com>
Loading