linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] base: topology: fix unused variable compile error
@ 2022-04-25  2:41 Ren Zhijie
  2022-04-25  5:41 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Ren Zhijie @ 2022-04-25  2:41 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Ren Zhijie

compile error:
drivers/base/topology.c: In function ‘topology_is_visible’:
drivers/base/topology.c:158:17: error: unused variable ‘dev’ [-Werror=unused-variable]
  struct device *dev = kobj_to_dev(kobj);
                 ^~~
cc1: all warnings being treated as errors

If CONFIG_SMP is N, the macro 'topology_ppin()'expands as follows.
"topology_ppin(dev->id) -> boot_cpu_data.ppin"
This cause an unused variable warning for 'dev' which used in the
topology_is_visible().

To fix build warning unused attribute added to the 'dev' variable.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes:aa63a74d4535("topology/sysfs: Hide PPIN on systems that do not support it.")
Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
---
 drivers/base/topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 706dbf8bf249..70962a4bcb1f 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -155,7 +155,8 @@ static struct attribute *default_attrs[] = {
 static umode_t topology_is_visible(struct kobject *kobj,
 				   struct attribute *attr, int unused)
 {
-	struct device *dev = kobj_to_dev(kobj);
+	struct device *dev __maybe_unused;

+	dev = kobj_to_dev(kobj);
 
 	if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
 		return 0;
-- 
2.17.1


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

* Re: [PATCH -next] base: topology: fix unused variable compile error
  2022-04-25  2:41 [PATCH -next] base: topology: fix unused variable compile error Ren Zhijie
@ 2022-04-25  5:41 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-04-25  5:41 UTC (permalink / raw)
  To: Ren Zhijie; +Cc: rafael, linux-kernel

On Mon, Apr 25, 2022 at 10:41:49AM +0800, Ren Zhijie wrote:
> compile error:
> drivers/base/topology.c: In function ‘topology_is_visible’:
> drivers/base/topology.c:158:17: error: unused variable ‘dev’ [-Werror=unused-variable]
>   struct device *dev = kobj_to_dev(kobj);
>                  ^~~
> cc1: all warnings being treated as errors
> 
> If CONFIG_SMP is N, the macro 'topology_ppin()'expands as follows.
> "topology_ppin(dev->id) -> boot_cpu_data.ppin"
> This cause an unused variable warning for 'dev' which used in the
> topology_is_visible().
> 
> To fix build warning unused attribute added to the 'dev' variable.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes:aa63a74d4535("topology/sysfs: Hide PPIN on systems that do not support it.")
> Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
> ---
>  drivers/base/topology.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/topology.c b/drivers/base/topology.c
> index 706dbf8bf249..70962a4bcb1f 100644
> --- a/drivers/base/topology.c
> +++ b/drivers/base/topology.c
> @@ -155,7 +155,8 @@ static struct attribute *default_attrs[] = {
>  static umode_t topology_is_visible(struct kobject *kobj,
>  				   struct attribute *attr, int unused)
>  {
> -	struct device *dev = kobj_to_dev(kobj);
> +	struct device *dev __maybe_unused;
> 
> +	dev = kobj_to_dev(kobj);
>  
>  	if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
>  		return 0;
> -- 
> 2.17.1
> 

Thanks for this, but I've already queued up the commit here:
	https://lore.kernel.org/r/20220422062653.3899972-1-gregkh@linuxfoundation.org
which is simpler and smaller and it should show up in the next
linux-next release.

greg k-h

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

end of thread, other threads:[~2022-04-25  5:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25  2:41 [PATCH -next] base: topology: fix unused variable compile error Ren Zhijie
2022-04-25  5:41 ` Greg KH

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).