Subject: Re: [patch] powerpc: sysfs fix compiler warning

From: Christian Krafft <[email-masked]>
Date: Mon, 25 Jun 2007 19:07:20 +0200

On Sat, 23 Jun 2007 11:46:54 +0200
Michael Buesch <[email-masked]> wrote:

> On Friday 22 June 2007 19:48:53 Christian Krafft wrote:
> > From: Christian Krafft <[email-masked]>
> > 
> > This patch fixes the following compiler warning:
> > arch/powerpc/kernel/sysfs.c:385: warning: ignoring return value of
> > `sysfs_create_group',
> > 
> > Signed-off-by: Christian Krafft <[email-masked]>
> > 
> > Index: linux-2.6.22-rc5/arch/powerpc/kernel/sysfs.c
> > ===================================================================
> > --- linux-2.6.22-rc5.orig/arch/powerpc/kernel/sysfs.c
> > +++ linux-2.6.22-rc5/arch/powerpc/kernel/sysfs.c
> > @@ -380,16 +380,23 @@ int cpu_add_sysdev_attr_group(struct att
> >  {
> >  	int cpu;
> >  	struct sys_device *sysdev;
> > +	int error;

Looks like I introduced a new warning while fixing another.
Have checked the patch with sparse just after sending it ;-)

> >  
> >  	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);
> 
> That is probably dangerous, if multiple sysfs_create_group fail
> with different error codes. So it will wiggle the error codes
> together.

Yeah, that's right, will fix it to do a break in case of error.

> 
> >  	}
> >  
> > +	if(error)
>  {
> > +		for_each_possible_cpu(cpu) {
> > +			sysdev = get_cpu_sysdev(cpu);
> > +			sysfs_remove_group(&sysdev->kobj, attrs);
> > +		}
> probably do something like
> 		error = -ENOENT;
>  }
> or some other error code here to fix it.
> > +
> >  	mutex_unlock(&cpu_mutex);
> > -	return 0;
> > +	return error;
> >  }
> >  EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
> >  
> > 
> > 
> 
> 
> 

-- 
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