All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8188eu: Refine if condition
@ 2015-02-27 17:58 Vatika Harlalka
  2015-03-02  0:21 ` [Outreachy kernel] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Vatika Harlalka @ 2015-02-27 17:58 UTC (permalink / raw)
  To: outreachy-kernel

Variable bound takes maximum value 8 so the if condition
for odd i is made more compact.

Signed-off-by: Vatika Harlalka <vatikaharlalka@gmail.com>
---
 drivers/staging/rtl8188eu/hal/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
index 6af72a4..3d0e447 100644
--- a/drivers/staging/rtl8188eu/hal/phy.c
+++ b/drivers/staging/rtl8188eu/hal/phy.c
@@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
 		bound = 4;
 
 	for (i = 0; i < bound; i++) {
-		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
+		if (i%2 == 1) {
 			if ((resulta[c1][i] & 0x00000200) != 0)
 				tmp1 = resulta[c1][i] | 0xFFFFFC00;
 			else
-- 
1.9.1



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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Refine if condition
  2015-02-27 17:58 [PATCH] Staging: rtl8188eu: Refine if condition Vatika Harlalka
@ 2015-03-02  0:21 ` Greg KH
  2015-03-02 17:30   ` Jes Sorensen
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-03-02  0:21 UTC (permalink / raw)
  To: Vatika Harlalka; +Cc: outreachy-kernel

On Fri, Feb 27, 2015 at 11:28:49PM +0530, Vatika Harlalka wrote:
> Variable bound takes maximum value 8 so the if condition
> for odd i is made more compact.
> 
> Signed-off-by: Vatika Harlalka <vatikaharlalka@gmail.com>
> ---
>  drivers/staging/rtl8188eu/hal/phy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
> index 6af72a4..3d0e447 100644
> --- a/drivers/staging/rtl8188eu/hal/phy.c
> +++ b/drivers/staging/rtl8188eu/hal/phy.c
> @@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
>  		bound = 4;
>  
>  	for (i = 0; i < bound; i++) {
> -		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
> +		if (i%2 == 1) {

I find this harder to read now, sorry, '%' is not used often in C code
for a reason :)

thanks,

greg k-h


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

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Refine if condition
  2015-03-02  0:21 ` [Outreachy kernel] " Greg KH
@ 2015-03-02 17:30   ` Jes Sorensen
  0 siblings, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2015-03-02 17:30 UTC (permalink / raw)
  To: Greg KH, Vatika Harlalka; +Cc: outreachy-kernel

On 03/01/15 19:21, Greg KH wrote:
> On Fri, Feb 27, 2015 at 11:28:49PM +0530, Vatika Harlalka wrote:
>> Variable bound takes maximum value 8 so the if condition
>> for odd i is made more compact.
>>
>> Signed-off-by: Vatika Harlalka <vatikaharlalka@gmail.com>
>> ---
>>  drivers/staging/rtl8188eu/hal/phy.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
>> index 6af72a4..3d0e447 100644
>> --- a/drivers/staging/rtl8188eu/hal/phy.c
>> +++ b/drivers/staging/rtl8188eu/hal/phy.c
>> @@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
>>  		bound = 4;
>>  
>>  	for (i = 0; i < bound; i++) {
>> -		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
>> +		if (i%2 == 1) {
> 
> I find this harder to read now, sorry, '%' is not used often in C code
> for a reason :)

In this case, it is probably more common in the kernel to use

	if ((i & 1) == 1)

in this case.

Jes



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

end of thread, other threads:[~2015-03-02 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 17:58 [PATCH] Staging: rtl8188eu: Refine if condition Vatika Harlalka
2015-03-02  0:21 ` [Outreachy kernel] " Greg KH
2015-03-02 17:30   ` Jes Sorensen

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.