[pve-devel] [PATCH qemu] Add format attributes to function candidates

Fiona Ebner f.ebner at proxmox.com
Mon Aug 7 14:05:28 CEST 2023


Am 07.08.23 um 11:18 schrieb Filip Schauer:
> Add format attributes to functions that take printf-like arguments. This
> provides additional compile-time checking that the correct parameters
> are passed to the functions.
> 
> This fixes compiler warnings generated by the -Wsuggest-attribute=format
> flag.
>

Which will actually be treated as an error after rebasing to QEMU 8.1,
so I already have a change for this lined-up. If you want, you can send
a v2 with my suggestion below, otherwise I'll just do the change when
rebasing to 8.1.

> @@ -177,6 +177,16 @@ index 0000000000..ac1fac6378
>  +    do { } while (0)
>  +#endif
>  +
> ++#ifdef __GNUC__
> ++#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
> ++#define PRINTF(i, j)    __attribute__((format (gnu_printf, i, j)))
> ++#else
> ++#define PRINTF(i, j)    __attribute__((format (printf, i, j)))
> ++#endif
> ++#else
> ++#define PRINTF(i, j)
> ++#endif
> ++

Note that QEMU already defines and uses a macro G_GNUC_PRINTF for this,
so I'd really like to use that in our patches too, no need to cook up
our own :)





More information about the pve-devel mailing list