Re: git: 6995e6b3237e - main - Fix printf format conflict

From: Rick Macklem <rick.macklem_at_gmail.com>
Date: Sun, 30 Apr 2023 03:08:35 UTC
On Sat, Apr 29, 2023 at 7:55 PM Jessica Clarke <jrtc27@freebsd.org> wrote:
>
> On 30 Apr 2023, at 03:54, Rick Macklem <rick.macklem@gmail.com> wrote:
> >
> > On Sat, Apr 29, 2023 at 7:17 PM Jessica Clarke <jrtc27@freebsd.org> wrote:
> >>
> >> CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to IThelp@uoguelph.ca.
> >>
> >>
> >> On 30 Apr 2023, at 01:55, Kirk McKusick <mckusick@FreeBSD.org> wrote:
> >>>
> >>> The branch main has been updated by mckusick:
> >>>
> >>> URL: https://cgit.FreeBSD.org/src/commit/?id=6995e6b3237e9be9ae6f68af13edd3db4b668ab8
> >>>
> >>> commit 6995e6b3237e9be9ae6f68af13edd3db4b668ab8
> >>> Author:     Kirk McKusick <mckusick@FreeBSD.org>
> >>> AuthorDate: 2023-04-30 00:55:15 +0000
> >>> Commit:     Kirk McKusick <mckusick@FreeBSD.org>
> >>> CommitDate: 2023-04-30 00:55:15 +0000
> >>>
> >>>   Fix printf format conflict
> >>>
> >>>   MFC after:   1 week
> >>> ---
> >>> sbin/dumpfs/dumpfs.c | 2 +-
> >>> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
> >>> index 01b475a03fea..743734660e57 100644
> >>> --- a/sbin/dumpfs/dumpfs.c
> >>> +++ b/sbin/dumpfs/dumpfs.c
> >>> @@ -245,7 +245,7 @@ dumpfs(const char *name, int dosb)
> >>>      default:
> >>>              goto err;
> >>>      }
> >>> -     printf("old_cpg\t%d\tsize_cg\t%jd\tCGSIZE\t%jd\n",
> >>> +     printf("old_cpg\t%d\tsize_cg\t%d\tCGSIZE\t%d\n",
> >>>          afs.fs_old_cpg, sizeof(struct cg), CGSIZE(&afs));
> >>
> >> size_t is not an int on 64-bit architectures; you want %zu.
> > Since size_t is 32 bits on some arches, don't you need to use %ju
> > and (uintmax_t)sizeof(struct cg)?
>
> No. %zu is size_t by definition. That’s the point of its existence.
Yep, I see that in "man 3 printf". As they say, you learn something every day.

rick

>
> Jess
>
> > rick
> >
> >>
> >> Jess
> >>
> >>>      printf("sblkno\t%d\tcblkno\t%d\tiblkno\t%d\tdblkno\t%d\n",
> >>>          afs.fs_sblkno, afs.fs_cblkno, afs.fs_iblkno, afs.fs_dblkno);
>