Linux-Block Archive mirror
 help / color / mirror / Atom feed
* [PATCH] floppy: fix function pointer cast warnings
@ 2024-02-13  9:59 Arnd Bergmann
  2024-02-13 15:55 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-02-13  9:59 UTC (permalink / raw
  To: Denis Efremov, Jens Axboe
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Christian Brauner, Hannes Reinecke, Andrew Morton,
	Kirill A. Shutemov, Johannes Thumshirn, linux-block, linux-kernel,
	llvm

From: Arnd Bergmann <arnd@arndb.de>

clang-16 complains about a control flow integrity (kcfi) violation
casting between incompatible pointers:

drivers/block/floppy.c:2001:11: error: cast from 'void (*)(void)' to 'done_f' (aka 'void (*)(int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
 2001 |         .done           = (done_f)empty
      |                           ^~~~~~~~~~~~~

Just add another empty function with the correct prototype as a
workaround.

The warning is for code that was added before the start of the normal
git history, but I tracked it done to an early change in the reconstructed
linux-history.git.

Fixes: 598a477afe06 ("Import 1.1.41")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/block/floppy.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index d0e41d52d6a9..2ba0ba135951 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -530,14 +530,13 @@ static struct format_descr format_req;
 static char *floppy_track_buffer;
 static int max_buffer_sectors;
 
-typedef void (*done_f)(int);
 static const struct cont_t {
 	void (*interrupt)(void);
 				/* this is called after the interrupt of the
 				 * main command */
 	void (*redo)(void);	/* this is called to retry the operation */
 	void (*error)(void);	/* this is called to tally an error */
-	done_f done;		/* this is called to say if the operation has
+	void (*done)(int);	/* this is called to say if the operation has
 				 * succeeded/failed */
 } *cont;
 
@@ -985,6 +984,10 @@ static void empty(void)
 {
 }
 
+static void empty_done(int result)
+{
+}
+
 static void (*floppy_work_fn)(void);
 
 static void floppy_work_workfn(struct work_struct *work)
@@ -1998,14 +2001,14 @@ static const struct cont_t wakeup_cont = {
 	.interrupt	= empty,
 	.redo		= do_wakeup,
 	.error		= empty,
-	.done		= (done_f)empty
+	.done		= empty_done,
 };
 
 static const struct cont_t intr_cont = {
 	.interrupt	= empty,
 	.redo		= process_fd_request,
 	.error		= empty,
-	.done		= (done_f)empty
+	.done		= empty_done,
 };
 
 /* schedules handler, waiting for completion. May be interrupted, will then
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] floppy: fix function pointer cast warnings
  2024-02-13  9:59 [PATCH] floppy: fix function pointer cast warnings Arnd Bergmann
@ 2024-02-13 15:55 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-02-13 15:55 UTC (permalink / raw
  To: Denis Efremov, Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Christian Brauner, Hannes Reinecke, Andrew Morton,
	Kirill A. Shutemov, Johannes Thumshirn, linux-block, linux-kernel,
	llvm


On Tue, 13 Feb 2024 10:59:07 +0100, Arnd Bergmann wrote:
> clang-16 complains about a control flow integrity (kcfi) violation
> casting between incompatible pointers:
> 
> drivers/block/floppy.c:2001:11: error: cast from 'void (*)(void)' to 'done_f' (aka 'void (*)(int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>  2001 |         .done           = (done_f)empty
>       |                           ^~~~~~~~~~~~~
> 
> [...]

Applied, thanks!

[1/1] floppy: fix function pointer cast warnings
      commit: 7789bf05529889a39bcf4cd17a68521de063b88b

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-13 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-13  9:59 [PATCH] floppy: fix function pointer cast warnings Arnd Bergmann
2024-02-13 15:55 ` Jens Axboe

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 read-only IMAP folder(s) and NNTP newsgroup(s).