linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
@ 2019-02-08  2:41 Allen
  2019-02-08  8:38 ` Heiko Carstens
  0 siblings, 1 reply; 3+ messages in thread
From: Allen @ 2019-02-08  2:41 UTC (permalink / raw)
  To: linux-s390; +Cc: linux-kernel, Allen Pais

From: Allen Pais <allen.lkml@gmail.com>

This issue was detected with the help of Coccinelle.

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 arch/s390/tools/gen_opcode_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/tools/gen_opcode_table.c b/arch/s390/tools/gen_opcode_table.c
index a1bc02b29c81..468b70c85f62 100644
--- a/arch/s390/tools/gen_opcode_table.c
+++ b/arch/s390/tools/gen_opcode_table.c
@@ -138,7 +138,7 @@ static struct insn_type *insn_format_to_type(char *format)
 	strcpy(tmp, format);
 	base_format = tmp;
 	base_format = strsep(&base_format, "_");
-	for (i = 0; i < sizeof(insn_type_table) / sizeof(insn_type_table[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {
 		ptr = insn_type_table[i].format;
 		while (*ptr) {
 			if (!strcmp(base_format, *ptr))
-- 
2.19.1


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

* Re: [PATCH] Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
  2019-02-08  2:41 [PATCH] Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element Allen
@ 2019-02-08  8:38 ` Heiko Carstens
  2019-02-08 11:05   ` Allen
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Carstens @ 2019-02-08  8:38 UTC (permalink / raw)
  To: Allen; +Cc: linux-s390, linux-kernel

On Fri, Feb 08, 2019 at 08:11:10AM +0530, Allen wrote:
> From: Allen Pais <allen.lkml@gmail.com>
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  arch/s390/tools/gen_opcode_table.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/tools/gen_opcode_table.c b/arch/s390/tools/gen_opcode_table.c
> index a1bc02b29c81..468b70c85f62 100644
> --- a/arch/s390/tools/gen_opcode_table.c
> +++ b/arch/s390/tools/gen_opcode_table.c
> @@ -138,7 +138,7 @@ static struct insn_type *insn_format_to_type(char *format)
>  	strcpy(tmp, format);
>  	base_format = tmp;
>  	base_format = strsep(&base_format, "_");
> -	for (i = 0; i < sizeof(insn_type_table) / sizeof(insn_type_table[0]); i++) {
> +	for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {

This does not compile.


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

* Re: [PATCH] Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
  2019-02-08  8:38 ` Heiko Carstens
@ 2019-02-08 11:05   ` Allen
  0 siblings, 0 replies; 3+ messages in thread
From: Allen @ 2019-02-08 11:05 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: linux-s390, linux-kernel

> >
> > diff --git a/arch/s390/tools/gen_opcode_table.c b/arch/s390/tools/gen_opcode_table.c
> > index a1bc02b29c81..468b70c85f62 100644
> > --- a/arch/s390/tools/gen_opcode_table.c
> > +++ b/arch/s390/tools/gen_opcode_table.c
> > @@ -138,7 +138,7 @@ static struct insn_type *insn_format_to_type(char *format)
> >       strcpy(tmp, format);
> >       base_format = tmp;
> >       base_format = strsep(&base_format, "_");
> > -     for (i = 0; i < sizeof(insn_type_table) / sizeof(insn_type_table[0]); i++) {
> > +     for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {
>
> This does not compile.
>
   Surprising. I try it out again.

Thanks.

-- 
       - Allen

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

end of thread, other threads:[~2019-02-08 11:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08  2:41 [PATCH] Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element Allen
2019-02-08  8:38 ` Heiko Carstens
2019-02-08 11:05   ` Allen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).