Skip to content

Commit

Permalink
datapath-windows: fix MIN() macro
Browse files Browse the repository at this point in the history
A quick implementation of MIN() didn't take into account operator
precedence as shown in the following example:

 #include <stdio.h>
 #define MYMIN(_a, _b) (_a) > (_b) ? (_b) : (_a)
 int main() {
     if (MYMIN(512, 256) < 14) {
         printf("buggy MYMIN\n");
     }
     return 0;
 }

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Russell Bryant <russell@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
nithinrajub authored and blp committed Nov 26, 2015
1 parent bc06cc7 commit 09dbf16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion datapath-windows/ovsext/Util.h
Expand Up @@ -66,7 +66,7 @@ VOID OvsFreeAlignedMemory(VOID *ptr);
VOID OvsAppendList(PLIST_ENTRY dst, PLIST_ENTRY src);


#define MIN(_a, _b) (_a) > (_b) ? (_b) : (_a)
#define MIN(_a, _b) ((_a) > (_b) ? (_b) : (_a))
#define ARRAY_SIZE(_x) ((sizeof(_x))/sizeof (_x)[0])
#define OVS_SWITCH_PORT_ID_INVALID (NDIS_SWITCH_PORT_ID)(-1)

Expand Down

0 comments on commit 09dbf16

Please sign in to comment.