Re: [PATCH] staging: r8188eu: combine nested if statements into one

From: Philipp Hortmann
Date: Thu Jun 23 2022 - 01:11:35 EST


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