Re: [PATCH v1 2/2] tools/nolibc/stdio: Add format attribute to enable printf warnings

From: Willy Tarreau
Date: Fri May 20 2022 - 00:22:06 EST


On Fri, May 20, 2022 at 12:21:16AM +0700, Ammar Faizi wrote:
> From: Alviro Iskandar Setiawan <alviro.iskandar@xxxxxxxxxxx>
>
> When we use printf and fprintf functions from the nolibc, we don't
> get any warning from the compiler if we have the wrong arguments.
> For example, the following calls will compile silently:
> ```
> printf("%s %s\n", "aaa");
> fprintf(stdout, "%s %s\n", "xxx", 1);
> ```
> (Note the wrong arguments).
>
> Those calls are undefined behavior. The compiler can help us warn
> about the above mistakes by adding a `printf` format attribute to
> those functions declaration.

I'm shocked I forgot it, I use it all the time, I'm even seeing this
as a bug fix for the series I sent. Thanks for fixing this mistake of
mine!

Acked-by: Willy Tarreau <w@xxxxxx>

Willy