All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue
@ 2014-12-19  2:18 Eduardo Barretto
  2014-12-19 15:41 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Eduardo Barretto @ 2014-12-19  2:18 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

Checkpatch was complaining about the else statement because the if statement had a return '1' call. Taking a look at the function which this else statement belongs, you can see that it has an switch case statement.
The main idea of the function is to return '1' if you get into any of the cases (including the default case where the "problematic" if/else statement is declared).
If any of the cases is not sufficient the function should return '0', so the else statement that checkpath was complaining could be removed, and what was done inside this else statement can be done outside the switch case statement and then we return '0'.
This way we have a cleaner code and no checkpatch error complaints.

Signed-off-by: Eduardo Barretto <edusbarretto@gmail.com>
---
 drivers/staging/wlan-ng/hfa384x_usb.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 55d2f56..de33a07 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -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;
 		}
+		break;
 	}
-	return 0;		/* avoid compiler warnings */
+	/* bad code */
+	pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
+		 pdrcode);
+	return 0;
 }
--
2.2.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue
  2014-12-19  2:18 [PATCH v3] Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue Eduardo Barretto
@ 2014-12-19 15:41 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2014-12-19 15:41 UTC (permalink / raw)
  To: Eduardo Barretto; +Cc: devel, linux-kernel

On Fri, Dec 19, 2014 at 12:18:26AM -0200, Eduardo Barretto wrote:
> Checkpatch was complaining about the else statement because the if statement had a return '1' call. Taking a look at the function which this else statement belongs, you can see that it has an switch case statement.
> The main idea of the function is to return '1' if you get into any of the cases (including the default case where the "problematic" if/else statement is declared).
> If any of the cases is not sufficient the function should return '0', so the else statement that checkpath was complaining could be removed, and what was done inside this else statement can be done outside the switch case statement and then we return '0'.
> This way we have a cleaner code and no checkpatch error complaints.

Verbose is good, but please wrap your lines at 72 columns.  And this
might have been a bit too verbose :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-19 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19  2:18 [PATCH v3] Staging: wlan-ng: hfa384x_usb: fixed an 'else' statement coding style issue Eduardo Barretto
2014-12-19 15:41 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.