All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sr: Fix a recently introduced W=1 compiler warning
@ 2020-03-30  2:53 Bart Van Assche
  2020-03-30  3:06 ` James Bottomley
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2020-03-30  2:53 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Arnd Bergmann

Fix the following compiler warning:

drivers/scsi/sr.c:686:12: warning: initialized field overwritten [-Woverride-init]
  686 |  .ioctl  = sr_block_compat_ioctl,
      |            ^~~~~~~~~~~~~~~~~~~~~
drivers/scsi/sr.c:686:12: note: (near initialization for 'sr_bdops.ioctl')

Cc: Arnd Bergmann <arnd@arndb.de>
Fixes: d320a9551e39 ("compat_ioctl: scsi: move ioctl handling into drivers")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/sr.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index fe0e1c721a99..9ad57a98a37f 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -556,6 +556,7 @@ static void sr_block_release(struct gendisk *disk, fmode_t mode)
 	mutex_unlock(&cd->lock);
 }
 
+#ifndef CONFIG_COMPAT
 static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 			  unsigned long arg)
 {
@@ -597,8 +598,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 	mutex_unlock(&cd->lock);
 	return ret;
 }
-
-#ifdef CONFIG_COMPAT
+#else /* !defined(CONFIG_COMPAT) */
 static int sr_block_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
 			  unsigned long arg)
 {
@@ -641,7 +641,7 @@ static int sr_block_compat_ioctl(struct block_device *bdev, fmode_t mode, unsign
 	return ret;
 
 }
-#endif
+#endif /* !defined(CONFIG_COMPAT) */
 
 static unsigned int sr_block_check_events(struct gendisk *disk,
 					  unsigned int clearing)
@@ -685,8 +685,9 @@ static const struct block_device_operations sr_bdops =
 	.owner		= THIS_MODULE,
 	.open		= sr_block_open,
 	.release	= sr_block_release,
+#ifndef CONFIG_COMPAT
 	.ioctl		= sr_block_ioctl,
-#ifdef CONFIG_COMPAT
+#else
 	.ioctl		= sr_block_compat_ioctl,
 #endif
 	.check_events	= sr_block_check_events,

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

* Re: [PATCH] sr: Fix a recently introduced W=1 compiler warning
  2020-03-30  2:53 [PATCH] sr: Fix a recently introduced W=1 compiler warning Bart Van Assche
@ 2020-03-30  3:06 ` James Bottomley
  2020-03-30  8:59   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2020-03-30  3:06 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen; +Cc: linux-scsi, Arnd Bergmann

On Sun, 2020-03-29 at 19:53 -0700, Bart Van Assche wrote: 
>  static unsigned int sr_block_check_events(struct gendisk *disk,
>  					  unsigned int clearing)
> @@ -685,8 +685,9 @@ static const struct block_device_operations
> sr_bdops =
>  	.owner		= THIS_MODULE,
>  	.open		= sr_block_open,
>  	.release	= sr_block_release,
> +#ifndef CONFIG_COMPAT
>  	.ioctl		= sr_block_ioctl,
> -#ifdef CONFIG_COMPAT
> +#else
>  	.ioctl		= sr_block_compat_ioctl,

Well, this is obviously incorrect: we need the compat ioctl for 32 on
64 bit and the real for native 64 bit, so both have to be defined. 
What you propose would work if we were only ever 32 on 64.  I think
what you want to do is change the second .ioctl to .compat_ioctl.

James


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

* Re: [PATCH] sr: Fix a recently introduced W=1 compiler warning
  2020-03-30  3:06 ` James Bottomley
@ 2020-03-30  8:59   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-03-30  8:59 UTC (permalink / raw)
  To: James Bottomley; +Cc: Bart Van Assche, Martin K . Petersen, linux-scsi

On Mon, Mar 30, 2020 at 5:06 AM James Bottomley <jejb@linux.vnet.ibm.com> wrote:
>
> On Sun, 2020-03-29 at 19:53 -0700, Bart Van Assche wrote:
> >  static unsigned int sr_block_check_events(struct gendisk *disk,
> >                                         unsigned int clearing)
> > @@ -685,8 +685,9 @@ static const struct block_device_operations
> > sr_bdops =
> >       .owner          = THIS_MODULE,
> >       .open           = sr_block_open,
> >       .release        = sr_block_release,
> > +#ifndef CONFIG_COMPAT
> >       .ioctl          = sr_block_ioctl,
> > -#ifdef CONFIG_COMPAT
> > +#else
> >       .ioctl          = sr_block_compat_ioctl,
>
> Well, this is obviously incorrect: we need the compat ioctl for 32 on
> 64 bit and the real for native 64 bit, so both have to be defined.
> What you propose would work if we were only ever 32 on 64.  I think
> what you want to do is change the second .ioctl to .compat_ioctl.

The correct fix was merged into v5.6-rc4, see commit 03264ddde245 ("scsi:
compat_ioctl: cdrom: Replace .ioctl with .compat_ioctl in four appropriate
places").

        Arnd

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

end of thread, other threads:[~2020-03-30  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30  2:53 [PATCH] sr: Fix a recently introduced W=1 compiler warning Bart Van Assche
2020-03-30  3:06 ` James Bottomley
2020-03-30  8:59   ` Arnd Bergmann

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.