Removed sign comparison warning.

Marko Nikolić marko.nikolic at dmsgroup.rs
Thu Jun 3 12:47:14 CDT 2010


Hi Michael,

Yes, you are right, casting is not the best solution. The idea was to have a
controlled type conversion, thus avoiding implicit type conversion in 
readlink output parameter. Implicit conversion could lead to another 
warnings (with -Wconversion or -Wsign-conversion enabled).

However, the above conversion warning options anyway produce lot of warning 
(possibly hard to remove, imho), so I'll change the patch to what you have 
suggested.

Thanks,

Marko

Michael Stefaniuc wrote:

> Hello Marko,
> 
> thank you for your patch and welcome to Wine development.
> While in general patches to make Wine use proper types are accepted
> there is a slight problem with this patch.
> 
> On 06/01/2010 11:42 PM, grkoma at gmail.com wrote:
>> From: Marko Nikolic<grkoma at gmail.com>
>>
>> ---
>>   libs/wine/config.c |    4 ++--
>>   1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libs/wine/config.c b/libs/wine/config.c
>> index 6bb87b0..c04b704 100644
>> --- a/libs/wine/config.c
>> +++ b/libs/wine/config.c
>> @@ -146,10 +146,10 @@ static char *get_runtime_bindir( const char *argv0
>> )
>>   #ifdef linux
>>       for (size = 256; ; size *= 2)
>>       {
>> -        int ret;
>> +        ssize_t ret;
>>           if (!(bindir = malloc( size ))) break;
>>           if ((ret = readlink( "/proc/self/exe", bindir, size )) == -1)
>>           break;
>> -        if (ret != size)
>> +        if ((size_t)ret != size)   /* Safe to cast, ret is>  0 here */
> Having to use a cast to silence a -Wsign-compare is worse than keeping
> the warning; especially as that is an extra warning not included in the
> -Wall used by Wine. Though in this specific case by using the proper
> types the warning can be eliminated without resorting to casts.
> 
>>           {
>>               if (!(p = memrchr( bindir, '/', ret ))) break;
>>               if (p == bindir) p++;
> 
> bye
> michael





More information about the wine-devel mailing list