lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45027fa0-cda5-2a80-f1cd-ed805d2717ee@nfschina.com>
Date:   Fri, 8 Sep 2023 09:23:22 +0800
From:   Su Hui <suhui@...china.com>
To:     Dan Carpenter <dan.carpenter@...aro.org>
Cc:     gregkh@...uxfoundation.org, rafael@...nel.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] driver base: slience unused warning


On 2023/9/7 18:49, Dan Carpenter wrote:
> On Thu, Aug 31, 2023 at 03:36:55PM +0800, Su Hui wrote:
>> Avoid unused warning with gcc and W=1 option.
>>
>> drivers/base/module.c:36:6: error:
>> variable ‘no_warn’ set but not used [-Werror=unused-but-set-variable]
>>
>> Signed-off-by: Su Hui <suhui@...china.com>
>> ---
>>   drivers/base/module.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/module.c b/drivers/base/module.c
>> index 46ad4d636731..10494336d601 100644
>> --- a/drivers/base/module.c
>> +++ b/drivers/base/module.c
>> @@ -33,7 +33,7 @@ static void module_create_drivers_dir(struct module_kobject *mk)
>>   void module_add_driver(struct module *mod, struct device_driver *drv)
>>   {
>>   	char *driver_name;
>> -	int no_warn;
>> +	int __maybe_unused no_warn;
> Just delete the variable if it isn't used.

Hi,

The variable "no_warn" is used to avoid warning like this:

drivers/base/module.c: In function ‘module_add_driver’:
drivers/base/module.c:62:2: error: ignoring return value of 
‘sysfs_create_link’ declared with attribute ‘warn_unused_result’ 
[-Werror=unused-result]

    62 |  sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
       |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This variable is been used but never be read, so gcc and W=1 give such 
warning.

drivers/base/module.c:36:6: error:
variable ‘no_warn’ set but not used [-Werror=unused-but-set-variable]

I wanted to use "__maybe_unused" to avoid  this warning.

However it seems like a wrong using of "__maybe_unused" as Greg KH said:

"But no_warn is being used in this file, it's being set but not read
which is ok.  That's a real use, so this change really isn't correct,
sorry."

Su Hui

>   
>
> regards,
> dan carpenter
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ