Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-16 Thread David Miller
From: Denis Cheng <[EMAIL PROTECTED]>
Date: Sun,  2 Sep 2007 12:59:07 +0800

> Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>

Applied to net-2.6.24, thanks!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-16 Thread David Miller
From: Denis Cheng [EMAIL PROTECTED]
Date: Sun,  2 Sep 2007 12:59:07 +0800

 Signed-off-by: Denis Cheng [EMAIL PROTECTED]

Applied to net-2.6.24, thanks!
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-02 Thread Robert P. J. Day
On Sun, 2 Sep 2007, rae l wrote:

> On 9/2/07, Robert P. J. Day <[EMAIL PROTECTED]> wrote:

> > denis:
> >
> > if you're planning on doing this ARRAY_SIZE cleanup fairly
> > rigorously, here's an overview of what you're looking (based on a
> > fairly dumb scanning script that undoubtedly generates some false
> > positives).  of course, the respective subsystem maintainers are
> > welcome to deal with them first, of course.
> >
> > p.s.  and when you submit those patches, it's necessary to submit
> > them to only the appropriate subsystem mailing lists, not to the
> > LKML in general.

> I didn't realize that there's so many places to switch to
> ARRAY_SIZE, so now I wonder is this cleaning work valuable to the
> whole kernel tree? or we can keep the current state and just
> encourage new code to use ARRAY_SIZE?

that is *so* not my call.  i just thought that, if you were about to
embark on this clean-up, you knew what was ahead of you.  if you're
still interested in doing it, my best advice is to do it a subsystem
at a time, and submit the patches just to those subsystems or the
appropriate maintainers, rather than to the whole LKML, in order to
keep the traffic down.

and i'd encourage you to keep working on this.  and if you have any
more general questions, you're better off asking on the kernel
janitors list, not LKML.

http://kerneljanitors.org/

rday
-- 

Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca

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


Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-02 Thread rae l
On 9/2/07, Robert P. J. Day <[EMAIL PROTECTED]> wrote:
> On Sun, 2 Sep 2007, Denis Cheng wrote:
>
> > Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
> > ---
> >  net/ipv4/af_inet.c |2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> > index e681034..d5e8b67 100644
> > --- a/net/ipv4/af_inet.c
> > +++ b/net/ipv4/af_inet.c
> > @@ -939,7 +939,7 @@ static struct inet_protosw inetsw_array[] =
> > }
> >  };
> >
> > -#define INETSW_ARRAY_LEN (sizeof(inetsw_array) / sizeof(struct 
> > inet_protosw))
> > +#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array)
> >
> >  void inet_register_protosw(struct inet_protosw *p)
> >  {
>
> denis:
>
> if you're planning on doing this ARRAY_SIZE cleanup fairly rigorously,
> here's an overview of what you're looking (based on a fairly dumb
> scanning script that undoubtedly generates some false positives).  of
> course, the respective subsystem maintainers are welcome to deal with
> them first, of course.
>
> p.s.  and when you submit those patches, it's necessary to submit them
> to only the appropriate subsystem mailing lists, not to the LKML in
> general.
I didn't realize that there's so many places to switch to ARRAY_SIZE,
so now I wonder is this cleaning work valuable to the whole kernel tree?
or we can keep the current state and just encourage new code to use ARRAY_SIZE?

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


Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-01 Thread Robert P. J. Day
On Sun, 2 Sep 2007, Denis Cheng wrote:

> Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
> ---
>  net/ipv4/af_inet.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index e681034..d5e8b67 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -939,7 +939,7 @@ static struct inet_protosw inetsw_array[] =
> }
>  };
>
> -#define INETSW_ARRAY_LEN (sizeof(inetsw_array) / sizeof(struct inet_protosw))
> +#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array)
>
>  void inet_register_protosw(struct inet_protosw *p)
>  {

denis:

if you're planning on doing this ARRAY_SIZE cleanup fairly rigorously,
here's an overview of what you're looking (based on a fairly dumb
scanning script that undoubtedly generates some false positives).  of
course, the respective subsystem maintainers are welcome to deal with
them first, of course.

p.s.  and when you submit those patches, it's necessary to submit them
to only the appropriate subsystem mailing lists, not to the LKML in
general.


= Where ARRAY_SIZE() might be used ...

./Documentation/CodingStyle:  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./Documentation/hpet.txt:   for (i = 0; i < (sizeof (hpet_command) / sizeof 
(hpet_command[0])); i++)
./Documentation/spi/spidev_test.c:#define ARRAY_SIZE(a) (sizeof(a) / 
sizeof((a)[0]))
./include/acpi/acmacros.h:#define ACPI_ARRAY_LENGTH(x)(sizeof(x) / 
sizeof((x)[0]))
./include/linux/netfilter/xt_sctp.h:#define ELEMCOUNT(x) 
(sizeof(x)/sizeof(x[0]))
./include/linux/kernel.h:#define ARRAY_SIZE(arr) (sizeof(arr) / 
sizeof((arr)[0]) + __must_be_array(arr))
./include/asm-parisc/mmzone.h:  BUG_ON(i >= sizeof(pfnnid_map) / 
sizeof(pfnnid_map[0]));
./include/asm-sh/hw_irq.h:#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
./include/video/sgivw.h:#define DBE_VT_SIZE  
(sizeof(dbeVTimings)/sizeof(dbeVTimings[0]))
./include/net/ip_vs.h:#define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, 
sizeof(t)/sizeof(t[0]))
./kernel/compat.c:  for (j = 0; j < sizeof(m)/sizeof(um); j++) {
./kernel/compat.c:  for (j = 0; j < sizeof(m)/sizeof(um); j++) {
./arch/m68k/amiga/amisound.c:#define DATA_SIZE  
(sizeof(sine_data)/sizeof(sine_data[0]))
./arch/i386/boot/compressed/relocs.c:#define ARRAY_SIZE(x) (sizeof(x) / 
sizeof((x)[0]))
./arch/x86_64/kernel/smpboot.c: for (i = 0; i < sizeof(regs) / sizeof(*regs); 
i++) {
./arch/mips/au1000/common/dbdma.c:#define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / 
sizeof(dbdev_tab_t))
./arch/cris/arch-v10/kernel/setup.c:if (revision >= sizeof cpu_info/sizeof 
*cpu_info)
./arch/cris/arch-v10/kernel/setup.c:info = _info[sizeof 
cpu_info/sizeof *cpu_info - 1];
./arch/um/include/user.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i < 
sizeof(regs)/sizeof(regs[0]); i++)
./arch/arm/kernel/dma-isa.c:for (i = 0; i < sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
./arch/avr32/mach-at32ap/time-tc.c: int divs_size = sizeof(divs) / 
sizeof(*divs);
./arch/powerpc/platforms/celleb/scc_sio.c:  for(i = 0; i < 
sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
./arch/powerpc/boot/types.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./scripts/mod/file2alias.c:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./drivers/char/synclink_gt.c:   static unsigned int count = 
sizeof(patterns)/sizeof(patterns[0]);
./drivers/mtd/nand/excite_nandflash.c: sizeof 
partition_info / sizeof partition_info[0]);
./drivers/message/fusion/mptbase.c: if (u16cnt < 
sizeof(ioc->hs_reply) / sizeof(ioc->hs_reply[0]))
./drivers/serial/mcfserial.c:   
(sizeof(mcfrs_baud_table)/sizeof(mcfrs_baud_table[0]))
./drivers/serial/68328serial.c:#define BAUD_TABLE_SIZE 
(sizeof(baud_table)/sizeof(baud_table[0]))
./drivers/serial/68328serial.c: for (i = 0; i < sizeof(baud_table) / 
sizeof(baud_table[0]); i++)
./drivers/serial/68328serial.c: if (i >= sizeof(baud_table) / 
sizeof(baud_table[0])) {
./drivers/zorro/names.c:#define MANUF( manuf, name ){ 0x##manuf, 
sizeof(__prods_##manuf) / sizeof(struct zorro_prod_info), __manufstr_##manuf, 
__prods_##manuf },
./drivers/media/video/saa7134/saa7134-tvaudio.c:#define TVAUDIO 
(sizeof(tvaudio)/sizeof(struct saa7134_tvaudio))
./drivers/media/video/tveeprom.c:#define STRM(array,i) (i < 
sizeof(array)/sizeof(char*) ? array[i] : 

[PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-01 Thread Denis Cheng
Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
---
 net/ipv4/af_inet.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index e681034..d5e8b67 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -939,7 +939,7 @@ static struct inet_protosw inetsw_array[] =
}
 };
 
-#define INETSW_ARRAY_LEN (sizeof(inetsw_array) / sizeof(struct inet_protosw))
+#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array)
 
 void inet_register_protosw(struct inet_protosw *p)
 {
-- 
1.5.3.rc7

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


[PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-01 Thread Denis Cheng
Signed-off-by: Denis Cheng [EMAIL PROTECTED]
---
 net/ipv4/af_inet.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index e681034..d5e8b67 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -939,7 +939,7 @@ static struct inet_protosw inetsw_array[] =
}
 };
 
-#define INETSW_ARRAY_LEN (sizeof(inetsw_array) / sizeof(struct inet_protosw))
+#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array)
 
 void inet_register_protosw(struct inet_protosw *p)
 {
-- 
1.5.3.rc7

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


Re: [PATCH] net/ipv4/af_inet.c: use ARRAY_SIZE macro from kernel.h instead

2007-09-01 Thread Robert P. J. Day
On Sun, 2 Sep 2007, Denis Cheng wrote:

 Signed-off-by: Denis Cheng [EMAIL PROTECTED]
 ---
  net/ipv4/af_inet.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
 index e681034..d5e8b67 100644
 --- a/net/ipv4/af_inet.c
 +++ b/net/ipv4/af_inet.c
 @@ -939,7 +939,7 @@ static struct inet_protosw inetsw_array[] =
 }
  };

 -#define INETSW_ARRAY_LEN (sizeof(inetsw_array) / sizeof(struct inet_protosw))
 +#define INETSW_ARRAY_LEN ARRAY_SIZE(inetsw_array)

  void inet_register_protosw(struct inet_protosw *p)
  {

denis:

if you're planning on doing this ARRAY_SIZE cleanup fairly rigorously,
here's an overview of what you're looking (based on a fairly dumb
scanning script that undoubtedly generates some false positives).  of
course, the respective subsystem maintainers are welcome to deal with
them first, of course.

p.s.  and when you submit those patches, it's necessary to submit them
to only the appropriate subsystem mailing lists, not to the LKML in
general.


= Where ARRAY_SIZE() might be used ...

./Documentation/CodingStyle:  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./Documentation/hpet.txt:   for (i = 0; i  (sizeof (hpet_command) / sizeof 
(hpet_command[0])); i++)
./Documentation/spi/spidev_test.c:#define ARRAY_SIZE(a) (sizeof(a) / 
sizeof((a)[0]))
./include/acpi/acmacros.h:#define ACPI_ARRAY_LENGTH(x)(sizeof(x) / 
sizeof((x)[0]))
./include/linux/netfilter/xt_sctp.h:#define ELEMCOUNT(x) 
(sizeof(x)/sizeof(x[0]))
./include/linux/kernel.h:#define ARRAY_SIZE(arr) (sizeof(arr) / 
sizeof((arr)[0]) + __must_be_array(arr))
./include/asm-parisc/mmzone.h:  BUG_ON(i = sizeof(pfnnid_map) / 
sizeof(pfnnid_map[0]));
./include/asm-sh/hw_irq.h:#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
./include/video/sgivw.h:#define DBE_VT_SIZE  
(sizeof(dbeVTimings)/sizeof(dbeVTimings[0]))
./include/net/ip_vs.h:#define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, 
sizeof(t)/sizeof(t[0]))
./kernel/compat.c:  for (j = 0; j  sizeof(m)/sizeof(um); j++) {
./kernel/compat.c:  for (j = 0; j  sizeof(m)/sizeof(um); j++) {
./arch/m68k/amiga/amisound.c:#define DATA_SIZE  
(sizeof(sine_data)/sizeof(sine_data[0]))
./arch/i386/boot/compressed/relocs.c:#define ARRAY_SIZE(x) (sizeof(x) / 
sizeof((x)[0]))
./arch/x86_64/kernel/smpboot.c: for (i = 0; i  sizeof(regs) / sizeof(*regs); 
i++) {
./arch/mips/au1000/common/dbdma.c:#define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / 
sizeof(dbdev_tab_t))
./arch/cris/arch-v10/kernel/setup.c:if (revision = sizeof cpu_info/sizeof 
*cpu_info)
./arch/cris/arch-v10/kernel/setup.c:info = cpu_info[sizeof 
cpu_info/sizeof *cpu_info - 1];
./arch/um/include/user.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/um/kernel/tt/ptproxy/ptrace.c:   for (i = 0; i  
sizeof(regs)/sizeof(regs[0]); i++)
./arch/arm/kernel/dma-isa.c:for (i = 0; i  sizeof(dma_resources) / 
sizeof(dma_resources[0]); i++)
./arch/avr32/mach-at32ap/time-tc.c: int divs_size = sizeof(divs) / 
sizeof(*divs);
./arch/powerpc/platforms/celleb/scc_sio.c:  for(i = 0; i  
sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
./arch/powerpc/boot/types.h:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./scripts/mod/file2alias.c:#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
./drivers/char/synclink_gt.c:   static unsigned int count = 
sizeof(patterns)/sizeof(patterns[0]);
./drivers/mtd/nand/excite_nandflash.c: sizeof 
partition_info / sizeof partition_info[0]);
./drivers/message/fusion/mptbase.c: if (u16cnt  
sizeof(ioc-hs_reply) / sizeof(ioc-hs_reply[0]))
./drivers/serial/mcfserial.c:   
(sizeof(mcfrs_baud_table)/sizeof(mcfrs_baud_table[0]))
./drivers/serial/68328serial.c:#define BAUD_TABLE_SIZE 
(sizeof(baud_table)/sizeof(baud_table[0]))
./drivers/serial/68328serial.c: for (i = 0; i  sizeof(baud_table) / 
sizeof(baud_table[0]); i++)
./drivers/serial/68328serial.c: if (i = sizeof(baud_table) / 
sizeof(baud_table[0])) {
./drivers/zorro/names.c:#define MANUF( manuf, name ){ 0x##manuf, 
sizeof(__prods_##manuf) / sizeof(struct zorro_prod_info), __manufstr_##manuf, 
__prods_##manuf },
./drivers/media/video/saa7134/saa7134-tvaudio.c:#define TVAUDIO 
(sizeof(tvaudio)/sizeof(struct saa7134_tvaudio))
./drivers/media/video/tveeprom.c:#define STRM(array,i) (i  
sizeof(array)/sizeof(char*) ? array[i] : unknown)
./drivers/media/video/mxb.c: