Date: Wed, 18 May 2011 14:38:52 -0700 From: mdf@FreeBSD.org To: Dimitry Andric <dim@freebsd.org> Cc: Ben Laurie <benl@freebsd.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek <pjd@freebsd.org> Subject: Re: svn commit: r222084 - head/contrib/gperf/src Message-ID: <BANLkTim=Vymb44bNyKbkW-oj=4kbsr0gxg@mail.gmail.com> In-Reply-To: <4DD43AB7.7060705@FreeBSD.org> References: <201105182106.p4IL6KkE008657@svn.freebsd.org> <20110518211651.GE2273@garage.freebsd.pl> <4DD43AB7.7060705@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, May 18, 2011 at 2:31 PM, Dimitry Andric <dim@freebsd.org> wrote: > On 2011-05-18 23:16, Pawel Jakub Dawidek wrote: >> >> On Wed, May 18, 2011 at 09:06:20PM +0000, Ben Laurie wrote: >>> >>> Author: benl >>> Date: Wed May 18 21:06:20 2011 >>> New Revision: 222084 >>> URL: http://svn.freebsd.org/changeset/base/222084 >>> >>> Log: >>> =A0 Fix clang warnings. >>> >>> =A0 Approved by: philip (mentor) >> >> [...] >>> >>> - =A0 =A0 =A0 =A0 =A0 =A0fprintf (stderr, " by changing asso_value['%c'= ] (char #%d) >>> to %d\n", >>> + =A0 =A0 =A0 =A0 =A0 =A0fprintf (stderr, " by changing asso_value['%c'= ] (char #%zd) >>> to %d\n", >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *p, p - union_set + 1, asso= _values[(unsigned >>> char)(*p)]); >> >> Hmm, both 'p' and 'union_set' are 'char *' and %zd is for ssize_t. It is >> a bit strange that it fixes the warning. > > If you subtract two pointers, such as in this case, you get a ptrdiff_t. > > Strictly, this doesn't have to be exactly the same type as ssize_t, but > in practice it will almost always be. > > You can also cast the result to intmax_t, and use %jd, then it will > always be correct, but possibly have some small overhead. Or you can use %td which is the C99 conversion specifier for ptrdiff_t. Thanks, matthew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTim=Vymb44bNyKbkW-oj=4kbsr0gxg>