[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87fso8vb3w.fsf_-_@kernel.org>
Date: Thu, 24 Feb 2022 11:59:31 +0200
From: Kalle Valo <kvalo@...nel.org>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Francesco Magliocca <franciman12@...il.com>,
Jeff Johnson <quic_jjohnson@...cinc.com>,
ath10k@...ts.infradead.org, rmanohar@....qualcomm.com,
linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...uxfoundation.org>
Subject: Use of void pointer arithmetic?
(Changing subject, adding Linus and linux-kernel)
Dan Carpenter <dan.carpenter@...cle.com> writes:
> On Thu, Feb 24, 2022 at 09:34:31AM +0200, Kalle Valo wrote:
>> Francesco Magliocca <franciman12@...il.com> writes:
>>
>> > Hi, I picked (void*) to be conformant with the other examples in htt_rx.c
>> > For example at line 1431:
>> >> rxd = HTT_RX_BUF_TO_RX_DESC(hw,
>> >> (void *)msdu->data - hw->rx_desc_ops->rx_desc_size);
>> >
>> > But for me it is ok. Maybe we should fix all the occurrences of this kind.
>>
>> Yeah, it would be good to fix the void pointer arithmetic in a separate
>> patch. I have planning to enable -Wpointer-arith in my ath10k-check and
>> ath11k-check scripts, so patches are very welcome.
>
> Void * casts simplify a lot of code. Less noise. More readable.
> They're more accurate in a sense because it's not a u8 at all. The
> kernel can't compile with other compilers besides GCC and Clang so why
> care about that the C standard hasn't caught up?
>
> What does -Wpointer-arith buy us?
A good question. I have always just thought we should avoid void pointer
arithmetic due to the C standard, but now that you mention it void
pointers can indeed simplify the code. So I'm not so sure anymore.
Any opinions? Is there a kernel wide recommendation for this?
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Powered by blists - more mailing lists