qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/9] hw/usb/redirect.c: Stop using qemu_oom_check()


From: Richard Henderson
Subject: Re: [PATCH 1/9] hw/usb/redirect.c: Stop using qemu_oom_check()
Date: Sat, 26 Feb 2022 14:26:49 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 2/26/22 08:07, Peter Maydell wrote:
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>
---
I have left all of these errors as fatal, since that's what they
were previously. Possibly somebody with a better understanding
of the usbredir code might be able to make them theoretically
non-fatal, but we make malloc failures generally fatal anyway.
---
  hw/usb/redirect.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]