All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 13:40 ` Laurent Navet
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Navet @ 2013-01-08 13:40 UTC (permalink / raw)
  To: w.sang; +Cc: ben-linux, khali, linux-i2c, linux-kernel, Laurent Navet

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

The semantic patch that makes this output is available
in scripts/coccinelle/misc/noderef.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 7fa5b24..f958d0f 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
 	}
 
 	mux->busses = devm_kzalloc(&pdev->dev,
-				   sizeof(mux->busses) * mux->pdata->bus_count,
+				   sizeof(*mux->busses) * mux->pdata->bus_count,
 				   GFP_KERNEL);
 	if (!mux->busses) {
 		dev_err(&pdev->dev, "Cannot allocate busses\n");
-- 
1.7.10.4


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

* [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 13:40 ` Laurent Navet
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Navet @ 2013-01-08 13:40 UTC (permalink / raw)
  To: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ
  Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg, khali-PUYAD+kWke1g9hUCZPvPmw,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Laurent Navet

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

The semantic patch that makes this output is available
in scripts/coccinelle/misc/noderef.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Laurent Navet <laurent.navet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 7fa5b24..f958d0f 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
 	}
 
 	mux->busses = devm_kzalloc(&pdev->dev,
-				   sizeof(mux->busses) * mux->pdata->bus_count,
+				   sizeof(*mux->busses) * mux->pdata->bus_count,
 				   GFP_KERNEL);
 	if (!mux->busses) {
 		dev_err(&pdev->dev, "Cannot allocate busses\n");
-- 
1.7.10.4

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 14:43   ` Laurent Navet
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Navet @ 2013-01-08 14:43 UTC (permalink / raw)
  To: w.sang; +Cc: ben-linux, khali, linux-i2c, linux-kernel, Laurent Navet

This is not really a bug as mux->busses is a multilevel pointer, so
the result of sizeof(ptr) is the same as sizeof(*ptr).
But I think this is more logical and according to CodingStyle rules like this.
This is also what is done for mux->states a few lines above.

Regards,


2013/1/8, Laurent Navet <laurent.navet@gmail.com>:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
>
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
>
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
>
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> index 7fa5b24..f958d0f 100644
> --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> @@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct
> platform_device *pdev)
>  	}
>
>  	mux->busses = devm_kzalloc(&pdev->dev,
> -				   sizeof(mux->busses) * mux->pdata->bus_count,
> +				   sizeof(*mux->busses) * mux->pdata->bus_count,
>  				   GFP_KERNEL);
>  	if (!mux->busses) {
>  		dev_err(&pdev->dev, "Cannot allocate busses\n");
> --
> 1.7.10.4
>
>


-- 
« On ne résout pas un problème avec les modes de pensée qui l’ont engendré. »
« You cannot solve current problems with current thinking. Current
problems are the result of current thinking »

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 14:43   ` Laurent Navet
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Navet @ 2013-01-08 14:43 UTC (permalink / raw)
  To: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ
  Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg, khali-PUYAD+kWke1g9hUCZPvPmw,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Laurent Navet

This is not really a bug as mux->busses is a multilevel pointer, so
the result of sizeof(ptr) is the same as sizeof(*ptr).
But I think this is more logical and according to CodingStyle rules like this.
This is also what is done for mux->states a few lines above.

Regards,


2013/1/8, Laurent Navet <laurent.navet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
>
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
>
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
>
> Signed-off-by: Laurent Navet <laurent.navet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> index 7fa5b24..f958d0f 100644
> --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> @@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct
> platform_device *pdev)
>  	}
>
>  	mux->busses = devm_kzalloc(&pdev->dev,
> -				   sizeof(mux->busses) * mux->pdata->bus_count,
> +				   sizeof(*mux->busses) * mux->pdata->bus_count,
>  				   GFP_KERNEL);
>  	if (!mux->busses) {
>  		dev_err(&pdev->dev, "Cannot allocate busses\n");
> --
> 1.7.10.4
>
>


-- 
« On ne résout pas un problème avec les modes de pensée qui l’ont engendré. »
« You cannot solve current problems with current thinking. Current
problems are the result of current thinking »

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 19:32   ` Jean Delvare
  0 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2013-01-08 19:32 UTC (permalink / raw)
  To: Laurent Navet; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

On Tue,  8 Jan 2013 14:40:09 +0100, Laurent Navet wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
> 
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
> 
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> index 7fa5b24..f958d0f 100644
> --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> @@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
>  	}
>  
>  	mux->busses = devm_kzalloc(&pdev->dev,
> -				   sizeof(mux->busses) * mux->pdata->bus_count,
> +				   sizeof(*mux->busses) * mux->pdata->bus_count,
>  				   GFP_KERNEL);
>  	if (!mux->busses) {
>  		dev_err(&pdev->dev, "Cannot allocate busses\n");

Good catch.

Acked-by: Jean Delvare <khali@linux-fr.org>

-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-08 19:32   ` Jean Delvare
  0 siblings, 0 replies; 8+ messages in thread
From: Jean Delvare @ 2013-01-08 19:32 UTC (permalink / raw)
  To: Laurent Navet
  Cc: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, ben-linux-elnMNo+KYs3YtjvyW6yDsg,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue,  8 Jan 2013 14:40:09 +0100, Laurent Navet wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
> 
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
> 
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
> 
> Signed-off-by: Laurent Navet <laurent.navet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/muxes/i2c-mux-pinctrl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> index 7fa5b24..f958d0f 100644
> --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
> @@ -167,7 +167,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
>  	}
>  
>  	mux->busses = devm_kzalloc(&pdev->dev,
> -				   sizeof(mux->busses) * mux->pdata->bus_count,
> +				   sizeof(*mux->busses) * mux->pdata->bus_count,
>  				   GFP_KERNEL);
>  	if (!mux->busses) {
>  		dev_err(&pdev->dev, "Cannot allocate busses\n");

Good catch.

Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>

-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-23  9:56   ` Wolfram Sang
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2013-01-23  9:56 UTC (permalink / raw)
  To: Laurent Navet; +Cc: ben-linux, khali, linux-i2c, linux-kernel

On Tue, Jan 08, 2013 at 02:40:09PM +0100, Laurent Navet wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
> 
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
> 
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>

Thanks, applied to for-current.

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

* Re: [PATCH] drivers: i2c: muxes: fix sizeof(ptr)
@ 2013-01-23  9:56   ` Wolfram Sang
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2013-01-23  9:56 UTC (permalink / raw)
  To: Laurent Navet
  Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg, khali-PUYAD+kWke1g9hUCZPvPmw,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Jan 08, 2013 at 02:40:09PM +0100, Laurent Navet wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer
> 
> The semantic patch that makes this output is available
> in scripts/coccinelle/misc/noderef.cocci.
> 
> More information about semantic patching is available at
> http://coccinelle.lip6.fr/
> 
> Signed-off-by: Laurent Navet <laurent.navet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Thanks, applied to for-current.

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

end of thread, other threads:[~2013-01-23  9:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-08 13:40 [PATCH] drivers: i2c: muxes: fix sizeof(ptr) Laurent Navet
2013-01-08 13:40 ` Laurent Navet
2013-01-08 14:43 ` Laurent Navet
2013-01-08 14:43   ` Laurent Navet
2013-01-08 19:32 ` Jean Delvare
2013-01-08 19:32   ` Jean Delvare
2013-01-23  9:56 ` Wolfram Sang
2013-01-23  9:56   ` Wolfram Sang

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.