kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof
@ 2012-09-19 16:31 Fengguang Wu
  2012-09-19 17:06 ` [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Fengguang Wu @ 2012-09-19 16:31 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]

Hi Lars-Peter,

FYI, there are new coccinelle warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
head:   5d06e3df280bd230e2eadc16372e62818c63e894
commit: a0e545e0e75006a7de0e9bc5397f6b44c61990b2 [86/151] staging:iio:hwmon bridge: Use iio_read_channel_processed

All coccinelle warnings:

+ drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof to pointer

vim +96 drivers/staging/iio/iio_hwmon.c
    86		st->channels = iio_channel_get_all(dev_name(&pdev->dev));
    87		if (IS_ERR(st->channels)) {
    88			ret = PTR_ERR(st->channels);
    89			goto error_free_state;
    90		}
    91	
    92		/* count how many attributes we have */
    93		while (st->channels[st->num_channels].indio_dev)
    94			st->num_channels++;
    95	
  > 96		st->attrs = kzalloc(sizeof(st->attrs) * (st->num_channels + 1),
    97				    GFP_KERNEL);
    98		if (st->attrs == NULL) {
    99			ret = -ENOMEM;
   100			goto error_release_channels;
   101		}
   102		for (i = 0; i < st->num_channels; i++) {
   103			a = kzalloc(sizeof(*a), GFP_KERNEL);
   104			if (a == NULL) {
   105				ret = -ENOMEM;
   106				goto error_free_attrs;

Please consider folding the attached diff :-)

---
0-DAY kernel build testing backend         Open Source Technology Centre
Fengguang Wu, Yuanhan Liu                              Intel Corporation

[-- Attachment #2: noderef-iio_hwmon.patch --]
[-- Type: text/x-diff, Size: 918 bytes --]

[PATCH] iio_hwmon: fix coccinelle warnings

/c/kernel-tests/src/linux/drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof to pointer

 sizeof when applied to a pointer typed expression gives the size of
 the pointer

Generated by: scripts/coccinelle/misc/noderef.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

Please take the patch only if it's a positive warning. Thanks!

 cocci-output-20562-fb0f2b-iio_hwmon.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/staging/iio/iio_hwmon.c
+++ b/drivers/staging/iio/iio_hwmon.c
@@ -93,7 +93,7 @@ static int __devinit iio_hwmon_probe(str
 	while (st->channels[st->num_channels].indio_dev)
 		st->num_channels++;
 
-	st->attrs = kzalloc(sizeof(st->attrs) * (st->num_channels + 1),
+	st->attrs = kzalloc(sizeof(*st->attrs) * (st->num_channels + 1),
 			    GFP_KERNEL);
 	if (st->attrs == NULL) {
 		ret = -ENOMEM;

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

* Re: [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si
  2012-09-19 16:31 [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof Fengguang Wu
@ 2012-09-19 17:06 ` Lars-Peter Clausen
  2012-09-19 17:19 ` Fengguang Wu
  2012-09-19 19:15 ` Lars-Peter Clausen
  2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2012-09-19 17:06 UTC (permalink / raw)
  To: kernel-janitors

On 09/19/2012 06:31 PM, Fengguang Wu wrote:
> Hi Lars-Peter,
> 
> FYI, there are new coccinelle warnings show up in
> 
> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
> head:   5d06e3df280bd230e2eadc16372e62818c63e894
> commit: a0e545e0e75006a7de0e9bc5397f6b44c61990b2 [86/151] staging:iio:hwmon bridge: Use iio_read_channel_processed

Hi,

Thanks for info, patch looks good, but the warning is not introduced by the
commit you mention, though.

- Lars

> 
> All coccinelle warnings:
> 
> + drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof to pointer
> 
> vim +96 drivers/staging/iio/iio_hwmon.c
>     86		st->channels = iio_channel_get_all(dev_name(&pdev->dev));
>     87		if (IS_ERR(st->channels)) {
>     88			ret = PTR_ERR(st->channels);
>     89			goto error_free_state;
>     90		}
>     91	
>     92		/* count how many attributes we have */
>     93		while (st->channels[st->num_channels].indio_dev)
>     94			st->num_channels++;
>     95	
>   > 96		st->attrs = kzalloc(sizeof(st->attrs) * (st->num_channels + 1),
>     97				    GFP_KERNEL);
>     98		if (st->attrs = NULL) {
>     99			ret = -ENOMEM;
>    100			goto error_release_channels;
>    101		}
>    102		for (i = 0; i < st->num_channels; i++) {
>    103			a = kzalloc(sizeof(*a), GFP_KERNEL);
>    104			if (a = NULL) {
>    105				ret = -ENOMEM;
>    106				goto error_free_attrs;
> 
> Please consider folding the attached diff :-)
> 
> ---
> 0-DAY kernel build testing backend         Open Source Technology Centre
> Fengguang Wu, Yuanhan Liu                              Intel Corporation


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

* Re: [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si
  2012-09-19 16:31 [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof Fengguang Wu
  2012-09-19 17:06 ` [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si Lars-Peter Clausen
@ 2012-09-19 17:19 ` Fengguang Wu
  2012-09-19 19:15 ` Lars-Peter Clausen
  2 siblings, 0 replies; 4+ messages in thread
From: Fengguang Wu @ 2012-09-19 17:19 UTC (permalink / raw)
  To: kernel-janitors

On Wed, Sep 19, 2012 at 07:06:39PM +0200, Lars-Peter Clausen wrote:
> On 09/19/2012 06:31 PM, Fengguang Wu wrote:
> > Hi Lars-Peter,
> > 
> > FYI, there are new coccinelle warnings show up in
> > 
> > tree:   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
> > head:   5d06e3df280bd230e2eadc16372e62818c63e894
> > commit: a0e545e0e75006a7de0e9bc5397f6b44c61990b2 [86/151] staging:iio:hwmon bridge: Use iio_read_channel_processed
> 
> Hi,
> 
> Thanks for info, patch looks good, but the warning is not introduced by the
> commit you mention, though.

Sorry! I should probably change the prompt message accordingly,
especially removing the word "new". Because I'm reporting new as
well as old coccinelle warnings:

In fact I've never run a complete coccinelle check, mark all existing
warnings as "old" and ignore them.  It feels not good to ignore all
existing problems in that way. On the other hand, it's also not
feasible to check/fix all of them in one day.

So I decided to report old/new coccinelle warnings for the files
touched by new commits. Which looks like the most manageable way.
However it means the below message is not always accurate and
sometimes I forgot to change it accordingly:

> > FYI, there are new coccinelle warnings show up in

Thanks,
Fengguang

> > All coccinelle warnings:
> > 
> > + drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof to pointer
> > 
> > vim +96 drivers/staging/iio/iio_hwmon.c
> >     86		st->channels = iio_channel_get_all(dev_name(&pdev->dev));
> >     87		if (IS_ERR(st->channels)) {
> >     88			ret = PTR_ERR(st->channels);
> >     89			goto error_free_state;
> >     90		}
> >     91	
> >     92		/* count how many attributes we have */
> >     93		while (st->channels[st->num_channels].indio_dev)
> >     94			st->num_channels++;
> >     95	
> >   > 96		st->attrs = kzalloc(sizeof(st->attrs) * (st->num_channels + 1),
> >     97				    GFP_KERNEL);
> >     98		if (st->attrs = NULL) {
> >     99			ret = -ENOMEM;
> >    100			goto error_release_channels;
> >    101		}
> >    102		for (i = 0; i < st->num_channels; i++) {
> >    103			a = kzalloc(sizeof(*a), GFP_KERNEL);
> >    104			if (a = NULL) {
> >    105				ret = -ENOMEM;
> >    106				goto error_free_attrs;
> > 
> > Please consider folding the attached diff :-)
> > 
> > ---
> > 0-DAY kernel build testing backend         Open Source Technology Centre
> > Fengguang Wu, Yuanhan Liu                              Intel Corporation

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

* Re: [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si
  2012-09-19 16:31 [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof Fengguang Wu
  2012-09-19 17:06 ` [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si Lars-Peter Clausen
  2012-09-19 17:19 ` Fengguang Wu
@ 2012-09-19 19:15 ` Lars-Peter Clausen
  2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2012-09-19 19:15 UTC (permalink / raw)
  To: kernel-janitors

On 09/19/2012 07:19 PM, Fengguang Wu wrote:
> On Wed, Sep 19, 2012 at 07:06:39PM +0200, Lars-Peter Clausen wrote:
>> On 09/19/2012 06:31 PM, Fengguang Wu wrote:
>>> Hi Lars-Peter,
>>>
>>> FYI, there are new coccinelle warnings show up in
>>>
>>> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
>>> head:   5d06e3df280bd230e2eadc16372e62818c63e894
>>> commit: a0e545e0e75006a7de0e9bc5397f6b44c61990b2 [86/151] staging:iio:hwmon bridge: Use iio_read_channel_processed
>>
>> Hi,
>>
>> Thanks for info, patch looks good, but the warning is not introduced by the
>> commit you mention, though.
> 
> Sorry! I should probably change the prompt message accordingly,
> especially removing the word "new". Because I'm reporting new as
> well as old coccinelle warnings:
> 
> In fact I've never run a complete coccinelle check, mark all existing
> warnings as "old" and ignore them.  It feels not good to ignore all
> existing problems in that way. On the other hand, it's also not
> feasible to check/fix all of them in one day.
> 
> So I decided to report old/new coccinelle warnings for the files
> touched by new commits. Which looks like the most manageable way.
> However it means the below message is not always accurate and
> sometimes I forgot to change it accordingly:
> 

Ok. I think for IIO I'll just go through all the existing warnings and fix
them, that should avoid old warnings with new patches.

- Lars

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

end of thread, other threads:[~2012-09-19 19:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 16:31 [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of sizeof Fengguang Wu
2012-09-19 17:06 ` [staging:staging-next 86/151] drivers/staging/iio/iio_hwmon.c:96:21-27: ERROR: application of si Lars-Peter Clausen
2012-09-19 17:19 ` Fengguang Wu
2012-09-19 19:15 ` Lars-Peter Clausen

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