Re: [PATCH] removes array_size duplicates
On Mon, 1 Oct 2007, Robert P. J. Day wrote: ... > among other things, one of the creepy issues here is the definition in > include/linux/netfilter/xt_sctp.h of the macro: > > ... > #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ > do {\ > int i; \ > for (i = 0; i < ELEMCOUNT(chunkmap); i++) \ srcmap?? > destmap[i] = srcmap[i]; \ > } while (0) > ... > whoops, i take it back ... isn't this just a flat-out error, where the macro should be written with the correction above? 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] removes array_size duplicates
On Mon, 1 Oct 2007, Andrew Morton wrote: > On Fri, 28 Sep 2007 00:51:13 +0200 roel <[EMAIL PROTECTED]> wrote: > > > This patch removes some ARRAY_SIZE macro duplicates. There is also one in > > arch/um/include/user.h, which isn't fixed here because comments in that file > > explicitly state a preference for the 'less fancy' version. If that's the > > case as well for any of the other replacements please comment. > > I got a bunch of rejects against various development trees, a > build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now > > net/netfilter/xt_sctp.c: In function 'match_packet': > net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative > net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative among other things, one of the creepy issues here is the definition in include/linux/netfilter/xt_sctp.h of the macro: ... #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ do {\ int i; \ for (i = 0; i < ELEMCOUNT(chunkmap); i++) \ destmap[i] = srcmap[i]; \ } while (0) ... i'm not a big fan of macros that refer to objects that aren't parameters to the macro, especially when all the rest of them *do*. rday p.s. ELEMCOUNT is simply an alternative to ARRAY_SIZE, which could certainly be rewritten that way. -- 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] removes array_size duplicates
On Mon, 1 Oct 2007 11:33:01 +0200 (CEST) Geert Uytterhoeven <[EMAIL PROTECTED]> wrote: > On Mon, 1 Oct 2007, Andrew Morton wrote: > > On Fri, 28 Sep 2007 00:51:13 +0200 roel <[EMAIL PROTECTED]> wrote: > > > This patch removes some ARRAY_SIZE macro duplicates. There is also one in > > > arch/um/include/user.h, which isn't fixed here because comments in that > > > file > > > explicitly state a preference for the 'less fancy' version. If that's the > > > case as well for any of the other replacements please comment. > > > > I got a bunch of rejects against various development trees, a > > build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now > > > > net/netfilter/xt_sctp.c: In function 'match_packet': > > net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative > > net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative > > However, arch/m68k/amiga/amisound.c: > Acked-by: Geert Uytterhoeven <[EMAIL PROTECTED]> > Well yes. If the change had been split up into separate per-subsystem patches I wouldn't have needed to drop the whole lot. Hint. - 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] removes array_size duplicates
On Mon, 1 Oct 2007, Andrew Morton wrote: > On Fri, 28 Sep 2007 00:51:13 +0200 roel <[EMAIL PROTECTED]> wrote: > > This patch removes some ARRAY_SIZE macro duplicates. There is also one in > > arch/um/include/user.h, which isn't fixed here because comments in that file > > explicitly state a preference for the 'less fancy' version. If that's the > > case as well for any of the other replacements please comment. > > I got a bunch of rejects against various development trees, a > build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now > > net/netfilter/xt_sctp.c: In function 'match_packet': > net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative > net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative However, arch/m68k/amiga/amisound.c: Acked-by: Geert Uytterhoeven <[EMAIL PROTECTED]> Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [EMAIL PROTECTED] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds - 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] removes array_size duplicates
On Fri, 28 Sep 2007 00:51:13 +0200 roel <[EMAIL PROTECTED]> wrote: > This patch removes some ARRAY_SIZE macro duplicates. There is also one in > arch/um/include/user.h, which isn't fixed here because comments in that file > explicitly state a preference for the 'less fancy' version. If that's the > case as well for any of the other replacements please comment. I got a bunch of rejects against various development trees, a build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now net/netfilter/xt_sctp.c: In function 'match_packet': net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative - 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] removes array_size duplicates
On Fri, 28 Sep 2007 00:51:13 +0200 roel [EMAIL PROTECTED] wrote: This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. I got a bunch of rejects against various development trees, a build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now net/netfilter/xt_sctp.c: In function 'match_packet': net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative - 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] removes array_size duplicates
On Mon, 1 Oct 2007, Andrew Morton wrote: On Fri, 28 Sep 2007 00:51:13 +0200 roel [EMAIL PROTECTED] wrote: This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. I got a bunch of rejects against various development trees, a build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now net/netfilter/xt_sctp.c: In function 'match_packet': net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative However, arch/m68k/amiga/amisound.c: Acked-by: Geert Uytterhoeven [EMAIL PROTECTED] Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [EMAIL PROTECTED] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds - 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] removes array_size duplicates
On Mon, 1 Oct 2007 11:33:01 +0200 (CEST) Geert Uytterhoeven [EMAIL PROTECTED] wrote: On Mon, 1 Oct 2007, Andrew Morton wrote: On Fri, 28 Sep 2007 00:51:13 +0200 roel [EMAIL PROTECTED] wrote: This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. I got a bunch of rejects against various development trees, a build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now net/netfilter/xt_sctp.c: In function 'match_packet': net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative However, arch/m68k/amiga/amisound.c: Acked-by: Geert Uytterhoeven [EMAIL PROTECTED] Well yes. If the change had been split up into separate per-subsystem patches I wouldn't have needed to drop the whole lot. Hint. - 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] removes array_size duplicates
On Mon, 1 Oct 2007, Andrew Morton wrote: On Fri, 28 Sep 2007 00:51:13 +0200 roel [EMAIL PROTECTED] wrote: This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. I got a bunch of rejects against various development trees, a build error in net/ipv4/ipvs/ip_vs_proto_udp.c and now net/netfilter/xt_sctp.c: In function 'match_packet': net/netfilter/xt_sctp.c:58: error: size of array 'type name' is negative net/netfilter/xt_sctp.c:106: error: size of array 'type name' is negative among other things, one of the creepy issues here is the definition in include/linux/netfilter/xt_sctp.h of the macro: ... #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ do {\ int i; \ for (i = 0; i ELEMCOUNT(chunkmap); i++) \ destmap[i] = srcmap[i]; \ } while (0) ... i'm not a big fan of macros that refer to objects that aren't parameters to the macro, especially when all the rest of them *do*. rday p.s. ELEMCOUNT is simply an alternative to ARRAY_SIZE, which could certainly be rewritten that way. -- 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] removes array_size duplicates
On Mon, 1 Oct 2007, Robert P. J. Day wrote: ... among other things, one of the creepy issues here is the definition in include/linux/netfilter/xt_sctp.h of the macro: ... #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ do {\ int i; \ for (i = 0; i ELEMCOUNT(chunkmap); i++) \ srcmap?? destmap[i] = srcmap[i]; \ } while (0) ... whoops, i take it back ... isn't this just a flat-out error, where the macro should be written with the correction above? 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/
[PATCH] removes array_size duplicates
This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- Documentation/spi/spidev_test.c|2 -- arch/i386/boot/compressed/relocs.c |1 - arch/m68k/amiga/amisound.c |3 +-- arch/powerpc/boot/types.h |2 -- arch/sparc64/kernel/pci.c |6 ++ drivers/acpi/utilities/uteval.c|4 ++-- drivers/net/irda/actisys-sir.c |6 ++ drivers/net/lp486e.c |4 +--- drivers/net/sk98lin/skgemib.c |5 - drivers/net/skfp/smt.c |4 +--- drivers/net/skfp/srf.c | 18 +++--- drivers/net/wireless/ipw2100.c | 13 - drivers/serial/68328serial.c |6 ++ drivers/video/sgivwfb.c|4 ++-- include/acpi/acmacros.h|2 -- include/linux/netfilter/xt_sctp.h | 12 +--- include/net/ip_vs.h|1 - include/video/sgivw.h |1 - net/ipv4/ipvs/ip_vs_proto_tcp.c|2 +- scripts/mod/file2alias.c |2 -- 20 files changed, 30 insertions(+), 68 deletions(-) diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c index 218e862..0f23aac 100644 --- a/Documentation/spi/spidev_test.c +++ b/Documentation/spi/spidev_test.c @@ -21,8 +21,6 @@ #include #include -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - static void pabort(const char *s) { perror(s); diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c index 2d77ee7..5d8dbff 100644 --- a/arch/i386/boot/compressed/relocs.c +++ b/arch/i386/boot/compressed/relocs.c @@ -11,7 +11,6 @@ #include #define MAX_SHDRS 100 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) static Elf32_Ehdr ehdr; static Elf32_Shdr shdr[MAX_SHDRS]; static Elf32_Sym *symtab[MAX_SHDRS]; diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c index 1f5bfb5..8d013a1 100644 --- a/arch/m68k/amiga/amisound.c +++ b/arch/m68k/amiga/amisound.c @@ -21,7 +21,6 @@ static const signed char sine_data[] = { 0, 39, 75, 103, 121, 127, 121, 103, 75, 39, 0, -39, -75, -103, -121, -127, -121, -103, -75, -39 }; -#define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0])) #define custom amiga_custom @@ -55,7 +54,7 @@ void __init amiga_init_sound(void) memcpy (snd_data, sine_data, sizeof(sine_data)); /* setup divisor */ - clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE; + clock_constant = (amiga_colorclock + ARRAY_SIZE(sine_data) /2) / ARRAY_SIZE(sine_data); /* without amifb, turn video off and enable high quality sound */ #ifndef CONFIG_FB_AMIGA diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h index 31393d1..733622a 100644 --- a/arch/powerpc/boot/types.h +++ b/arch/powerpc/boot/types.h @@ -1,8 +1,6 @@ #ifndef _TYPES_H_ #define _TYPES_H_ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index e8dac81..5c8c433 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c @@ -209,14 +209,12 @@ static struct { { "SUNW,sun4v-pci", sun4v_pci_init }, { "pciex108e,80f0", fire_pci_init }, }; -#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \ - sizeof(pci_controller_table[0])) static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp) { int i; - for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) { + for (i = 0; i < ARRAY_SIZE(pci_controller_table); i++) { if (!strncmp(model_name, pci_controller_table[i].model_name, namelen)) { @@ -232,7 +230,7 @@ static int __init pci_is_controller(const char *model_name, int namelen, struct { int i; - for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) { + for (i = 0; i < ARRAY_SIZE(pci_controller_table); i++) { if (!strncmp(model_name, pci_controller_table[i].model_name, namelen)) { diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 0042b7e..5da86d5 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -122,7 +122,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) /* Compare input string to static table of supported interfaces */ - for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { +
[PATCH] removes array_size duplicates
This patch removes some ARRAY_SIZE macro duplicates. There is also one in arch/um/include/user.h, which isn't fixed here because comments in that file explicitly state a preference for the 'less fancy' version. If that's the case as well for any of the other replacements please comment. Signed-off-by: Roel Kluin [EMAIL PROTECTED] --- Documentation/spi/spidev_test.c|2 -- arch/i386/boot/compressed/relocs.c |1 - arch/m68k/amiga/amisound.c |3 +-- arch/powerpc/boot/types.h |2 -- arch/sparc64/kernel/pci.c |6 ++ drivers/acpi/utilities/uteval.c|4 ++-- drivers/net/irda/actisys-sir.c |6 ++ drivers/net/lp486e.c |4 +--- drivers/net/sk98lin/skgemib.c |5 - drivers/net/skfp/smt.c |4 +--- drivers/net/skfp/srf.c | 18 +++--- drivers/net/wireless/ipw2100.c | 13 - drivers/serial/68328serial.c |6 ++ drivers/video/sgivwfb.c|4 ++-- include/acpi/acmacros.h|2 -- include/linux/netfilter/xt_sctp.h | 12 +--- include/net/ip_vs.h|1 - include/video/sgivw.h |1 - net/ipv4/ipvs/ip_vs_proto_tcp.c|2 +- scripts/mod/file2alias.c |2 -- 20 files changed, 30 insertions(+), 68 deletions(-) diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c index 218e862..0f23aac 100644 --- a/Documentation/spi/spidev_test.c +++ b/Documentation/spi/spidev_test.c @@ -21,8 +21,6 @@ #include linux/types.h #include linux/spi/spidev.h -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - static void pabort(const char *s) { perror(s); diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c index 2d77ee7..5d8dbff 100644 --- a/arch/i386/boot/compressed/relocs.c +++ b/arch/i386/boot/compressed/relocs.c @@ -11,7 +11,6 @@ #include endian.h #define MAX_SHDRS 100 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) static Elf32_Ehdr ehdr; static Elf32_Shdr shdr[MAX_SHDRS]; static Elf32_Sym *symtab[MAX_SHDRS]; diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c index 1f5bfb5..8d013a1 100644 --- a/arch/m68k/amiga/amisound.c +++ b/arch/m68k/amiga/amisound.c @@ -21,7 +21,6 @@ static const signed char sine_data[] = { 0, 39, 75, 103, 121, 127, 121, 103, 75, 39, 0, -39, -75, -103, -121, -127, -121, -103, -75, -39 }; -#define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0])) #define custom amiga_custom @@ -55,7 +54,7 @@ void __init amiga_init_sound(void) memcpy (snd_data, sine_data, sizeof(sine_data)); /* setup divisor */ - clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE; + clock_constant = (amiga_colorclock + ARRAY_SIZE(sine_data) /2) / ARRAY_SIZE(sine_data); /* without amifb, turn video off and enable high quality sound */ #ifndef CONFIG_FB_AMIGA diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h index 31393d1..733622a 100644 --- a/arch/powerpc/boot/types.h +++ b/arch/powerpc/boot/types.h @@ -1,8 +1,6 @@ #ifndef _TYPES_H_ #define _TYPES_H_ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index e8dac81..5c8c433 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c @@ -209,14 +209,12 @@ static struct { { SUNW,sun4v-pci, sun4v_pci_init }, { pciex108e,80f0, fire_pci_init }, }; -#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \ - sizeof(pci_controller_table[0])) static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp) { int i; - for (i = 0; i PCI_NUM_CONTROLLER_TYPES; i++) { + for (i = 0; i ARRAY_SIZE(pci_controller_table); i++) { if (!strncmp(model_name, pci_controller_table[i].model_name, namelen)) { @@ -232,7 +230,7 @@ static int __init pci_is_controller(const char *model_name, int namelen, struct { int i; - for (i = 0; i PCI_NUM_CONTROLLER_TYPES; i++) { + for (i = 0; i ARRAY_SIZE(pci_controller_table); i++) { if (!strncmp(model_name, pci_controller_table[i].model_name, namelen)) { diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 0042b7e..5da86d5 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -122,7 +122,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) /* Compare input string to static table of supported interfaces */ - for (i = 0; i