Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-11 Thread walter harms


Am 11.08.2013 07:48, schrieb Julia Lawall:
> On Sun, 11 Aug 2013, Dan Carpenter wrote:
> 
>> ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
>> removed.  What I meant before was just that probably people will
>> probably complain if we try to remove it.
> 
> Well, I could either wait for someone to defend it, or send a patch 
> getting rid of it and see what happens...  I can't see what could go wrong 
> with
> 
> f(...,
> - ARRAY_AND_SIZE(e)
> + e, ARRAY_SIZE(e)
>   , ...)
> 
> so it should be an easy patch to create.
> 


if it is not to much work, send a patch to get rid of it.
It seems all agree that the disadvantages outweighs it
advantages.

just my 2 cents,
 wh


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-11 Thread walter harms


Am 11.08.2013 07:48, schrieb Julia Lawall:
 On Sun, 11 Aug 2013, Dan Carpenter wrote:
 
 ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
 removed.  What I meant before was just that probably people will
 probably complain if we try to remove it.
 
 Well, I could either wait for someone to defend it, or send a patch 
 getting rid of it and see what happens...  I can't see what could go wrong 
 with
 
 f(...,
 - ARRAY_AND_SIZE(e)
 + e, ARRAY_SIZE(e)
   , ...)
 
 so it should be an easy patch to create.
 


if it is not to much work, send a patch to get rid of it.
It seems all agree that the disadvantages outweighs it
advantages.

just my 2 cents,
 wh


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall
On Sun, 11 Aug 2013, Dan Carpenter wrote:

> ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
> removed.  What I meant before was just that probably people will
> probably complain if we try to remove it.

Well, I could either wait for someone to defend it, or send a patch 
getting rid of it and see what happens...  I can't see what could go wrong 
with

f(...,
- ARRAY_AND_SIZE(e)
+ e, ARRAY_SIZE(e)
  , ...)

so it should be an easy patch to create.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Dan Carpenter
ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
removed.  What I meant before was just that probably people will
probably complain if we try to remove it.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread walter harms


Am 10.08.2013 17:32, schrieb Joe Perches:
> On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
>> From: Julia Lawall 
>>
>> Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
>> used for one call to a given function, it would be better, if possible, to
>> use it for all of them.
> 
> I think it'd be better to remove ARRAY_AND_SIZE instead.
> 

+1

:)

re,
 wh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Joe Perches
On Sat, 2013-08-10 at 17:38 +0200, Julia Lawall wrote:
> On Sat, 10 Aug 2013, Joe Perches wrote:
> > On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
> > > From: Julia Lawall 
> > > Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
> > > used for one call to a given function, it would be better, if possible, to
> > > use it for all of them.
> > I think it'd be better to remove ARRAY_AND_SIZE instead.
> 
> I can do that, if it is wanted, but there are over 200 uses, and I think 
> it is a little bit positive in that it ensures that the array is passed 
> along with its own size.

Maybe, but if it's generally accepted that it's useful,
and I'm a little dubious because it does hide argument
count in functions where it's used, the 6 #defines should
be centralized in kernel.h

$ git grep "define.*ARRAY_AND_SIZE"
arch/arm/mach-kirkwood/common.h:#define ARRAY_AND_SIZE(x)   (x), 
ARRAY_SIZE(x)
arch/arm/mach-mmp/common.h:#define ARRAY_AND_SIZE(x)(x), ARRAY_SIZE(x)
arch/arm/mach-pxa/generic.h:#define ARRAY_AND_SIZE(x)   (x), ARRAY_SIZE(x)
arch/arm/mach-ux500/db8500-regs.h:#define ARRAY_AND_SIZE(x) (x), 
ARRAY_SIZE(x)
drivers/pinctrl/pinctrl-lantiq.h:#define ARRAY_AND_SIZE(x)  (x), 
ARRAY_SIZE(x)
sound/soc/pxa/mioa701_wm9713.c:#define ARRAY_AND_SIZE(x)(x), 
ARRAY_SIZE(x)

A small counter-argument against using ARRAY_AND_SIZE:

clkdev_add_table has 60+ uses, only 6 of those with
ARRAY_AND_SIZE.

I think it makes it difficult to do some cocinelle/spatch
transform on clkdev_add_table.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall


On Sat, 10 Aug 2013, Joe Perches wrote:

> On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
> > From: Julia Lawall 
> > 
> > Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
> > used for one call to a given function, it would be better, if possible, to
> > use it for all of them.
> 
> I think it'd be better to remove ARRAY_AND_SIZE instead.

I can do that, if it is wanted, but there are over 200 uses, and I think 
it is a little bit positive in that it ensures that the array is passed 
along with its own size.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Joe Perches
On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
> From: Julia Lawall 
> 
> Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
> used for one call to a given function, it would be better, if possible, to
> use it for all of them.

I think it'd be better to remove ARRAY_AND_SIZE instead.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall
From: Julia Lawall 

Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
used for one call to a given function, it would be better, if possible, to
use it for all of them.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// 
@call@
identifier f;
expression e;
expression list[n] es;
@@

f(es,ARRAY_AND_SIZE(e),...)

@@
expression e;
identifier call.f;
expression list[call.n] ess;
@@

f(ess,
- e,ARRAY_SIZE(e)
+ ARRAY_AND_SIZE(e)
  ,...)
// 

Signed-off-by: Julia Lawall 

---
 arch/arm/mach-pxa/stargate2.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 62aea3e..ee7a42e 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -608,12 +608,10 @@ static void __init imote2_init(void)
 
imote2_stargate2_init();
 
-   platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
+   platform_add_devices(ARRAY_AND_SIZE(imote2_devices));
 
-   i2c_register_board_info(0, imote2_i2c_board_info,
-   ARRAY_SIZE(imote2_i2c_board_info));
-   i2c_register_board_info(1, imote2_pwr_i2c_board_info,
-   ARRAY_SIZE(imote2_pwr_i2c_board_info));
+   i2c_register_board_info(0, ARRAY_AND_SIZE(imote2_i2c_board_info));
+   i2c_register_board_info(1, ARRAY_AND_SIZE(imote2_pwr_i2c_board_info));
 
pxa_set_mci_info(_mci_platform_data);
pxa_set_udc_info(_udc_info);
@@ -990,8 +988,7 @@ static void __init stargate2_init(void)
platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
 
i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
-   i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
-   ARRAY_SIZE(stargate2_pwr_i2c_board_info));
+   i2c_register_board_info(1, 
ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info));
 
pxa_set_mci_info(_mci_platform_data);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
used for one call to a given function, it would be better, if possible, to
use it for all of them.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@call@
identifier f;
expression e;
expression list[n] es;
@@

f(es,ARRAY_AND_SIZE(e),...)

@@
expression e;
identifier call.f;
expression list[call.n] ess;
@@

f(ess,
- e,ARRAY_SIZE(e)
+ ARRAY_AND_SIZE(e)
  ,...)
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 arch/arm/mach-pxa/stargate2.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 62aea3e..ee7a42e 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -608,12 +608,10 @@ static void __init imote2_init(void)
 
imote2_stargate2_init();
 
-   platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
+   platform_add_devices(ARRAY_AND_SIZE(imote2_devices));
 
-   i2c_register_board_info(0, imote2_i2c_board_info,
-   ARRAY_SIZE(imote2_i2c_board_info));
-   i2c_register_board_info(1, imote2_pwr_i2c_board_info,
-   ARRAY_SIZE(imote2_pwr_i2c_board_info));
+   i2c_register_board_info(0, ARRAY_AND_SIZE(imote2_i2c_board_info));
+   i2c_register_board_info(1, ARRAY_AND_SIZE(imote2_pwr_i2c_board_info));
 
pxa_set_mci_info(imote2_mci_platform_data);
pxa_set_udc_info(imote2_udc_info);
@@ -990,8 +988,7 @@ static void __init stargate2_init(void)
platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
 
i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
-   i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
-   ARRAY_SIZE(stargate2_pwr_i2c_board_info));
+   i2c_register_board_info(1, 
ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info));
 
pxa_set_mci_info(stargate2_mci_platform_data);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Joe Perches
On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
 From: Julia Lawall julia.law...@lip6.fr
 
 Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
 used for one call to a given function, it would be better, if possible, to
 use it for all of them.

I think it'd be better to remove ARRAY_AND_SIZE instead.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall


On Sat, 10 Aug 2013, Joe Perches wrote:

 On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
  From: Julia Lawall julia.law...@lip6.fr
  
  Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
  used for one call to a given function, it would be better, if possible, to
  use it for all of them.
 
 I think it'd be better to remove ARRAY_AND_SIZE instead.

I can do that, if it is wanted, but there are over 200 uses, and I think 
it is a little bit positive in that it ensures that the array is passed 
along with its own size.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Joe Perches
On Sat, 2013-08-10 at 17:38 +0200, Julia Lawall wrote:
 On Sat, 10 Aug 2013, Joe Perches wrote:
  On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
   From: Julia Lawall julia.law...@lip6.fr
   Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
   used for one call to a given function, it would be better, if possible, to
   use it for all of them.
  I think it'd be better to remove ARRAY_AND_SIZE instead.
 
 I can do that, if it is wanted, but there are over 200 uses, and I think 
 it is a little bit positive in that it ensures that the array is passed 
 along with its own size.

Maybe, but if it's generally accepted that it's useful,
and I'm a little dubious because it does hide argument
count in functions where it's used, the 6 #defines should
be centralized in kernel.h

$ git grep define.*ARRAY_AND_SIZE
arch/arm/mach-kirkwood/common.h:#define ARRAY_AND_SIZE(x)   (x), 
ARRAY_SIZE(x)
arch/arm/mach-mmp/common.h:#define ARRAY_AND_SIZE(x)(x), ARRAY_SIZE(x)
arch/arm/mach-pxa/generic.h:#define ARRAY_AND_SIZE(x)   (x), ARRAY_SIZE(x)
arch/arm/mach-ux500/db8500-regs.h:#define ARRAY_AND_SIZE(x) (x), 
ARRAY_SIZE(x)
drivers/pinctrl/pinctrl-lantiq.h:#define ARRAY_AND_SIZE(x)  (x), 
ARRAY_SIZE(x)
sound/soc/pxa/mioa701_wm9713.c:#define ARRAY_AND_SIZE(x)(x), 
ARRAY_SIZE(x)

A small counter-argument against using ARRAY_AND_SIZE:

clkdev_add_table has 60+ uses, only 6 of those with
ARRAY_AND_SIZE.

I think it makes it difficult to do some cocinelle/spatch
transform on clkdev_add_table.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread walter harms


Am 10.08.2013 17:32, schrieb Joe Perches:
 On Sat, 2013-08-10 at 17:25 +0200, Julia Lawall wrote:
 From: Julia Lawall julia.law...@lip6.fr

 Because ARRAY_AND_SIZE changes the apparent arity of a function, if it is
 used for one call to a given function, it would be better, if possible, to
 use it for all of them.
 
 I think it'd be better to remove ARRAY_AND_SIZE instead.
 

+1

:)

re,
 wh
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Dan Carpenter
ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
removed.  What I meant before was just that probably people will
probably complain if we try to remove it.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arch/arm/mach-pxa/stargate2.c: use ARRAY_AND_SIZE consistently

2013-08-10 Thread Julia Lawall
On Sun, 11 Aug 2013, Dan Carpenter wrote:

 ARRAY_AND_SIZE() macro is horrible, and I would like it if it were
 removed.  What I meant before was just that probably people will
 probably complain if we try to remove it.

Well, I could either wait for someone to defend it, or send a patch 
getting rid of it and see what happens...  I can't see what could go wrong 
with

f(...,
- ARRAY_AND_SIZE(e)
+ e, ARRAY_SIZE(e)
  , ...)

so it should be an easy patch to create.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/