All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: acpi: Fix shifting 31 bits
@ 2021-03-17 14:25 jzp0409
  2021-03-17 14:51 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: jzp0409 @ 2021-03-17 14:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, edison.jiang

From: "edison.jiang" <jiangzhipeng@yulong.com>

Fix undefined behaviour in the usb apci driver by using 'BIT' marcro.

Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>
---
 drivers/usb/core/usb-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 50b2fc7..3e467a8 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -122,7 +122,7 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,
  * Private to usb-acpi, all the core needs to know is that
  * port_dev->location is non-zero when it has been set by the firmware.
  */
-#define USB_ACPI_LOCATION_VALID (1 << 31)
+#define USB_ACPI_LOCATION_VALID BIT(31)
 
 static struct acpi_device *usb_acpi_find_port(struct acpi_device *parent,
 					      int raw)
-- 
1.9.1



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

* Re: [PATCH] usb: acpi: Fix shifting 31 bits
  2021-03-17 14:25 [PATCH] usb: acpi: Fix shifting 31 bits jzp0409
@ 2021-03-17 14:51 ` Greg KH
  2021-03-18  2:14   ` jiangzhipeng
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-03-17 14:51 UTC (permalink / raw)
  To: jzp0409; +Cc: linux-usb, edison.jiang

On Wed, Mar 17, 2021 at 10:25:13PM +0800, jzp0409 wrote:
> From: "edison.jiang" <jiangzhipeng@yulong.com>
> 
> Fix undefined behaviour in the usb apci driver by using 'BIT' marcro.

What is undefined about it?

> 
> Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>

This name is not a valid signed-off-by name (I doubt you sign documents
with a ".", right?) and it does not match the "From:" name either, so
something needs to be fixed before this patch could be accepted.

> ---
>  drivers/usb/core/usb-acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
> index 50b2fc7..3e467a8 100644
> --- a/drivers/usb/core/usb-acpi.c
> +++ b/drivers/usb/core/usb-acpi.c
> @@ -122,7 +122,7 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,
>   * Private to usb-acpi, all the core needs to know is that
>   * port_dev->location is non-zero when it has been set by the firmware.
>   */
> -#define USB_ACPI_LOCATION_VALID (1 << 31)
> +#define USB_ACPI_LOCATION_VALID BIT(31)

I do not understand what this is trying to fix, please be more specific.

thanks,

greg k-h

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

* Re: [PATCH] usb: acpi: Fix shifting 31 bits
  2021-03-17 14:51 ` Greg KH
@ 2021-03-18  2:14   ` jiangzhipeng
  2021-03-18  5:27     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: jiangzhipeng @ 2021-03-18  2:14 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb, edison.jiang

On Wed, 17 Mar 2021 15:51:02 +0100
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Wed, Mar 17, 2021 at 10:25:13PM +0800, jzp0409 wrote:
> > From: "edison.jiang" <jiangzhipeng@yulong.com>
> > 
> > Fix undefined behaviour in the usb apci driver by using 'BIT'
> > marcro.  
> 
> What is undefined about it?
> 
> > 
> > Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>  
> 
> This name is not a valid signed-off-by name (I doubt you sign
> documents with a ".", right?) and it does not match the "From:" name
> either, so something needs to be fixed before this patch could be
> accepted.
> 
> > ---
> >  drivers/usb/core/usb-acpi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/core/usb-acpi.c
> > b/drivers/usb/core/usb-acpi.c index 50b2fc7..3e467a8 100644
> > --- a/drivers/usb/core/usb-acpi.c
> > +++ b/drivers/usb/core/usb-acpi.c
> > @@ -122,7 +122,7 @@ static enum usb_port_connect_type
> > usb_acpi_get_connect_type(acpi_handle handle,
> >   * Private to usb-acpi, all the core needs to know is that
> >   * port_dev->location is non-zero when it has been set by the
> > firmware. */
> > -#define USB_ACPI_LOCATION_VALID (1 << 31)
> > +#define USB_ACPI_LOCATION_VALID BIT(31)  
> 
> I do not understand what this is trying to fix, please be more
> specific.
> 
> thanks,
> 
> greg k-h

cppcheck error:
linux/drivers/usb/core/usb-acpi.c:191]: (error) Shifting signed 32-bit
value by 31 bits is undefined behaviour


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

* Re: [PATCH] usb: acpi: Fix shifting 31 bits
  2021-03-18  2:14   ` jiangzhipeng
@ 2021-03-18  5:27     ` Greg KH
  2021-03-18  8:34       ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2021-03-18  5:27 UTC (permalink / raw)
  To: jiangzhipeng; +Cc: linux-usb, edison.jiang

On Thu, Mar 18, 2021 at 10:14:30AM +0800, jiangzhipeng wrote:
> On Wed, 17 Mar 2021 15:51:02 +0100
> Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> > On Wed, Mar 17, 2021 at 10:25:13PM +0800, jzp0409 wrote:
> > > From: "edison.jiang" <jiangzhipeng@yulong.com>
> > > 
> > > Fix undefined behaviour in the usb apci driver by using 'BIT'
> > > marcro.  
> > 
> > What is undefined about it?
> > 
> > > 
> > > Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>  
> > 
> > This name is not a valid signed-off-by name (I doubt you sign
> > documents with a ".", right?) and it does not match the "From:" name
> > either, so something needs to be fixed before this patch could be
> > accepted.
> > 
> > > ---
> > >  drivers/usb/core/usb-acpi.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/core/usb-acpi.c
> > > b/drivers/usb/core/usb-acpi.c index 50b2fc7..3e467a8 100644
> > > --- a/drivers/usb/core/usb-acpi.c
> > > +++ b/drivers/usb/core/usb-acpi.c
> > > @@ -122,7 +122,7 @@ static enum usb_port_connect_type
> > > usb_acpi_get_connect_type(acpi_handle handle,
> > >   * Private to usb-acpi, all the core needs to know is that
> > >   * port_dev->location is non-zero when it has been set by the
> > > firmware. */
> > > -#define USB_ACPI_LOCATION_VALID (1 << 31)
> > > +#define USB_ACPI_LOCATION_VALID BIT(31)  
> > 
> > I do not understand what this is trying to fix, please be more
> > specific.
> > 
> > thanks,
> > 
> > greg k-h
> 
> cppcheck error:
> linux/drivers/usb/core/usb-acpi.c:191]: (error) Shifting signed 32-bit
> value by 31 bits is undefined behaviour
> 

That does not explain anything, sorry.

greg k-h

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

* Re: [PATCH] usb: acpi: Fix shifting 31 bits
  2021-03-18  5:27     ` Greg KH
@ 2021-03-18  8:34       ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2021-03-18  8:34 UTC (permalink / raw)
  To: jiangzhipeng; +Cc: linux-usb, edison.jiang

On Thu, Mar 18, 2021 at 06:27:37AM +0100, Greg KH wrote:
> On Thu, Mar 18, 2021 at 10:14:30AM +0800, jiangzhipeng wrote:
> > On Wed, 17 Mar 2021 15:51:02 +0100
> > Greg KH <gregkh@linuxfoundation.org> wrote:
> > 
> > > On Wed, Mar 17, 2021 at 10:25:13PM +0800, jzp0409 wrote:
> > > > From: "edison.jiang" <jiangzhipeng@yulong.com>
> > > > 
> > > > Fix undefined behaviour in the usb apci driver by using 'BIT'
> > > > marcro.  
> > > 
> > > What is undefined about it?
> > > 
> > > > 
> > > > Signed-off-by: edison.jiang <jiangzhipeng@yulong.com>  
> > > 
> > > This name is not a valid signed-off-by name (I doubt you sign
> > > documents with a ".", right?) and it does not match the "From:" name
> > > either, so something needs to be fixed before this patch could be
> > > accepted.
> > > 
> > > > ---
> > > >  drivers/usb/core/usb-acpi.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/usb/core/usb-acpi.c
> > > > b/drivers/usb/core/usb-acpi.c index 50b2fc7..3e467a8 100644
> > > > --- a/drivers/usb/core/usb-acpi.c
> > > > +++ b/drivers/usb/core/usb-acpi.c
> > > > @@ -122,7 +122,7 @@ static enum usb_port_connect_type
> > > > usb_acpi_get_connect_type(acpi_handle handle,
> > > >   * Private to usb-acpi, all the core needs to know is that
> > > >   * port_dev->location is non-zero when it has been set by the
> > > > firmware. */
> > > > -#define USB_ACPI_LOCATION_VALID (1 << 31)
> > > > +#define USB_ACPI_LOCATION_VALID BIT(31)  
> > > 
> > > I do not understand what this is trying to fix, please be more
> > > specific.
> > > 
> > > thanks,
> > > 
> > > greg k-h
> > 
> > cppcheck error:
> > linux/drivers/usb/core/usb-acpi.c:191]: (error) Shifting signed 32-bit
> > value by 31 bits is undefined behaviour
> > 
> 
> That does not explain anything, sorry.

In other words, cppcheck is usually horrid and you need to do some real
work to determine what it is trying to say, and to see if it just is
wrong or not.  Please do that research and if there is a real issue,
submit a patch to resolve it and put that information in the changelog
text to explain what is happening.

As it is, this change doesn't seem to actually do anything except quiet
a random tool.  And that tool is wrong here.

thanks,

greg k-h

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

end of thread, other threads:[~2021-03-18  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 14:25 [PATCH] usb: acpi: Fix shifting 31 bits jzp0409
2021-03-17 14:51 ` Greg KH
2021-03-18  2:14   ` jiangzhipeng
2021-03-18  5:27     ` Greg KH
2021-03-18  8:34       ` Greg KH

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.