On 13.02.2020 14:13, Joerg Sonnenberger wrote:
> On Thu, Feb 13, 2020 at 02:05:12PM +0100, Kamil Rytarowski wrote:
>> On 13.02.2020 00:58, Joerg Sonnenberger wrote:
>>> On Mon, Feb 10, 2020 at 04:45:35PM +0000, Roy Marples wrote:
>>>> On 09/02/2020 19:21, Joerg Sonnenberger wrote:
>>>>> On Sat, Feb 08, 2020 at 12:17:16PM +0000, Santhosh Raju wrote:
>>>>>> Module Name: src
>>>>>> Committed By: fox
>>>>>> Date: Sat Feb 8 12:17:16 UTC 2020
>>>>>>
>>>>>> Modified Files:
>>>>>> src/external/bsd/dhcpcd/dist/src: dhcp.c
>>>>>>
>>>>>> Log Message:
>>>>>> external/bsd/dhcpcd: Fix a -Wconversion warning.
>>>>>>
>>>>>> Type cast uint16_t to size_t to prevent implicit type conversion.
>>>>>
>>>>> Seriously? That should not warn and no cast should be used either.
>>>>
>>>> What fix would you recommend then?
>>>
>>> Disable the warning in GCC and fill an upstream PR against it. A
>>> conversion from uint16_t to size_t is value preserving by definition of
>>> the ISO C platform limits. It should never create a warning.
>>>
>>> Joerg
>>>
>>
>> If we disable warnings in our core software in non-trivial source file
>> for over 4000 lines we will mute more serious issues in a pretty
>> sensitive file. We fixed this warning in upstream dhcpcd.
>
> The fix is IMO significantly worse as it actually creates technical
> debt. Frankly, I would go so far and say that this should be reverted.
> This warning seems to be pretty fundamentally broken by design if the
> analysis so far is correct.
>
> Joerg
>
Feel free to fix GCC.
dhcpcd already uses this explicit cast style, e.g. here:
static void *
get_udp_data(void *packet, size_t *len)
{
const struct ip *ip = packet;
size_t ip_hl = (size_t)ip->ip_hl * 4;
char *p = packet;
p += ip_hl + sizeof(struct udphdr);
*len = (size_t)ntohs(ip->ip_len) - sizeof(struct udphdr) - ip_hl;
return p;
}
Attachment:
signature.asc
Description: OpenPGP digital signature