[PATCH v2 05/10] cxl: Refactor adaptor init/teardown

David Laight David.Laight at ACULAB.COM
Wed Aug 12 20:14:27 AEST 2015


From: Cyril Bur
> Sent: 11 August 2015 07:01
...
> You have a dilema with the use of ugly if (rc = foo()). I don't like it but the
> file is littered with it.
> 
> Looks like the majority of uses in this file the conditional block is only
> one line then it makes sense (or at least in terms of numbers of lines... fair
> enough), however, if you have a conditional block spanning multiple lines, I
> don't like.
...
> >  	kfree(adapter);
> >  }
> >
> > -static struct cxl *cxl_alloc_adapter(struct pci_dev *dev)
> > +static struct cxl *cxl_alloc_adapter(void)
> >  {
> >  	struct cxl *adapter;
> > +	int rc;
> >
> >  	if (!(adapter = kzalloc(sizeof(struct cxl), GFP_KERNEL)))
> >  		return NULL;
> >
> > -	adapter->dev.parent = &dev->dev;
> > -	adapter->dev.release = cxl_release_adapter;
> > -	pci_set_drvdata(dev, adapter);
> >  	spin_lock_init(&adapter->afu_list_lock);
> >
> > +	if ((rc = cxl_alloc_adapter_nr(adapter)))
> 
> Humf
> 
> > +		goto err1;
> > +
> > +	if ((rc = dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)))
> 
> Humf
> > +		goto err2;
> > +
> >  	return adapter;
> > +
> > +err2:
> > +	cxl_remove_adapter_nr(adapter);
> > +err1:
> > +	kfree(adapter);
> > +	return NULL;
> >  }
...

The function above doesn't even use the 'rc' value.

	David


More information about the Linuxppc-dev mailing list