lkml.org 
[lkml]   [2022]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] staging: r8188eu: combine nested if statements into one
From
On 6/23/22 05:15, Chang Yu wrote:
> - if (padapter) {
> - if (pfree_recv_queue == &precvpriv->free_recv_queue)
> - precvpriv->free_recvframe_cnt++;
> - }
> + if (padapter && pfree_recv_queue == &precvpriv->free_recv_queue)
> + precvpriv->free_recvframe_cnt++;

Hi

tested with:
#include <stdio.h>
int main() {
char padapter = 1;
int pfree_recv_queue = 256;
int free_recv_queue = 256;

if (padapter) {
if (pfree_recv_queue == free_recv_queue)
printf("Executed before patch:
precvpriv->free_recvframe_cnt++;\n");
}

if (padapter && pfree_recv_queue == free_recv_queue)
printf("Executed after patch: precvpriv->free_recvframe_cnt++;\n");

return 0;
}

Seems to work. But the rules which operation is done first && or == are
not too easy. I would prefer to have:

if (padapter && (pfree_recv_queue == free_recv_queue))

So it is very easy to read what is evaluated first.

But this is just my opinion and does not have to be right.

Thanks for your patch.

Bye Philipp

\
 
 \ /
  Last update: 2022-06-23 07:13    [W:0.135 / U:2.640 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site