Skip to contentSkip to conversation

debug.c: don't invent NUM_OF

PATCH Applied Randy.Dunlap 2 participants 2 messages Jan 7, 2005 1 message not in the archive ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 debug.c: don't invent NUM_OF

Use kernel.h for ARRAY_SIZE() instead of using local NUM_OF(). I.e., use kernel-supplied functions or macros when available.

diffstat:=

 drivers/acpi/debug.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

---

drivers/acpi/debug.c renamed from drivers/acpi/debug.c~acpi_array_size +3 -3
diff -Naurp ./drivers/acpi/debug.c~acpi_array_size ./drivers/acpi/debug.c
@@ -4,6 +4,7 @@
 
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <asm/uaccess.h>
 #include <acpi/acpi_drivers.h>
@@ -87,7 +88,6 @@ const struct acpi_dlevel acpi_debug_leve
 	ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
 	ACPI_DEBUG_INIT(ACPI_LV_EVENTS),             
 };
-#define NUM_OF(v)	( sizeof(v)/sizeof(v[0]) )
 
 static int
 acpi_system_read_debug (
@@ -109,7 +109,7 @@ acpi_system_read_debug (
 
 	switch ((unsigned long) data) {
 	case 0:
-		for (i = 0; i < NUM_OF(acpi_debug_layers); i++) {
+		for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
 			p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
 				acpi_debug_layers[i].name,
 				acpi_debug_layers[i].value,
@@ -126,7 +126,7 @@ acpi_system_read_debug (
 			acpi_dbg_layer);
 		break;
 	case 1:
-		for (i = 0; i < NUM_OF(acpi_debug_levels); i++) {
+		for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
 			p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
 				acpi_debug_levels[i].name,
 				acpi_debug_levels[i].value,

A message that is not in the archive (sent off-list or not yet received): [email protected]

Applied
#2 lore raw

applied.

thanks,
-len

Quoted 45 lines · Randy.Dunlap

Use kernel.h for ARRAY_SIZE() instead of using local NUM_OF(). I.e., use kernel-supplied functions or macros when available.

diffstat:=

  drivers/acpi/debug.c |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

---

______________________________________________________________________

diff -Naurp ./drivers/acpi/debug.c~acpi_array_size ./drivers/acpi/debug.c

drivers/acpi/debug.c renamed from drivers/acpi/debug.c~acpi_array_size +2 -2
@@ -4,6 +4,7 @@
 
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <asm/uaccess.h>
 #include <acpi/acpi_drivers.h>
@@ -87,7 +88,6 @@ const struct acpi_dlevel acpi_debug_leve
 	ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
 	ACPI_DEBUG_INIT(ACPI_LV_EVENTS),             
 };
-#define NUM_OF(v)	( sizeof(v)/sizeof(v[0]) )
 
 static int
 acpi_system_read_debug (
@@ -109,7 +109,7 @@ acpi_system_read_debug (
 
 	switch ((unsigned long) data) {
 	case 0:
-		for (i = 0; i < NUM_OF(acpi_debug_layers); i++) {
+		for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
 			p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
 				acpi_debug_layers[i].name,
 				acpi_debug_layers[i].value,

drivers/acpi/debug.c acpi_system_read_debug ( · line 132

Quoted 8 lines
drivers/acpi/debug.c renamed from drivers/acpi/debug.c~acpi_array_size +1 -1
@@ -126,7 +126,7 @@ acpi_system_read_debug (
 			acpi_dbg_layer);
 		break;
 	case 1:
-		for (i = 0; i < NUM_OF(acpi_debug_levels); i++) {
+		for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
 			p += sprintf(p, "%-25s\t0x%08lX [%c]\n",
 				acpi_debug_levels[i].name,
 				acpi_debug_levels[i].value,

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt