All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
@ 2016-06-07 17:48 Andy Shevchenko
  2016-06-08  0:16 ` Rafael J. Wysocki
  2016-06-11  0:19 ` Bjorn Helgaas
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-07 17:48 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm; +Cc: Andy Shevchenko

When cast pci_power_t type of variables a static analizer tool complains on
that.

	include/linux/pci.h:119:37: warning: cast from restricted pci_power_t

Enforce type casting to make static analizer happy.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index b67e4df..8d74834 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -116,7 +116,7 @@ extern const char *pci_power_names[];
 
 static inline const char *pci_power_name(pci_power_t state)
 {
-	return pci_power_names[1 + (int) state];
+	return pci_power_names[1 + (__force int) state];
 }
 
 #define PCI_PM_D2_DELAY		200
-- 
2.8.1


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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
  2016-06-07 17:48 [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t Andy Shevchenko
@ 2016-06-08  0:16 ` Rafael J. Wysocki
  2016-06-11  0:19 ` Bjorn Helgaas
  1 sibling, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2016-06-08  0:16 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pci, Bjorn Helgaas, linux-pm

On Tuesday, June 07, 2016 08:48:33 PM Andy Shevchenko wrote:
> When cast pci_power_t type of variables a static analizer tool complains on
> that.
> 
> 	include/linux/pci.h:119:37: warning: cast from restricted pci_power_t
> 
> Enforce type casting to make static analizer happy.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

ACK

> ---
>  include/linux/pci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b67e4df..8d74834 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -116,7 +116,7 @@ extern const char *pci_power_names[];
>  
>  static inline const char *pci_power_name(pci_power_t state)
>  {
> -	return pci_power_names[1 + (int) state];
> +	return pci_power_names[1 + (__force int) state];
>  }
>  
>  #define PCI_PM_D2_DELAY		200
> 


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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
  2016-06-07 17:48 [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t Andy Shevchenko
  2016-06-08  0:16 ` Rafael J. Wysocki
@ 2016-06-11  0:19 ` Bjorn Helgaas
  2016-06-13 11:40   ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2016-06-11  0:19 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm

On Tue, Jun 07, 2016 at 08:48:33PM +0300, Andy Shevchenko wrote:
> When cast pci_power_t type of variables a static analizer tool complains on
> that.
> 
> 	include/linux/pci.h:119:37: warning: cast from restricted pci_power_t
> 
> Enforce type casting to make static analizer happy.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to pci/pm for v4.8, thanks, Andy.

> ---
>  include/linux/pci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b67e4df..8d74834 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -116,7 +116,7 @@ extern const char *pci_power_names[];
>  
>  static inline const char *pci_power_name(pci_power_t state)
>  {
> -	return pci_power_names[1 + (int) state];
> +	return pci_power_names[1 + (__force int) state];
>  }
>  
>  #define PCI_PM_D2_DELAY		200
> -- 
> 2.8.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
  2016-06-11  0:19 ` Bjorn Helgaas
@ 2016-06-13 11:40   ` Andy Shevchenko
  2016-06-13 13:13     ` Bjorn Helgaas
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-13 11:40 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm

On Fri, 2016-06-10 at 19:19 -0500, Bjorn Helgaas wrote:
> On Tue, Jun 07, 2016 at 08:48:33PM +0300, Andy Shevchenko wrote:
> > When cast pci_power_t type of variables a static analizer tool
> > complains on
> > that.
> > 
> > 	include/linux/pci.h:119:37: warning: cast from restricted
> > pci_power_t
> > 
> > Enforce type casting to make static analizer happy.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Applied to pci/pm for v4.8, thanks, Andy.

Thanks.

By the way, what was the main point to use __bitwise annotation to this
type in the first place?

> 
> > ---
> >  include/linux/pci.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index b67e4df..8d74834 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -116,7 +116,7 @@ extern const char *pci_power_names[];
> >  
> >  static inline const char *pci_power_name(pci_power_t state)
> >  {
> > -	return pci_power_names[1 + (int) state];
> > +	return pci_power_names[1 + (__force int) state];
> >  }
> >  
> >  #define PCI_PM_D2_DELAY		200
> > -- 
> > 2.8.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pci" 
> > in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 

Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
  2016-06-13 11:40   ` Andy Shevchenko
@ 2016-06-13 13:13     ` Bjorn Helgaas
  2016-06-13 13:19         ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2016-06-13 13:13 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm

On Mon, Jun 13, 2016 at 02:40:54PM +0300, Andy Shevchenko wrote:
> On Fri, 2016-06-10 at 19:19 -0500, Bjorn Helgaas wrote:
> > On Tue, Jun 07, 2016 at 08:48:33PM +0300, Andy Shevchenko wrote:
> > > When cast pci_power_t type of variables a static analizer tool
> > > complains on
> > > that.
> > > 
> > > 	include/linux/pci.h:119:37: warning: cast from restricted
> > > pci_power_t
> > > 
> > > Enforce type casting to make static analizer happy.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > Applied to pci/pm for v4.8, thanks, Andy.
> 
> Thanks.
> 
> By the way, what was the main point to use __bitwise annotation to this
> type in the first place?

I don't know.  It looks like pci_power_t was the first use of __bitwise in
pci.h, added by e8191db240d2 ("[PATCH] PCI: Cleanup PCI power states").
That changelog mentions type-safety, but I must admit that doesn't make it
obvious to me.

Bjorn

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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
  2016-06-13 13:13     ` Bjorn Helgaas
@ 2016-06-13 13:19         ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-13 13:19 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm

On Mon, 2016-06-13 at 08:13 -0500, Bjorn Helgaas wrote:
> On Mon, Jun 13, 2016 at 02:40:54PM +0300, Andy Shevchenko wrote:
> > On Fri, 2016-06-10 at 19:19 -0500, Bjorn Helgaas wrote:
> > > On Tue, Jun 07, 2016 at 08:48:33PM +0300, Andy Shevchenko wrote:
> > > > When cast pci_power_t type of variables a static analizer tool
> > > > complains on
> > > > that.
> > > > 
> > > > 	include/linux/pci.h:119:37: warning: cast from
> > > > restricted
> > > > pci_power_t
> > > > 
> > > > Enforce type casting to make static analizer happy.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.co
> > > > m>
> > > 
> > > Applied to pci/pm for v4.8, thanks, Andy.
> > 
> > Thanks.
> > 
> > By the way, what was the main point to use __bitwise annotation to
> > this
> > type in the first place?
> 
> I don't know.  It looks like pci_power_t was the first use of
> __bitwise in
> pci.h, added by e8191db240d2 ("[PATCH] PCI: Cleanup PCI power
> states").
> That changelog mentions type-safety, but I must admit that doesn't
> make it
> obvious to me.

I'm asking since any code which is using this type (all direct
assignments or comparisons) brings a static analyzer complain.
You may check by yourself with (my usual command to build kernel)

% make C=1 CF=-D__CHECK_ENDIAN__ W=1 -j64

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t
@ 2016-06-13 13:19         ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-13 13:19 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Bjorn Helgaas, Rafael J . Wysocki, linux-pm

On Mon, 2016-06-13 at 08:13 -0500, Bjorn Helgaas wrote:
> On Mon, Jun 13, 2016 at 02:40:54PM +0300, Andy Shevchenko wrote:
> > On Fri, 2016-06-10 at 19:19 -0500, Bjorn Helgaas wrote:
> > > On Tue, Jun 07, 2016 at 08:48:33PM +0300, Andy Shevchenko wrote:
> > > > When cast pci_power_t type of variables a static analizer tool
> > > > complains on
> > > > that.
> > > > 
> > > > 	include/linux/pci.h:119:37: warning: cast from
> > > > restricted
> > > > pci_power_t
> > > > 
> > > > Enforce type casting to make static analizer happy.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.co
> > > > m>
> > > 
> > > Applied to pci/pm for v4.8, thanks, Andy.
> > 
> > Thanks.
> > 
> > By the way, what was the main point to use __bitwise annotation to
> > this
> > type in the first place?
> 
> I don't know.  It looks like pci_power_t was the first use of
> __bitwise in
> pci.h, added by e8191db240d2 ("[PATCH] PCI: Cleanup PCI power
> states").
> That changelog mentions type-safety, but I must admit that doesn't
> make it
> obvious to me.

I'm asking since any code which is using this type (all direct
assignments or comparisons) brings a static analyzer complain.
You may check by yourself with (my usual command to build kernel)

% make C=1 CF=-D__CHECK_ENDIAN__ W=1 -j64

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

end of thread, other threads:[~2016-06-13 13:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 17:48 [PATCH v1 1/1] PCI / PM: enforce type casting for pci_power_t Andy Shevchenko
2016-06-08  0:16 ` Rafael J. Wysocki
2016-06-11  0:19 ` Bjorn Helgaas
2016-06-13 11:40   ` Andy Shevchenko
2016-06-13 13:13     ` Bjorn Helgaas
2016-06-13 13:19       ` Andy Shevchenko
2016-06-13 13:19         ` Andy Shevchenko

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.