From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Clemens Ladisch <clemens@ladisch.de>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
"Christian A. Ehrhardt" <lk@c--e.de>,
"Christian A. Ehrhardt" <christian.ehrhardt@codasip.com>,
linux1394-devel@lists.sourceforge.net,
linux-sound@vger.kernel.org,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH v1 0/2] firewire: Simplify storing pointers in device id struct
Date: Mon, 27 Apr 2026 10:07:31 +0200 [thread overview]
Message-ID: <ae8SdLxuOlU4d5oP@monoceros> (raw)
In-Reply-To: <20260427063719.GA37068@sakamocchi.jp>
[-- Attachment #1: Type: text/plain, Size: 2306 bytes --]
Hello Takashi,
On Mon, Apr 27, 2026 at 03:37:19PM +0900, Takashi Sakamoto wrote:
> On Thu, Apr 23, 2026 at 06:53:12PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> > A considerable amount of drivers for the first category uses the
> > unsigned long variable to store a pointer. This involves casting both
> > for assignment and usage.
>
> The conversion between 'unsigned long' and 'void *' are not inherently
> invalid within ILP32/LP64 data models.
Agreed, it's not invalid. But casts are always a part in C code where
strange or even bad things can happen as the (weak) type-safety of C is
overridden. Arguably there is still casting involved as driver_data_ptr
is a void pointer, but this is near enough to the actually type of the
driver data to not require an explicit cast. In my eyes reducing the
number of casts is a maintenance improvement. That's a bit similar to
reducing the number of unsafe parts in Rust code. It reduces the amount
of code you have to keep an eye on when thinking about correctness of
the code and it makes drivers suspicious that use both .driver_data and
.driver_data_ptr (which is easy to grep for).
> As I see it, the main significant
> effect of these patches is to add a 'const' qualifier to pointer values
> (and improve type safety, presumably in your view).
For me the main benefit is that the explicit casts can go away. This is
what is implemented in the 2nd patch with changes like
- detect_formats = (snd_dice_detect_formats_t)entry->driver_data;
+ detect_formats = entry->driver_data_ptr;
but yes, that the const is kept this way is also a nice upside. I'm
currently working on a similar patch set for pci_device_id and this
indeed shows a few missing `const`s.
> If that is the case, why do the patch comments spend so much lines
> describing the size of unsigned long and pointer types, and CHERI
> extension? These points do not seem directly relevant to the practical
> benefits described above.
>
> It would be better to repost the patches with clearer and more focused
> comments so that subsystem maintainers are more likely to apply them
> without the background discussion about the CHERI extension.
I'll try that. Thanks for your feedback.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-04-27 8:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-19 6:42 [PATCH v1 0/2] firewire: Simplify storing pointers in device id struct Uwe Kleine-König (The Capable Hub)
2026-04-19 6:42 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
2026-04-19 6:42 ` [PATCH v1 2/2] ALSA: firewire: Make use of ieee1394's .driver_data_ptr Uwe Kleine-König (The Capable Hub)
2026-04-20 8:48 ` Andy Shevchenko
2026-04-20 9:08 ` [PATCH v1 0/2] firewire: Simplify storing pointers in device id struct Takashi Sakamoto
2026-04-20 17:39 ` Christian A. Ehrhardt
2026-04-21 12:53 ` Takashi Sakamoto
2026-04-21 14:07 ` Uwe Kleine-König (The Capable Hub)
2026-04-22 7:19 ` Andy Shevchenko
2026-04-22 8:30 ` Uwe Kleine-König (The Capable Hub)
2026-04-22 8:40 ` Uwe Kleine-König (The Capable Hub)
2026-04-22 9:40 ` Andy Shevchenko
2026-04-22 10:10 ` Uwe Kleine-König (The Capable Hub)
2026-04-21 16:20 ` Christian A. Ehrhardt
2026-04-23 14:19 ` Takashi Sakamoto
2026-04-23 16:53 ` Uwe Kleine-König (The Capable Hub)
2026-04-27 6:37 ` Takashi Sakamoto
2026-04-27 8:07 ` Uwe Kleine-König (The Capable Hub) [this message]
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=ae8SdLxuOlU4d5oP@monoceros \
--to=u.kleine-koenig@baylibre.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=christian.ehrhardt@codasip.com \
--cc=clemens@ladisch.de \
--cc=linux-sound@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=lk@c--e.de \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=wsa+renesas@sang-engineering.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox