curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] curl: Fix compile warning on Fedora-14.

From: Ben Greear <greearb_at_candelatech.com>
Date: Fri, 8 Sep 2017 15:37:00 -0700

On 09/08/2017 03:23 PM, Daniel Stenberg wrote:
> On Thu, 7 Sep 2017, greearb_at_candelatech.com wrote:
>
>> mime.c:301:5: error: conversion to 'char' from 'int' may alter its value
>
> ...
>
>> - dst[i++] = c? c: '0';
>> + if(c)
>> + dst[i++] = c;
>> + else
>> + dst[i++] = '0';
>
> Thanks Ben,
>
> I personally am generally very keen on fixing compiler warnings everywhere as I truly believe that helps us detect the *real* problems better. But in this case
> I'm relucant.
>
> First, this doesn't cause any warnings on the CI build compilers, including the gcc builds we do (with slightly newer versions than 4.5.1) so this would only
> fix warnings caused by an ancient gcc version with a probably buggy parser, but then also because I think the "fixed" version of the code is more complicated.
>
> But I'll certainly listen if someone else thinks differently...
>

I like to build with -Werror, and so this warning 'breaks' my build.

That really is the sole reason I'd even post this patch, as the original code
is correct as far as I can tell.

That said, the ? operator always makes me think a bit harder, so I rarely use them
anyway when I can easily not use them.

So, either way is fine with me.

Thanks,
Ben

-- 
Ben Greear <greearb_at_candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-09-09