From b13fe1161ced2436f4472a8a2bc2bd0810fe27ea Mon Sep 17 00:00:00 2001 From: purplerain Date: Sat, 30 Sep 2023 05:22:07 +0000 Subject: [PATCH] refactor NGE_INC macro for improved robustness and operator precedence handling. The NGE_INC(x, y) macro was corrected to include additional parenthesis to ensure the proper order of operations. It now increments x by 1 and applies the modulo y correctly, ensuring consistent and error-free behavior, particularly in complex expressions --- sys/dev/pci/if_ngereg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/pci/if_ngereg.h b/sys/dev/pci/if_ngereg.h index aefe6911e..346225063 100644 --- a/sys/dev/pci/if_ngereg.h +++ b/sys/dev/pci/if_ngereg.h @@ -528,7 +528,7 @@ struct nge_desc_32 { #define NGE_LASTDESC(x) (!((x)->nge_ctl & NGE_CMDSTS_MORE)) #define NGE_OWNDESC(x) ((x)->nge_ctl & NGE_CMDSTS_OWN) -#define NGE_INC(x, y) (x) = (x + 1) % y +#define NGE_INC(x, y) ((x) = ((x) + 1) % (y)) #define NGE_RXBYTES(x) ((x)->nge_ctl & NGE_CMDSTS_BUFLEN) #define NGE_RXSTAT_RANGELENERR 0x00010000