From: René Scharfe Date: Fri, 07 Apr 2017 15:25:06 GMT Subject: Re: [PATCH v3 1/2] Fix nonnull errors reported by UBSAN with GCC 7. Message-ID: <425176fe-090e-6edf-b6ba-fa77e35b3dd1@web.de> In-Reply-To: <96beb4c6-0569-0c12-8151-462c20be6a2a@suse.cz> Am 07.04.2017 um 16:23 schrieb Martin Liška: > On 04/06/2017 10:49 PM, Johannes Sixt wrote: >> Am 06.04.2017 um 19:31 schrieb René Scharfe: >>> 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 >> > > Good. There's tested v4. Thank you! I'd *still* prefer MOVE_ARRAY, though. Patches to follow. René