Re: [PATCH] fix a code style in drivers/char/virtio_console.c

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

 



Hello,

On (Tue) May 18 2010 [13:41:29], Steven Liu wrote:
> Hi, Amit,
> 
>     if 'err' initialised in this path, it needn't do err = -ENOMEM
> after,isn't it?

What I mean is if we later add some code that just does:

	if (err)
		goto fail;

then 'ret' can be -ENOMEM, as it was initialised to, which would be
fine. But if a later patch adds something like:

+	ret = -EIO;
+	err = ...
+	if (err)
+		goto fail;
+
	err = ...
	if (err)
		goto fail;

In this case, the 2nd if() would now return EIO instead of ENOMEM as
earlier.

Also, this style of coding can prevent uninitialised usage of 'ret', eg:


	int ret;

	if (err)
		goto fail;

fail:
	return ret;

In this case, the compiler will warn about 'ret' being used
uninitialised.

This is just a coding style issue. I had initially coded it the way your
patch does, but Rusty asked me to change that and I like this new style
better: there's less scope for surprises.

		Amit
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/virtualization

[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux