* [PATCH] firewire: fix function type cast warning
@ 2020-10-26 21:51 Arnd Bergmann
2020-10-27 0:13 ` Takashi Sakamoto
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-10-26 21:51 UTC (permalink / raw)
To: Stefan Richter
Cc: Arnd Bergmann, Gustavo A. R. Silva, linux1394-devel, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
gcc -Wextra complains about a suspicious cast:
rivers/firewire/core-cdev.c:985:8: warning: cast between incompatible function types from ‘void (*)(struct fw_iso_context *, dma_addr_t, void *)’ {aka ‘void (*)(struct fw_iso_context *, long long unsigned int, void *)’} to ‘void (*)(struct fw_iso_context *, u32, size_t, void *, void *)’ {aka ‘void (*)(struct fw_iso_context *, unsigned int, long unsigned int, void *, void *)’} [-Wcast-function-type]
The behavior is correct in the end, but this is more clearly
expressed using a transparent union.
Fixes: 872e330e3880 ("firewire: add isochronous multichannel reception")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/firewire/core-cdev.c | 6 +++---
drivers/firewire/core-iso.c | 2 +-
include/linux/firewire.h | 17 ++++++++---------
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index fb6c651214f3..8d85d52b02ca 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -970,7 +970,7 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
if (a->speed > SCODE_3200 || a->channel > 63)
return -EINVAL;
- cb = iso_callback;
+ cb.sc = iso_callback;
break;
case FW_ISO_CONTEXT_RECEIVE:
@@ -978,11 +978,11 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
a->channel > 63)
return -EINVAL;
- cb = iso_callback;
+ cb.sc = iso_callback;
break;
case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
- cb = (fw_iso_callback_t)iso_mc_callback;
+ cb.mc = iso_mc_callback;
break;
default:
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index af70e74f9a7e..ddada648775a 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -145,7 +145,7 @@ struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
ctx->channel = channel;
ctx->speed = speed;
ctx->header_size = header_size;
- ctx->callback.sc = callback;
+ ctx->callback = callback;
ctx->callback_data = callback_data;
return ctx;
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index aec8f30ab200..59b5e02a6d42 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -431,11 +431,13 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed);
struct fw_iso_context;
-typedef void (*fw_iso_callback_t)(struct fw_iso_context *context,
- u32 cycle, size_t header_length,
- void *header, void *data);
-typedef void (*fw_iso_mc_callback_t)(struct fw_iso_context *context,
- dma_addr_t completed, void *data);
+typedef union {
+ void (*sc)(struct fw_iso_context *context, u32 cycle,
+ size_t header_length, void *header, void *data);
+ void (*mc)(struct fw_iso_context *context, dma_addr_t completed,
+ void *data);
+} __attribute__ ((__transparent_union__)) fw_iso_callback_t;
+
struct fw_iso_context {
struct fw_card *card;
int type;
@@ -443,10 +445,7 @@ struct fw_iso_context {
int speed;
bool drop_overflow_headers;
size_t header_size;
- union {
- fw_iso_callback_t sc;
- fw_iso_mc_callback_t mc;
- } callback;
+ fw_iso_callback_t callback;
void *callback_data;
};
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] firewire: fix function type cast warning
2020-10-26 21:51 [PATCH] firewire: fix function type cast warning Arnd Bergmann
@ 2020-10-27 0:13 ` Takashi Sakamoto
2020-10-27 12:48 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sakamoto @ 2020-10-27 0:13 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Stefan Richter, linux1394-devel, Gustavo A. R. Silva,
Arnd Bergmann, linux-kernel, oscar.carter
Hi Arnd,
On Mon, Oct 26, 2020 at 10:51:27PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> gcc -Wextra complains about a suspicious cast:
>
> rivers/firewire/core-cdev.c:985:8: warning: cast between incompatible function types from ‘void (*)(struct fw_iso_context *, dma_addr_t, void *)’ {aka ‘void (*)(struct fw_iso_context *, long long unsigned int, void *)’} to ‘void (*)(struct fw_iso_context *, u32, size_t, void *, void *)’ {aka ‘void (*)(struct fw_iso_context *, unsigned int, long unsigned int, void *, void *)’} [-Wcast-function-type]
>
> The behavior is correct in the end, but this is more clearly
> expressed using a transparent union.
>
> Fixes: 872e330e3880 ("firewire: add isochronous multichannel reception")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/firewire/core-cdev.c | 6 +++---
> drivers/firewire/core-iso.c | 2 +-
> include/linux/firewire.h | 17 ++++++++---------
> 3 files changed, 12 insertions(+), 13 deletions(-)
Oscar Carter has posted a patch to fix it.
https://sourceforge.net/p/linux1394/mailman/message/37024966/
I don't know exactly but maintainers seems to overlook it...
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firewire: fix function type cast warning
2020-10-27 0:13 ` Takashi Sakamoto
@ 2020-10-27 12:48 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-10-27 12:48 UTC (permalink / raw)
To: Arnd Bergmann, Stefan Richter, linux1394-devel,
Gustavo A. R. Silva, Arnd Bergmann, linux-kernel, oscar.carter
On Tue, Oct 27, 2020 at 1:13 AM Takashi Sakamoto
<o-takashi@sakamocchi.jp> wrote:
> On Mon, Oct 26, 2020 at 10:51:27PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > gcc -Wextra complains about a suspicious cast:
> >
> > rivers/firewire/core-cdev.c:985:8: warning: cast between incompatible function types from ‘void (*)(struct fw_iso_context *, dma_addr_t, void *)’ {aka ‘void (*)(struct fw_iso_context *, long long unsigned int, void *)’} to ‘void (*)(struct fw_iso_context *, u32, size_t, void *, void *)’ {aka ‘void (*)(struct fw_iso_context *, unsigned int, long unsigned int, void *, void *)’} [-Wcast-function-type]
> >
> > The behavior is correct in the end, but this is more clearly
> > expressed using a transparent union.
> >
> > Fixes: 872e330e3880 ("firewire: add isochronous multichannel reception")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> > drivers/firewire/core-cdev.c | 6 +++---
> > drivers/firewire/core-iso.c | 2 +-
> > include/linux/firewire.h | 17 ++++++++---------
> > 3 files changed, 12 insertions(+), 13 deletions(-)
>
> Oscar Carter has posted a patch to fix it.
> https://sourceforge.net/p/linux1394/mailman/message/37024966/
>
> I don't know exactly but maintainers seems to overlook it...
Right, that seems fairly similar to my version but avoids the GNU
extension, so it would be better that version.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-27 12:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 21:51 [PATCH] firewire: fix function type cast warning Arnd Bergmann
2020-10-27 0:13 ` Takashi Sakamoto
2020-10-27 12:48 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).