Re: staging: dgap: Question about declaring variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 22, 2014 at 01:49:22PM -0400, Mark Hounschell wrote:
> I understand that unnecessarily initializing them is wrong. But if they
> do need initialized, is it preferred to do it in the declaration or in
> the code before it is used?

Which ever is more clear.  It's up to you.  Or do you mean code like
this?

1)
	ret = -ENOMEM;
	p = kmalloc();
	if (!p)
		goto err_free_x;

2)
	p = kmalloc();
	if (!p) {
		ret = -ENOMEM;
		goto err_free_x;
	}

That's also up to the maintainer.  People debate which one is cleaner.
I normally do the second one, unless the rest of the file does the first
one.  The first one apparently is slightly better assembly on current
GCCs.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux