Skip to content

Commit 227642d

Browse files
0xB10Cachow101
authored andcommitted
test: fix MIN macro-redefinition
Renames the `MIN` macro to `_TRACEPOINT_TEST_MIN`. From bitcoin#31418: ``` stderr: /virtual/main.c:70:9: warning: 'MIN' macro redefined [-Wmacro-redefined] 70 | #define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) | ^ include/linux/minmax.h:329:9: note: previous definition is here 329 | #define MIN(a,b) __cmp(min,a,b) | ^ 1 warning generated. ``` fixes: bitcoin#31418 Github-Pull: bitcoin#31419 Rebased-From: 00c1dbd
1 parent b8112cf commit 227642d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/functional/interface_usdt_net.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
MAX_MSG_TYPE_LENGTH,
4141
MAX_MSG_DATA_LENGTH
4242
) + """
43-
#define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
43+
// A min() macro. Prefixed with _TRACEPOINT_TEST to avoid collision with other MIN macros.
44+
#define _TRACEPOINT_TEST_MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
4445
4546
struct p2p_message
4647
{
@@ -60,7 +61,7 @@
6061
bpf_usdt_readarg_p(3, ctx, &msg.peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
6162
bpf_usdt_readarg_p(4, ctx, &msg.msg_type, MAX_MSG_TYPE_LENGTH);
6263
bpf_usdt_readarg(5, ctx, &msg.msg_size);
63-
bpf_usdt_readarg_p(6, ctx, &msg.msg, MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
64+
bpf_usdt_readarg_p(6, ctx, &msg.msg, _TRACEPOINT_TEST_MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
6465
inbound_messages.perf_submit(ctx, &msg, sizeof(msg));
6566
return 0;
6667
}
@@ -73,7 +74,7 @@
7374
bpf_usdt_readarg_p(3, ctx, &msg.peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
7475
bpf_usdt_readarg_p(4, ctx, &msg.msg_type, MAX_MSG_TYPE_LENGTH);
7576
bpf_usdt_readarg(5, ctx, &msg.msg_size);
76-
bpf_usdt_readarg_p(6, ctx, &msg.msg, MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
77+
bpf_usdt_readarg_p(6, ctx, &msg.msg, _TRACEPOINT_TEST_MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
7778
outbound_messages.perf_submit(ctx, &msg, sizeof(msg));
7879
return 0;
7980
};

0 commit comments

Comments
 (0)