[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for 6.2] nbd/server: Silence clang sanitizer warning
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH for 6.2] nbd/server: Silence clang sanitizer warning |
Date: |
Mon, 15 Nov 2021 23:51:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
On 11/15/21 23:39, Eric Blake wrote:
> clang's sanitizer is picky: memset(NULL, x, 0) is technically
> undefined behavior, even though no sane implementation of memset()
> deferences the NULL. Caught by the nbd-qemu-allocation iotest.
>
> The alternative to checking before each memset is to instead force an
> allocation of 1 element instead of g_new0(type, 0)'s behavior of
> returning NULL for a 0-length array.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Fixes: 3b1f244c59 (nbd: Allow export of multiple bitmaps for one device)
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> nbd/server.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>