mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] zorro: use ARRAY_SIZE
@ 2014-06-16 20:10 Himangi Saraogi
  2014-06-23  8:40 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-06-16 20:10 UTC (permalink / raw)
  To: Geert Uytterhoeven, linux-m68k, linux-kernel; +Cc: julia.lawall

ARRAY_SIZE is more concise to use when the size of an array is divided
by the size of its type or the size of its first element.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
// </smpl>


Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 drivers/zorro/names.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/zorro/names.c b/drivers/zorro/names.c
index 6f3fd99..4ccbcc9 100644
--- a/drivers/zorro/names.c
+++ b/drivers/zorro/names.c
@@ -52,7 +52,7 @@ static struct zorro_manuf_info __initdata zorro_manuf_list[] = {
 #include "devlist.h"
 };
 
-#define MANUFS (sizeof(zorro_manuf_list)/sizeof(struct zorro_manuf_info))
+#define MANUFS ARRAY_SIZE(zorro_manuf_list)
 
 void __init zorro_name_device(struct zorro_dev *dev)
 {
-- 
1.9.1


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

* Re: [PATCH] zorro: use ARRAY_SIZE
  2014-06-16 20:10 [PATCH] zorro: use ARRAY_SIZE Himangi Saraogi
@ 2014-06-23  8:40 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2014-06-23  8:40 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-m68k, linux-kernel, Julia Lawall

On Mon, Jun 16, 2014 at 10:10 PM, Himangi Saraogi <himangi774@gmail.com> wrote:
> ARRAY_SIZE is more concise to use when the size of an array is divided
> by the size of its type or the size of its first element.
>
> The Coccinelle semantic patch that makes this change is as follows:
>
> // <smpl>
> @@
> type T;
> T[] E;
> @@
>
> - (sizeof(E)/sizeof(T))
> + ARRAY_SIZE(E)
> // </smpl>
>
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>

Thanks!

Will apply and queue for v3.17.
I also converted the MANUF definition a few lines above:

-#define MANUF( manuf, name )           { 0x##manuf,
sizeof(__prods_##manuf) / sizeof(struct zorro_prod_info),
__manufstr_##manuf, __prods_##manuf },
+#define MANUF( manuf, name )           { 0x##manuf,
ARRAY_SIZE(__prods_##manuf), __manufstr_##manuf, __prods_##manuf },

> ---
>  drivers/zorro/names.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/zorro/names.c b/drivers/zorro/names.c
> index 6f3fd99..4ccbcc9 100644
> --- a/drivers/zorro/names.c
> +++ b/drivers/zorro/names.c
> @@ -52,7 +52,7 @@ static struct zorro_manuf_info __initdata zorro_manuf_list[] = {
>  #include "devlist.h"
>  };
>
> -#define MANUFS (sizeof(zorro_manuf_list)/sizeof(struct zorro_manuf_info))
> +#define MANUFS ARRAY_SIZE(zorro_manuf_list)
>
>  void __init zorro_name_device(struct zorro_dev *dev)
>  {

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

end of thread, other threads:[~2014-06-23  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-16 20:10 [PATCH] zorro: use ARRAY_SIZE Himangi Saraogi
2014-06-23  8:40 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®