Re: git: 6677621bad00 - main - cdefs.h: Fallback to printf0 for __printf0like

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sat, 06 Jul 2024 21:56:15 UTC
On 7/6/24 15:44, Warner Losh wrote:
> The branch main has been updated by imp:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=6677621bad00191dfec1b0a20ae1618b92745d9b
> 
> commit 6677621bad00191dfec1b0a20ae1618b92745d9b
> Author:     Warner Losh <imp@FreeBSD.org>
> AuthorDate: 2024-07-06 19:42:37 +0000
> Commit:     Warner Losh <imp@FreeBSD.org>
> CommitDate: 2024-07-06 19:45:03 +0000
> 
>      cdefs.h: Fallback to printf0 for __printf0like
>      
>      For some reason, my tests were fine with this like it was, but CI for
>      gcc12 and gcc13 is complaining. Revert to the old form until that can be
>      worked out why the mismatch.
>      
>      Fixes: 0b82dac337e7
>      Sponsored by:           Netflix
> ---
>   sys/sys/cdefs.h | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
> index 6b861b1903f6..a56839d57c7a 100644
> --- a/sys/sys/cdefs.h
> +++ b/sys/sys/cdefs.h
> @@ -356,9 +356,12 @@
>    * Clang has always had printf and printf0 as aliases. gcc 11.0 now follows
>    * clang. So now this is an alias for __printflike, or nothing. In the future
>    * _Nullable or _Nonnull will replace this.
> + * XXX Except that doesn't work, so for now revert to printf0 for clang and
> + * the FreeBSD gcc until I can work this out.
>    */
> -#if defined(__clang__) || __GNUC_PREREQ__(11, 0)
> -#define	__printf0like(fmtarg, firstvararg) __printflike(fmtarg, firstvararg)
> +#if defined(__clang__) || (defined(__GNUC__) && defined (__FreeBSD_cc_version))
> +#define	__printf0like(fmtarg, firstvararg) \
> +	    __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
>   #else
>   #define	__printf0like(fmtarg, firstvararg)
>   #endif

It's because my patch for devel/freebsd-gcc{12,13} is kind of wrong.  I had a mismerge
when updating the printf0 patch from gcc9 to gcc12 that ended up re-adding the
warn on NULL.  I need to update the ports to remove that part of the patch.  I will
probably leave printf0 working for now in the ports just as an alias for regular
printf to give us some transition time.

-- 
John Baldwin