2023-01-11 02:56:31

by XU pengfei

[permalink] [raw]
Subject: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

Pointer variables of void * type do not require type cast.

Signed-off-by: XU pengfei <[email protected]>
---
drivers/hwmon/ibmpex.c | 2 +-
drivers/hwmon/powr1220.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index 1837cccd993c..db066b368918 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -546,7 +546,7 @@ static void ibmpex_bmc_gone(int iface)

static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
{
- struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
+ struct ibmpex_bmc_data *data = user_msg_data;

if (msg->msgid != data->tx_msgid) {
dev_err(data->bmc_device,
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index f77dc6db31ac..501337ee5aa3 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -174,7 +174,7 @@ static umode_t
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
attr, int channel)
{
- struct powr1220_data *chip_data = (struct powr1220_data *)data;
+ struct powr1220_data *chip_data = data;

if (channel >= chip_data->max_channels)
return 0;
--
2.18.2


2023-01-11 03:32:19

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

On 1/10/23 18:07, XU pengfei wrote:
> Pointer variables of void * type do not require type cast.
>

One patch per driver, and include the driver name (ibmpex, powr1220)
in the subject.

Guenter

> Signed-off-by: XU pengfei <[email protected]>
> ---
> drivers/hwmon/ibmpex.c | 2 +-
> drivers/hwmon/powr1220.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
> index 1837cccd993c..db066b368918 100644
> --- a/drivers/hwmon/ibmpex.c
> +++ b/drivers/hwmon/ibmpex.c
> @@ -546,7 +546,7 @@ static void ibmpex_bmc_gone(int iface)
>
> static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
> {
> - struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
> + struct ibmpex_bmc_data *data = user_msg_data;
>
> if (msg->msgid != data->tx_msgid) {
> dev_err(data->bmc_device,
> diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
> index f77dc6db31ac..501337ee5aa3 100644
> --- a/drivers/hwmon/powr1220.c
> +++ b/drivers/hwmon/powr1220.c
> @@ -174,7 +174,7 @@ static umode_t
> powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
> attr, int channel)
> {
> - struct powr1220_data *chip_data = (struct powr1220_data *)data;
> + struct powr1220_data *chip_data = data;
>
> if (channel >= chip_data->max_channels)
> return 0;

2023-01-11 06:10:46

by Ammar Faizi

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

On 1/11/23 10:29 AM, Guenter Roeck wrote:
> On 1/10/23 18:07, XU pengfei wrote:
>> diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
>> index f77dc6db31ac..501337ee5aa3 100644
>> --- a/drivers/hwmon/powr1220.c
>> +++ b/drivers/hwmon/powr1220.c
>> @@ -174,7 +174,7 @@ static umode_t
>>   powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
>>               attr, int channel)
>>   {
>> -    struct powr1220_data *chip_data = (struct powr1220_data *)data;
>> +    struct powr1220_data *chip_data = data;

This is wrong. That cast is needed to discard the "const".

CC [M] drivers/hwmon/powr1220.o
drivers/hwmon/powr1220.c: In function ‘powr1220_is_visible’:
drivers/hwmon/powr1220.c:177:43: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
177 | struct powr1220_data *chip_data = data;
| ^~~~
cc1: all warnings being treated as errors

--
Ammar Faizi

2023-01-11 06:20:17

by Ammar Faizi

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

On 1/11/23 1:03 PM, Ammar Faizi wrote:
> On 1/11/23 10:29 AM, Guenter Roeck wrote:
>> On 1/10/23 18:07, XU pengfei wrote:
>>> diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
>>> index f77dc6db31ac..501337ee5aa3 100644
>>> --- a/drivers/hwmon/powr1220.c
>>> +++ b/drivers/hwmon/powr1220.c
>>> @@ -174,7 +174,7 @@ static umode_t
>>>   powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
>>>               attr, int channel)
>>>   {
>>> -    struct powr1220_data *chip_data = (struct powr1220_data *)data;
>>> +    struct powr1220_data *chip_data = data;
>
> This is wrong. That cast is needed to discard the "const".
>
>   CC [M]  drivers/hwmon/powr1220.o
> drivers/hwmon/powr1220.c: In function ‘powr1220_is_visible’:
> drivers/hwmon/powr1220.c:177:43: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
>   177 |         struct powr1220_data *chip_data = data;
>       |                                           ^~~~
> cc1: all warnings being treated as errors

Anyway, powr1220_is_visible() doesn't write via that pointer, but
the local variable needs to be a const as well.

diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index f77dc6db31ac..7cbbed5a6f5e 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -174,7 +174,7 @@ static umode_t
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
attr, int channel)
{
- struct powr1220_data *chip_data = (struct powr1220_data *)data;
+ const struct powr1220_data *chip_data = data;

if (channel >= chip_data->max_channels)
return 0;


--
Ammar Faizi

2023-01-11 07:34:28

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

Hi XU,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on linus/master v6.2-rc3 next-20230111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20230111020723.3194-1-xupengfei%40nfschina.com
patch subject: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
config: alpha-randconfig-r036-20230110
compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d29823be8837ea100c4a9525d4d0fbc122b77566
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
git checkout d29823be8837ea100c4a9525d4d0fbc122b77566
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

drivers/hwmon/powr1220.c: In function 'powr1220_is_visible':
>> drivers/hwmon/powr1220.c:177:43: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
177 | struct powr1220_data *chip_data = data;
| ^~~~


vim +/const +177 drivers/hwmon/powr1220.c

172
173 static umode_t
174 powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
175 attr, int channel)
176 {
> 177 struct powr1220_data *chip_data = data;
178
179 if (channel >= chip_data->max_channels)
180 return 0;
181
182 switch (type) {
183 case hwmon_in:
184 switch (attr) {
185 case hwmon_in_input:
186 case hwmon_in_highest:
187 case hwmon_in_label:
188 return 0444;
189 default:
190 break;
191 }
192 break;
193 default:
194 break;
195 }
196
197 return 0;
198 }
199

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.90 kB)
config (121.77 kB)
Download all attachments

2023-01-11 08:32:18

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

Hi XU,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on linus/master v6.2-rc3 next-20230111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20230111020723.3194-1-xupengfei%40nfschina.com
patch subject: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
config: i386-randconfig-a002
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d29823be8837ea100c4a9525d4d0fbc122b77566
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
git checkout d29823be8837ea100c4a9525d4d0fbc122b77566
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/hwmon/powr1220.c:177:24: error: initializing 'struct powr1220_data *' with an expression of type 'const void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
struct powr1220_data *chip_data = data;
^ ~~~~
1 error generated.


vim +177 drivers/hwmon/powr1220.c

172
173 static umode_t
174 powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
175 attr, int channel)
176 {
> 177 struct powr1220_data *chip_data = data;
178
179 if (channel >= chip_data->max_channels)
180 return 0;
181
182 switch (type) {
183 case hwmon_in:
184 switch (attr) {
185 case hwmon_in_input:
186 case hwmon_in_highest:
187 case hwmon_in_label:
188 return 0444;
189 default:
190 break;
191 }
192 break;
193 default:
194 break;
195 }
196
197 return 0;
198 }
199

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.94 kB)
config (171.96 kB)
Download all attachments

2023-01-11 09:22:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions

Hi XU,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on linus/master v6.2-rc3 next-20230111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link: https://lore.kernel.org/r/20230111020723.3194-1-xupengfei%40nfschina.com
patch subject: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
config: csky-randconfig-s053-20230110
compiler: csky-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/d29823be8837ea100c4a9525d4d0fbc122b77566
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review XU-pengfei/hwmon-remove-unnecessary-void-conversions/20230111-100855
git checkout d29823be8837ea100c4a9525d4d0fbc122b77566
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash drivers/hwmon/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

sparse warnings: (new ones prefixed by >>)
>> drivers/hwmon/powr1220.c:177:43: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected struct powr1220_data *chip_data @@ got void const *data @@
drivers/hwmon/powr1220.c:177:43: sparse: expected struct powr1220_data *chip_data
drivers/hwmon/powr1220.c:177:43: sparse: got void const *data

vim +177 drivers/hwmon/powr1220.c

172
173 static umode_t
174 powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
175 attr, int channel)
176 {
> 177 struct powr1220_data *chip_data = data;
178
179 if (channel >= chip_data->max_channels)
180 return 0;
181
182 switch (type) {
183 case hwmon_in:
184 switch (attr) {
185 case hwmon_in_input:
186 case hwmon_in_highest:
187 case hwmon_in_label:
188 return 0444;
189 default:
190 break;
191 }
192 break;
193 default:
194 break;
195 }
196
197 return 0;
198 }
199

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (3.06 kB)
config (154.46 kB)
Download all attachments