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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux