Skip to contentSkip to conversation

oprofile: Fix unnecessary cleverness

PATCH New Markus Armbruster 1 participant 1 message May 12, 2006

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

PATCH 1/1 oprofile: Fix unnecessary cleverness

nmi_create_files() in arch/i386/oprofile/nmi_int.c depends on model->num_counters (number of performance counters) being less than
10. While this is currently the case, it's too clever by half.

Other archs aren't quite as clever: they assume 100. I suggest to normalize them all to 1000.

arch/i386/oprofile/nmi_int.c +3 -3
diff -r ddba92a5cba9 arch/i386/oprofile/nmi_int.c
@@ -281,9 +281,9 @@ static int nmi_create_files(struct super
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry * dir;
-		char buf[2];
- 
-		snprintf(buf, 2, "%d", i);
+		char buf[4];
+ 
+		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(sb, root, buf);
 		oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled); 
 		oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event); 
arch/alpha/oprofile/common.c +1 -1
diff -r ddba92a5cba9 arch/alpha/oprofile/common.c
@@ -112,7 +112,7 @@ op_axp_create_files(struct super_block *
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[3];
+		char buf[4];
 
 		snprintf(buf, sizeof buf, "%d", i);
 		dir = oprofilefs_mkdir(sb, root, buf);
arch/mips/oprofile/common.c +1 -1
diff -r ddba92a5cba9 arch/mips/oprofile/common.c
@@ -38,7 +38,7 @@ static int op_mips_create_files(struct s
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[3];
+		char buf[4];
 
 		snprintf(buf, sizeof buf, "%d", i);
 		dir = oprofilefs_mkdir(sb, root, buf);
arch/powerpc/oprofile/common.c +1 -1
diff -r ddba92a5cba9 arch/powerpc/oprofile/common.c
@@ -93,7 +93,7 @@ static int op_powerpc_create_files(struc
 
 	for (i = 0; i < model->num_counters; ++i) {
 		struct dentry *dir;
-		char buf[3];
+		char buf[4];
 
 		snprintf(buf, sizeof buf, "%d", i);
 		dir = oprofilefs_mkdir(sb, root, buf);
arch/sh/oprofile/op_model_sh7750.c +1 -1
diff -r ddba92a5cba9 arch/sh/oprofile/op_model_sh7750.c
@@ -198,7 +198,7 @@ static int sh7750_perf_counter_create_fi
 
 	for (i = 0; i < NR_CNTRS; i++) {
 		struct dentry *dir;
-		char buf[3];
+		char buf[4];
 
 		snprintf(buf, sizeof(buf), "%d", i);
 		dir = oprofilefs_mkdir(sb, root, buf);