Re: [PATCH 06/12] selftests/nolibc: avoid passing NULL to printf("%s")
From: Thomas Weißschuh
Date: Sat Aug 03 2024 - 14:29:29 EST
Aug 3, 2024 11:34:03 Willy Tarreau <w@xxxxxx>:
> On Sun, Jul 28, 2024 at 12:10:00PM +0200, Thomas Weißschuh wrote:
>> Clang on higher optimization levels detects that NULL is passed to
>> printf("%s") and warns about it.
>> Avoid the warning.
>
> I don't see why this would be a problem, we do explicitly check for
> NULL in our printf implementation and print "(null)". Or maybe it is
> upset due to the attribute(printf) ? I don't know what the standard
> says regarding %s and NULL, though. If it says that NULL is forbidden
> then I can understand the warning and your fix is indeed correct. In
> any case it's not worth fighting with a compiler for nolibc-test, but
> it's probably worth mentioning in the commit message that it warns
> despite the check being already done.
It's undefined as per POSIX.
I'll update the commit message.