Skip to contentSkip to conversation

platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()

PATCH In review Thorsten Blum 3 participants 3 messages Aug 15 – Sep 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()

Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().

---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lenovo/think-lmi.c +1 -1
index 26ee6ab34a15..81ab6aafee47 100644
@@ -249,7 +249,7 @@ static int tlmi_errstr_to_err(const char *errstr)
 {
 	int i;
 
-	for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
+	for (i = 0; i < ARRAY_SIZE(tlmi_errs); i++) {
 		if (!strcmp(tlmi_errs[i].err_str, errstr))
 			return tlmi_errs[i].err_code;
 	}
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Thorsten Blum

Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().

---
 drivers/platform/x86/lenovo/think-lmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lenovo/think-lmi.c +0 -0
index 26ee6ab34a15..81ab6aafee47 100644

drivers/platform/x86/lenovo/think-lmi.c static int tlmi_errstr_to_err(const char *errstr) · line 255

Quoted 8 lines
drivers/platform/x86/lenovo/think-lmi.c +1 -1
@@ -249,7 +249,7 @@ static int tlmi_errstr_to_err(const char *errstr)
 {
 	int i;
 
-	for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
+	for (i = 0; i < ARRAY_SIZE(tlmi_errs); i++) {
 		if (!strcmp(tlmi_errs[i].err_str, errstr))
 			return tlmi_errs[i].err_code;
 	}

Thanks - looks good to me

Mark

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 1 line · Thorsten Blum

Use the ARRAY_SIZE() helper to simplify tlmi_errstr_to_err().

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: think-lmi: Use ARRAY_SIZE() in tlmi_errstr_to_err()

      commit: 2ba3e60e4e073b48abde8e787fe6fffaacdc4007

--
i.