linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/module_64: fix array_size.cocci warning
@ 2022-02-23  7:54 Guo Zhengkui
  2022-02-24  0:32 ` Russell Currey
  2022-03-02 12:41 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Guo Zhengkui @ 2022-02-23  7:54 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Christophe Leroy, Guo Zhengkui, Russell Currey,
	Wedson Almeida Filho,
	open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
	open list
  Cc: kernel

Fix following coccicheck warning:
./arch/powerpc/kernel/module_64.c:432:40-41: WARNING: Use ARRAY_SIZE.

ARRAY_SIZE(arr) is a macro provided by the kernel. It makes sure that arr
is an array, so it's safer than sizeof(arr) / sizeof(arr[0]) and more
standard.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
 arch/powerpc/kernel/module_64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 6a45e6ddbe58..94d14cf99bca 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -14,6 +14,7 @@
 #include <linux/ftrace.h>
 #include <linux/bug.h>
 #include <linux/uaccess.h>
+#include <linux/kernel.h>
 #include <asm/module.h>
 #include <asm/firmware.h>
 #include <asm/code-patching.h>
@@ -429,7 +430,7 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
 	if (is_mprofile_ftrace_call(name))
 		return create_ftrace_stub(entry, addr, me);
 
-	for (i = 0; i < sizeof(ppc64_stub_insns) / sizeof(u32); i++) {
+	for (i = 0; i < ARRAY_SIZE(ppc64_stub_insns); i++) {
 		if (patch_instruction(&entry->jump[i],
 				      ppc_inst(ppc64_stub_insns[i])))
 			return 0;
-- 
2.20.1


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

* Re: [PATCH] powerpc/module_64: fix array_size.cocci warning
  2022-02-23  7:54 [PATCH] powerpc/module_64: fix array_size.cocci warning Guo Zhengkui
@ 2022-02-24  0:32 ` Russell Currey
  2022-03-02 12:41 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Russell Currey @ 2022-02-24  0:32 UTC (permalink / raw)
  To: Guo Zhengkui, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Christophe Leroy, Wedson Almeida Filho,
	open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
	open list
  Cc: kernel

On Wed, 2022-02-23 at 15:54 +0800, Guo Zhengkui wrote:
> Fix following coccicheck warning:
> ./arch/powerpc/kernel/module_64.c:432:40-41: WARNING: Use ARRAY_SIZE.
> 
> ARRAY_SIZE(arr) is a macro provided by the kernel. It makes sure that
> arr
> is an array, so it's safer than sizeof(arr) / sizeof(arr[0]) and more
> standard.
> 
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>

Reviewed-by: Russell Currey <ruscur@russell.cc>

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

* Re: [PATCH] powerpc/module_64: fix array_size.cocci warning
  2022-02-23  7:54 [PATCH] powerpc/module_64: fix array_size.cocci warning Guo Zhengkui
  2022-02-24  0:32 ` Russell Currey
@ 2022-03-02 12:41 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2022-03-02 12:41 UTC (permalink / raw)
  To: Paul Mackerras, Christophe Leroy, Michael Ellerman, open list,
	open list:LINUX FOR POWERPC 32-BIT AND 64-BIT, Russell Currey,
	Benjamin Herrenschmidt, Wedson Almeida Filho, Guo Zhengkui
  Cc: kernel

On Wed, 23 Feb 2022 15:54:23 +0800, Guo Zhengkui wrote:
> Fix following coccicheck warning:
> ./arch/powerpc/kernel/module_64.c:432:40-41: WARNING: Use ARRAY_SIZE.
> 
> ARRAY_SIZE(arr) is a macro provided by the kernel. It makes sure that arr
> is an array, so it's safer than sizeof(arr) / sizeof(arr[0]) and more
> standard.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/module_64: fix array_size.cocci warning
      https://git.kernel.org/powerpc/c/8a0edc72bec25fa62450bfef1a150483558e1289

cheers

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

end of thread, other threads:[~2022-03-02 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23  7:54 [PATCH] powerpc/module_64: fix array_size.cocci warning Guo Zhengkui
2022-02-24  0:32 ` Russell Currey
2022-03-02 12:41 ` Michael Ellerman

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).