Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2011 23:31:35 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Cc:        Ben Laurie <benl@FreeBSD.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r222084 - head/contrib/gperf/src
Message-ID:  <4DD43AB7.7060705@FreeBSD.org>
In-Reply-To: <20110518211651.GE2273@garage.freebsd.pl>
References:  <201105182106.p4IL6KkE008657@svn.freebsd.org> <20110518211651.GE2273@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
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:
>>    Fix clang warnings.
>>
>>    Approved by:	philip (mentor)
> [...]
>> -            fprintf (stderr, " by changing asso_value['%c'] (char #%d) to %d\n",
>> +            fprintf (stderr, " by changing asso_value['%c'] (char #%zd) to %d\n",
>>                        *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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DD43AB7.7060705>