Skip to contentSkip to conversation

Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue

PATCH Superseded Eduardo Barretto 2 participants 4 messages Dec 15, 2014 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue

Fixed a coding style issue

---
 drivers/staging/wlan-ng/hfa384x_usb.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/wlan-ng/hfa384x_usb.c +4 -5
index 55d2f56..d388f2c 100644
@@ -4123,12 +4123,11 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode)
 			pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
 				 pdrcode);
 			return 1;
-		} else {
-			/* bad code */
-			pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
-				 pdrcode);
-			return 0;
 		}
+		/* bad code */
+		pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
+			 pdrcode);
+		return 0;
 	}
 	return 0;		/* avoid compiler warnings */
 }
Signature · 1 line
2.1.3
#1 lore raw
Quoted 1 line · Eduardo Barretto

Fixed a coding style issue

[]

drivers/staging/wlan-ng/hfa384x_usb.c

Quoted 1 line
drivers/staging/wlan-ng/hfa384x_usb.c +0 -0

[]

Quoted 7 lines
drivers/staging/wlan-ng/hfa384x_usb.c +0 -3
@@ -4123,12 +4123,11 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode)
 			pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
 				 pdrcode);
 			return 1;
-		} else {
-			/* bad code */
-			pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",

drivers/staging/wlan-ng/hfa384x_usb.c static int hfa384x_isgood_pdrcode(u16 pdrcode) · line 4133

Quoted 10 lines
drivers/staging/wlan-ng/hfa384x_usb.c +4 -2
-				 pdrcode);
-			return 0;
 		}
+		/* bad code */
+		pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
+			 pdrcode);
+		return 0;
 	}
 	return 0;		/* avoid compiler warnings */
 }

While this patch isn't necessary, if any change is done, it might better to not have two consecutive return 0; uses.

#2 lore raw

Thank you for the quick feedback.
It was my first patch to the kernel and I wanted to be sure it would get right to the community. I'll be making a version two with the consideration you brought me.

Thank you again,
Best regards,

Eduardo Barretto

Quoted 28 lines · Joe Perches
Quoted 1 line · Eduardo Barretto

Fixed a coding style issue

[]

drivers/staging/wlan-ng/hfa384x_usb.c

Quoted 1 line
drivers/staging/wlan-ng/hfa384x_usb.c +0 -0

[]

Quoted 7 lines
drivers/staging/wlan-ng/hfa384x_usb.c +0 -3
@@ -4123,12 +4123,11 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode)
 			pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
 				 pdrcode);
 			return 1;
-		} else {
-			/* bad code */
-			pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",

drivers/staging/wlan-ng/hfa384x_usb.c static int hfa384x_isgood_pdrcode(u16 pdrcode) · line 4133

Quoted 10 lines
drivers/staging/wlan-ng/hfa384x_usb.c +4 -2
-				 pdrcode);
-			return 0;
 		}
+		/* bad code */
+		pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
+			 pdrcode);
+		return 0;
 	}
 	return 0;		/* avoid compiler warnings */
 }

While this patch isn't necessary, if any change is done, it might better to not have two consecutive return 0; uses.

#3 lore raw
Quoted 3 lines · Eduardo Barretto

Thank you for the quick feedback.
It was my first patch to the kernel and I wanted to be sure it would get right to the community. I'll be making a version two with the consideration you brought me.

the code today is:

{
	switch (prdcode) {
	case [...]
		return 1;
	default:
		if (prdcode < 0x1000) {
			printk(msg1);
			return 1;
		else
			printk(msg2);
			return 0;
	}
	return 0;	/* avoid compiler noise */
}

I think this code does not needs changing.
I think more modern compilers don't even warn
when the last return 0; isn't there.

If it were to be changed, I'd probably write it like:

{
	switch (prdcode) {
	case [...]
		return 1;
	default:
		if (prdcode < 0x1000) {
			printk(msg1);
			return 1;
		}
		break;
	}

	printk(msg2);
	return 0;
}

but I wouldn't bother.