Skip to contentSkip to conversation

powerpc: sysfs fix compiler warning

PATCH In review Christian Krafft 2 participants 3 messages Jun 29, 2007 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: sysfs fix compiler warning

From: Christian Krafft <[email protected]>

This patch fixes the following compiler warning:
arch/powerpc/kernel/sysfs.c:385: warning: ignoring return value of `sysfs_create_group',

arch/powerpc/kernel/sysfs.c +11 -2
@@ -380,16 +380,25 @@ int cpu_add_sysdev_attr_group(struct att
 {
 	int cpu;
 	struct sys_device *sysdev;
+	int error = 0;
 
 	mutex_lock(&cpu_mutex);
 
 	for_each_possible_cpu(cpu) {
 		sysdev = get_cpu_sysdev(cpu);
-		sysfs_create_group(&sysdev->kobj, attrs);
+		error = sysfs_create_group(&sysdev->kobj, attrs);
+
+		if (error) {
+			for_each_possible_cpu(cpu) {
+				sysdev = get_cpu_sysdev(cpu);
+				sysfs_remove_group(&sysdev->kobj, attrs);
+			}
+			break;
+		}
 	}
 
 	mutex_unlock(&cpu_mutex);
-	return 0;
+	return error;
 }
 EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
 
Signature · 13 lines
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294
#1 lore raw
Quoted 17 lines · On Friday 29 June 2007 16:50:10 Christian Krafft wrote:

From: Christian Krafft <[email protected]>

This patch fixes the following compiler warning:
arch/powerpc/kernel/sysfs.c:385: warning: ignoring return value of `sysfs_create_group',

arch/powerpc/kernel/sysfs.c +1 -0
@@ -380,16 +380,25 @@ int cpu_add_sysdev_attr_group(struct att
 {
 	int cpu;
 	struct sys_device *sysdev;
+	int error = 0;
 
 	mutex_lock(&cpu_mutex);

arch/powerpc/kernel/sysfs.c int cpu_add_sysdev_attr_group(struct att · line 394

Quoted 10 lines
arch/powerpc/kernel/sysfs.c +6 -1
 
 	for_each_possible_cpu(cpu) {
 		sysdev = get_cpu_sysdev(cpu);
-		sysfs_create_group(&sysdev->kobj, attrs);
+		error = sysfs_create_group(&sysdev->kobj, attrs);
+
+		if (error) {
+			for_each_possible_cpu(cpu) {
+				sysdev = get_cpu_sysdev(cpu);
+				sysfs_remove_group(&sysdev->kobj, attrs);

Is sysfs_remove_group() safe to call on kobjs for which we did not call sysfs_create_group()?

Quoted 13 lines
arch/powerpc/kernel/sysfs.c +4 -1
+			}
+			break;
+		}
 	}
 
 	mutex_unlock(&cpu_mutex);
-	return 0;
+	return error;
 }
 EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
 
Signature · 1 line
Greetings Michael.
#2 lore raw
Quoted 19 lines · On Fri, 29 Jun 2007 16:57:20 +0200 Michael Buesch <[email protected]> wrote:
Quoted 18 lines · On Friday 29 June 2007 16:50:10 Christian Krafft wrote:

From: Christian Krafft <[email protected]>

This patch fixes the following compiler warning:
arch/powerpc/kernel/sysfs.c:385: warning: ignoring return value of `sysfs_create_group',

arch/powerpc/kernel/sysfs.c +1 -0
@@ -380,16 +380,25 @@ int cpu_add_sysdev_attr_group(struct att
 {
 	int cpu;
 	struct sys_device *sysdev;
+	int error = 0;
 
 	mutex_lock(&cpu_mutex);
 
Quoted 12 lines

arch/powerpc/kernel/sysfs.c int cpu_add_sysdev_attr_group(struct att · line 394

Quoted 9 lines
arch/powerpc/kernel/sysfs.c +6 -1
 	for_each_possible_cpu(cpu) {
 		sysdev = get_cpu_sysdev(cpu);
-		sysfs_create_group(&sysdev->kobj, attrs);
+		error = sysfs_create_group(&sysdev->kobj, attrs);
+
+		if (error) {
+			for_each_possible_cpu(cpu) {
+				sysdev = get_cpu_sysdev(cpu);
+				sysfs_remove_group(&sysdev->kobj, attrs);

Is sysfs_remove_group() safe to call on kobjs for which we did not call sysfs_create_group()?

I only looked into it a little and haven't seen a problem.
From the interface point of view I would say it would be a bug, if it's not safe. But I will do a short test on this.

Quoted 17 lines
Quoted 14 lines
arch/powerpc/kernel/sysfs.c +4 -1
+			}
+			break;
+		}
 	}
 
 	mutex_unlock(&cpu_mutex);
-	return 0;
+	return error;
 }
 EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
 
Signature · 13 lines
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294