Web lists-archives.com

[PATCH] staging: ccree: fix array_size.cocci warnings




drivers/staging/ccree/ssi_sysfs.c:319:34-35: WARNING: Use ARRAY_SIZE
drivers/staging/ccree/ssi_sysfs.c:429:34-35: WARNING: Use ARRAY_SIZE

 Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element

Semantic patch information:
 This makes an effort to find cases where ARRAY_SIZE can be used such as
 where there is a division of sizeof the array by the sizeof its first
 element or by any indexed element or the element type. It replaces the
 division of the two sizeofs by ARRAY_SIZE.

Generated by: scripts/coccinelle/misc/array_size.cocci

CC: Gilad Ben-Yossef <gilad@xxxxxxxxxxxxx>
Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
---

 ssi_sysfs.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/staging/ccree/ssi_sysfs.c
+++ b/drivers/staging/ccree/ssi_sysfs.c
@@ -316,7 +316,7 @@ static ssize_t ssi_sys_help_show(struct
 	int i=0, offset = 0;
 
 	offset += scnprintf(buf + offset, PAGE_SIZE - offset, "Usage:\n");
-	for ( i = 0; i < (sizeof(help_str)/sizeof(help_str[0])); i+=2) {
+	for ( i = 0; i < ARRAY_SIZE(help_str); i+=2) {
 	   offset += scnprintf(buf + offset, PAGE_SIZE - offset, "%s\t\t%s\n", help_str[i], help_str[i+1]);
 	}
 	return offset;
@@ -426,8 +426,7 @@ int ssi_sysfs_init(struct kobject *sys_d
 	/* Initialize top directory */
 	retval = sys_init_dir(&sys_top_dir, drvdata, sys_dev_obj,
 				"cc_info", ssi_sys_top_level_attrs,
-				sizeof(ssi_sys_top_level_attrs) /
-				sizeof(struct kobj_attribute));
+				ARRAY_SIZE(ssi_sys_top_level_attrs));
 	return retval;
 }