Re: [PATCH v3] can: length: can_fd_len2dlc(): make length calculation readable again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/18/21 9:58 PM, Oliver Hartkopp wrote:
>>> diff --git a/drivers/net/can/dev/length.c b/drivers/net/can/dev/length.c
>>> index d35c4e82314d..d085cb26d00d 100644
>>> --- a/drivers/net/can/dev/length.c
>>> +++ b/drivers/net/can/dev/length.c
>>> @@ -25,16 +25,21 @@ static const u8 len2dlc[] = {
>>>   	11, 11, 11, 11,			/* 17 - 20 */
>>>   	12, 12, 12, 12,			/* 21 - 24 */
>>>   	13, 13, 13, 13, 13, 13, 13, 13,	/* 25 - 32 */
>>>   	14, 14, 14, 14, 14, 14, 14, 14,	/* 33 - 40 */
>>>   	14, 14, 14, 14, 14, 14, 14, 14,	/* 41 - 48 */
>>> +	15, 15, 15, 15, 15, 15, 15, 15,	/* 49 - 56 */
>>> +	15, 15, 15, 15, 15, 15, 15, 15	/* 57 - 64 */
>>>   };
>>>   
>>>   /* map the sanitized data length to an appropriate data length code */
>>>   u8 can_fd_len2dlc(u8 len)
>>>   {
>>> -	if (len >= ARRAY_SIZE(len2dlc))
>>> +	/* check for length mapping table size at build time */
>>> +	BUILD_BUG_ON(ARRAY_SIZE(len2dlc) < CANFD_MAX_DLEN + 1);
>>                                          ^^^
>> What about "!="?
> 
> "<" makes sure that the table is long enough
> "!=" makes sure it has a specific length

From my point of view we want it to have a specific length...

> So "<" looks easier to understand to me.
> 
> ¯\_(ツ)_/¯

...so changed to != why applying to linux-can-next/testing

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux