OSDN Git Service

hw/usb/redirect.c: Stop using qemu_oom_check()
authorPeter Maydell <peter.maydell@linaro.org>
Sat, 26 Feb 2022 18:07:15 +0000 (18:07 +0000)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 4 Mar 2022 10:20:16 +0000 (11:20 +0100)
commitfedc1c19155f78f4f5be58092cd54cef0ea874ff
treef6f3e4bda90c44106b1ee1ab937b01d17ce41fd7
parent7b672528070ffe9c401d760c0edb75849d8e484e
hw/usb/redirect.c: Stop using qemu_oom_check()

qemu_oom_check() is a function which essentially says "if you pass me
a NULL pointer then print a message then abort()".  On POSIX systems
the message includes strerror(errno); on Windows it includes the
GetLastError() error value printed as an integer.

Other than in the implementation of qemu_memalign(), we use this
function only in hw/usb/redirect.c, for three checks:

 * on a call to usbredirparser_create()
 * on a call to usberedirparser_serialize()
 * on a call to malloc()

The usbredir library API functions make no guarantees that they will
set errno on errors, let alone that they might set the
Windows-specific GetLastError string.  malloc() is documented as
setting errno, not GetLastError -- and in any case the only thing it
might set errno to is ENOMEM.  So qemu_oom_check() isn't the right
thing for any of these.  Replace them with straightforward
error-checking code.  This will allow us to get rid of
qemu_oom_check().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220226180723.1706285-2-peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/redirect.c