Thread (3 messages) 3 messages, 2 authors, 2021-11-30

Re: [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues

From: Dan Carpenter <hidden>
Date: 2021-11-30 09:48:41
Also in: lkml

On Tue, Nov 30, 2021 at 03:43:47AM +0530, Vihas Mak wrote:
quoted hunk ↗ jump to hunk
Fix camelcase warnings from checkpatch.pl and use ARRAY_SIZE()
to make the code cleaner and avoid following cocci warnings:

	drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:142:51-52: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:174:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:450:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:655:49-50: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c:136:50-51: WARNING: Use ARRAY_SIZE

Signed-off-by: Vihas Mak <redacted>
---
 .../staging/r8188eu/hal/HalHWImg8188E_BB.c    |  6 ++---
 .../staging/r8188eu/hal/HalHWImg8188E_MAC.c   |  2 +-
 .../staging/r8188eu/hal/HalHWImg8188E_RF.c    | 24 +++++++++----------
 3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
index f6e4243e0..ce46b3651 100644
--- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
+++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
@@ -171,7 +171,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
 {
 	u32     hex         = 0;
 	u32     i           = 0;
-	u32     arraylen    = sizeof(array_agc_tab_1t_8188e) / sizeof(u32);
+	u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
 	u32    *array       = array_agc_tab_1t_8188e;
Get rid of both the "arraylen" and "array" variables.  They only obscure
what the code is doing.  You may need to do additional clean up to make
it work without making the lines too long...

Same for the rest.

If that is too complicated then it's fine too, just leave it as-is for
now.  I know that sometimes people just want to silence the checkpatch
warnings but I prefer to keep the warning as a marker for bad code so
let's leave it until someone can fix this in the correct way.

regards,
dan carpenter
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help