David Sharp schrieb:
> On Sun, Jun 14, 2009 at 12:06 AM, Ben Gamari wrote:
>> Fix compiler warning:
>>
>> imLcIm.c:364: warning: format ‘%03x’ expects type ‘unsigned int’, but
>> argument 6 has type ‘long unsigned int’
>> imLcIm.c:367: warning: format ‘%03x’ expects type ‘unsigned int’, but
>> argument 6 has type ‘long unsigned int’
>> ---
>> modules/im/ximcp/imLcIm.c |8
>> 1 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/modules/im/ximcp/imLcIm.c b/modules/im/ximcp/imLcIm.c
>> index 17121b5..e398112 100644
>> --- a/modules/im/ximcp/imLcIm.c
>> +++ b/modules/im/ximcp/imLcIm.c
>> @@ -363,11 +363,11 @@ Private int _XimCachedFileName (
>> *res = Xmalloc (len + 1 + 27 + 1); /* Max VERSION */
>>
>> if (len == 0 || dir [len-1] != '/')
>> - sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
>> - XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2);
>> + sprintf (*res, "%s/%c%d_%03lx_%08x_%08x", dir, _XimGetMyEndian(),
>> + XIM_CACHE_VERSION, sizeof(DefTree), hash, hash2);
>
> This will break systems where size_t is 32 bits. 'z' is the correct
> length modifier for size_t
>
>> else
>> - sprintf (*res, "%s%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
>> - XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2);
>> + sprintf (*res, "%s%c%d_%03lx_%08x_%08x", dir, _XimGetMyEndian(),
>> + XIM_CACHE_VERSION, sizeof(DefTree), hash, hash2);
>>
>> /* fprintf (stderr, "-> %s\n", *res); */
>> if ( (fd = _XOpenFile (*res, O_RDONLY)) == -1)
>> --
it also breaks for dir="very log string that will overflow the buffer"
there is an asprintf(3) equivalent that would be more save and you can remove
the Xmalloc.
re,
wh
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg