Thread (25 messages) 25 messages, 6 authors, 2014-12-08

Re: [tpmdd-devel] [PATCH v8 0/8] TPM 2.0 support

From: Joe Perches <joe@perches.com>
Date: 2014-12-02 23:48:40
Also in: lkml

On Wed, 2014-12-03 at 00:33 +0100, Peter Hüwe wrote:
Am Mittwoch, 3. Dezember 2014, 00:24:43 schrieb Aaro Koskinen:
quoted
On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote:
quoted
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client
*client,

 		return -ENODEV;
 	
 	rc = tpm_chip_register(chip);

-	if (rc)
-		return rc;

-	return 0;
+	return rc;
Maybe just return tpm_chip_register(chip)?
Even better.
The pattern:

	foo = bar();
	if (foo)
		return foo;

	return 0;

is fairly common.

There are a few hundred in the kernel.

$ grep-2.5.4 -nrP --include=*.[ch] "\b(\w+)\s*=\s*[^;]*;\s*if\s*\(\s*\1\s*\)\s*return\s*\1\s*;\s*return\s*0;" * | \
  grep -oP '^.+:\d+:' | \
  wc -l
308
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help