[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f6fbc5cc-392d-4914-a08c-e70091ca3371@kernel.org>
Date: Wed, 10 Sep 2025 20:12:27 +0900
From: Vincent Mailhol <mailhol@...nel.org>
To: Marc Kleine-Budde <mkl@...gutronix.de>
Cc: Oliver Hartkopp <socketcan@...tkopp.net>,
Stéphane Grosjean <stephane.grosjean@...-networks.com>,
Robert Nawrath <mbro1689@...il.com>, Minh Le <minh.le.aj@...esas.com>,
Duy Nguyen <duy.nguyen.rh@...esas.com>, linux-can@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 04/20] can: netlink: refactor can_validate_bittiming()
On 10/09/2025 at 19:55, Marc Kleine-Budde wrote:
> On 10.09.2025 15:43:00, Vincent Mailhol wrote:
>> On 10/09/2025 at 15:13, Marc Kleine-Budde wrote:
>>> On 10.09.2025 15:03:29, Vincent Mailhol wrote:
>>>> Whenever can_validate_bittiming() is called, it is always preceded by
>>>> some boilerplate code which was copy pasted all over the place. Move
>>>> that repeated code directly inside can_validate_bittiming().
>>>>
>>>> Finally, the mempcy() is not needed. Just use the pointer returned by
>>>> nla_data() as-is.
>>>
>>> The memcpy()'ed struct is guaranteed to be properly aligned, is this
>>> also the case for the casted nla_data() pointer?
>>
>> The NLA attributes are aligned on 4 bytes, c.f. NLA_ALIGNTO:
>>
>> https://elixir.bootlin.com/linux/v6.16.5/source/include/uapi/linux/netlink.h#L248
>>
>> Which is sufficient for struct can_bittiming which also requires just 4 bytes of
>> alignment as proven by the fact the the code would still compile if I add this
>> static assert:
>>
>> static_assert(_Alignof(typeof(*bt)) <= NLA_ALIGNTO);
>>
>> But I have to admit that you caught me off guard. I did not think of that. Maybe
>> I should add above static assertions to the code to document that what we are
>> doing is correct?
>
> Yes, make it so!
I applied the changes locally.
Let me know when you are done with the review of the other patches. I will wait
for your other comments (if any) before sending v3.
Yours sincerely,
Vincent Mailhol
Powered by blists - more mailing lists