lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100518063241.GB27262@amit-laptop.redhat.com>
Date:	Tue, 18 May 2010 12:02:41 +0530
From:	Amit Shah <amit.shah@...hat.com>
To:	Steven Liu <lingjiujianke@...il.com>
Cc:	linux-kernel@...r.kernel.org,
	virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH] fix a code style in drivers/char/virtio_console.c

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ