public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtl8188eu: Remove unnecessary braces for simple return in xmit_linux.c
@ 2014-11-08 21:14 Krzysztof Konopko
  2014-11-08 21:23 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Konopko @ 2014-11-08 21:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: navin patidar, Larry Finger, trivial, devel, linux-kernel,
	Krzysztof Konopko

scripts/checkpatch.pl reports a coding style problem in xmit_linux.c

  WARNING:BRACES: braces {} are not necessary for single statement blocks
  #61852: FILE: rtl8188eu/os_dep/xmit_linux.c:70:

This patch removes unnecessary braces.

Signed-off-by: Krzysztof Konopko <kris@konagma.com>
---
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
index d5e41a5..9e0e338 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
@@ -67,9 +67,8 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
 int rtw_endofpktfile(struct pkt_file *pfile)
 {
 
-	if (pfile->pkt_len == 0) {
+	if (pfile->pkt_len == 0)
 		return true;
-	}
 
 
 	return false;
-- 
2.1.1


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

* Re: [PATCH] rtl8188eu: Remove unnecessary braces for simple return in xmit_linux.c
  2014-11-08 21:14 [PATCH] rtl8188eu: Remove unnecessary braces for simple return in xmit_linux.c Krzysztof Konopko
@ 2014-11-08 21:23 ` Joe Perches
  2014-11-09  9:38   ` Krzysztof Konopko
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-11-08 21:23 UTC (permalink / raw)
  To: Krzysztof Konopko
  Cc: Greg Kroah-Hartman, navin patidar, Larry Finger, trivial, devel,
	linux-kernel

On Sat, 2014-11-08 at 22:14 +0100, Krzysztof Konopko wrote:
> scripts/checkpatch.pl reports a coding style problem in xmit_linux.c
[]
> diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
[]
> @@ -67,9 +67,8 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
>  int rtw_endofpktfile(struct pkt_file *pfile)
>  {
>  
> -	if (pfile->pkt_len == 0) {
> +	if (pfile->pkt_len == 0)
>  		return true;
> -	}
>  
> 
>  	return false;

This should probably be

bool rtw_endofpktfile(const struct pkt_file *pfile_
{
	return !pfile->pkt_len;
}

or just removed altogether and tested directly
in the one place it's used.



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

* Re: [PATCH] rtl8188eu: Remove unnecessary braces for simple return in xmit_linux.c
  2014-11-08 21:23 ` Joe Perches
@ 2014-11-09  9:38   ` Krzysztof Konopko
  2014-11-10 18:54     ` [PATCH] rtl8188eu: Simplify rtw_endofpktfile() " Krzysztof Konopko
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Konopko @ 2014-11-09  9:38 UTC (permalink / raw)
  To: Joe Perches
  Cc: Greg Kroah-Hartman, navin patidar, Larry Finger, trivial, devel,
	linux-kernel

On 08/11/14 21:23, Joe Perches wrote:
> On Sat, 2014-11-08 at 22:14 +0100, Krzysztof Konopko wrote:
>> scripts/checkpatch.pl reports a coding style problem in xmit_linux.c
> []
>> diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
> []
>> @@ -67,9 +67,8 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
>>  int rtw_endofpktfile(struct pkt_file *pfile)
>>  {
>>  
>> -	if (pfile->pkt_len == 0) {
>> +	if (pfile->pkt_len == 0)
>>  		return true;
>> -	}
>>  
>>
>>  	return false;
> 
> This should probably be
> 
> bool rtw_endofpktfile(const struct pkt_file *pfile_
> {
> 	return !pfile->pkt_len;
> }
>

Thanks for looking into it.

I see your point about making it a single return statement.  I tend to
shorten things as well.  I'd keep it as this:

bool rtw_endofpktfile(const struct pkt_file *pfile_
{
 	return pfile->pkt_len == 0;
}

Usign `!` operator suggests the variable is boolean although the name
suggests it isn't.  I'm not so familiar with the linux kernel code base
yet to justify it myself but I see no harm in making it slightly more
explicit.

> or just removed altogether and tested directly
> in the one place it's used.
> 
> 

It looks to me that the original intention was to open a possibility to
define the end of packet file in a OS dependent way so I'd leave it.

Or, if the counter argument is that non-Linux functionality should not
appear in this driver, the rest of non-Linux code should be removed in
the first place.  I'm not in position to even have an opinion on this.

The sole point of this patch was to fix a coding style problem but the
change you suggest seems still relevant.  I'll resend unless you have
strong objections on using `==` operator explicitly in the return statement.

Cheers,
Kris

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

* [PATCH] rtl8188eu: Simplify rtw_endofpktfile() in xmit_linux.c
  2014-11-09  9:38   ` Krzysztof Konopko
@ 2014-11-10 18:54     ` Krzysztof Konopko
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Konopko @ 2014-11-10 18:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Krzysztof Konopko, navin patidar, Larry Finger, devel,
	linux-kernel, trivial

scripts/checkpatch.pl reports a coding style problem in xmit_linux.c

  WARNING:BRACES: braces {} are not necessary for single statement blocks
  #61852: FILE: rtl8188eu/os_dep/xmit_linux.c:70:

This patch removes unnecessary braces and simplifies the function to a
single return statement.

Signed-off-by: Krzysztof Konopko <kris@konagma.com>
---
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
index d5e41a5..5acf9a9 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
@@ -66,13 +66,7 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
 
 int rtw_endofpktfile(struct pkt_file *pfile)
 {
-
-	if (pfile->pkt_len == 0) {
-		return true;
-	}
-
-
-	return false;
+	return pfile->pkt_len == 0;
 }
 
 int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz)
-- 
2.1.1


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

end of thread, other threads:[~2014-11-10 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-08 21:14 [PATCH] rtl8188eu: Remove unnecessary braces for simple return in xmit_linux.c Krzysztof Konopko
2014-11-08 21:23 ` Joe Perches
2014-11-09  9:38   ` Krzysztof Konopko
2014-11-10 18:54     ` [PATCH] rtl8188eu: Simplify rtw_endofpktfile() " Krzysztof Konopko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox