From: Kalle Valo <kvalo@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Francesco Magliocca <franciman12@gmail.com>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
ath10k@lists.infradead.org, rmanohar@qti.qualcomm.com,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linuxfoundation.org>
Subject: Use of void pointer arithmetic?
Date: Thu, 24 Feb 2022 11:59:31 +0200 [thread overview]
Message-ID: <87fso8vb3w.fsf_-_@kernel.org> (raw)
In-Reply-To: <20220224075346.GL3943@kadam> (Dan Carpenter's message of "Thu, 24 Feb 2022 10:53:46 +0300")
(Changing subject, adding Linus and linux-kernel)
Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Thu, Feb 24, 2022 at 09:34:31AM +0200, Kalle Valo wrote:
>> Francesco Magliocca <franciman12@gmail.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
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k
WARNING: multiple messages have this Message-ID (diff)
From: Kalle Valo <kvalo@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Francesco Magliocca <franciman12@gmail.com>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
ath10k@lists.infradead.org, rmanohar@qti.qualcomm.com,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linuxfoundation.org>
Subject: Use of void pointer arithmetic?
Date: Thu, 24 Feb 2022 11:59:31 +0200 [thread overview]
Message-ID: <87fso8vb3w.fsf_-_@kernel.org> (raw)
In-Reply-To: <20220224075346.GL3943@kadam> (Dan Carpenter's message of "Thu, 24 Feb 2022 10:53:46 +0300")
(Changing subject, adding Linus and linux-kernel)
Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Thu, Feb 24, 2022 at 09:34:31AM +0200, Kalle Valo wrote:
>> Francesco Magliocca <franciman12@gmail.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
next prev parent reply other threads:[~2022-02-24 9:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 12:26 [PATCH v2] ath10k: fix pointer arithmetic error in trace call Francesco Magliocca
2022-02-21 12:26 ` Francesco Magliocca
2022-02-22 20:52 ` Jeff Johnson
2022-02-22 20:52 ` Jeff Johnson
2022-02-23 11:48 ` Francesco Magliocca
2022-02-23 11:48 ` Francesco Magliocca
2022-02-24 7:34 ` Kalle Valo
2022-02-24 7:34 ` Kalle Valo
2022-02-24 7:53 ` Dan Carpenter
2022-02-24 7:53 ` Dan Carpenter
2022-02-24 9:59 ` Kalle Valo [this message]
2022-02-24 9:59 ` Use of void pointer arithmetic? Kalle Valo
2022-02-24 10:31 ` Johannes Berg
2022-02-24 10:31 ` Johannes Berg
2022-02-24 17:45 ` Linus Torvalds
2022-02-24 17:45 ` Linus Torvalds
2022-02-24 9:05 ` [PATCH v2] ath10k: fix pointer arithmetic error in trace call Kalle Valo
2022-02-24 9:05 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fso8vb3w.fsf_-_@kernel.org \
--to=kvalo@kernel.org \
--cc=ath10k@lists.infradead.org \
--cc=dan.carpenter@oracle.com \
--cc=franciman12@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_jjohnson@quicinc.com \
--cc=rmanohar@qti.qualcomm.com \
--cc=torvalds@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.