Re: [PATCH v3 1/2] Fix nonnull errors reported by UBSAN with GCC 7.
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Apr 6, 2017, 20:49 UTC
- Message-ID
- <357d045a-b1c5-1a73-2256-839efb543fe3@kdbg.org>
- In-Reply-To
- <e392e05c-2815-8cfa-eed0-bd990f8ce954@web.de>
Am 06.04.2017 um 19:31 schrieb René Scharfe:
Show 13 quoted lines
> Am 06.04.2017 um 18:33 schrieb Johannes Sixt:
>> Am 06.04.2017 um 17:42 schrieb Martin Liška:
>>> +static inline void *sane_memmove(void *dest, const void *src, size_t n)
>>> +{
>>> + if (n > 0)
>>> + return memmove(dest, src, n);
>>> + else
>>> + return dest;
>>> +}
>>
>> Huh? memmove with n == 0 is well-defined. This wrapper is pointless.
>
> memmove(3) with NULL pointers is undefined.Then don't hide this helper behind a macro with a suspiciously similar name. Using the name sane_mmemove at the call site is preferable. memmove_or_null or something similar perhaps even more so.
-- Hannes