Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31419: test: fix MIN macro redefinition
Browse files Browse the repository at this point in the history
00c1dbd test: fix MIN macro-redefinition (0xb10c)

Pull request description:

  Renames the `MIN` macro to `_TRACEPOINT_TEST_MIN`.

  From #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/bitcoin#31418

ACKs for top commit:
  maflcko:
    review ACK 00c1dbd

Tree-SHA512: 1d91ed8b3c0b0410d42a11004286359546c17613c3ff03dd51c26896ee050e9280fff69fa2eaa6e6085f9b611663bcacedec80997a6c5e37874a79ba86bfa507
  • Loading branch information
fanquake committed Dec 4, 2024
2 parents 39950e1 + 00c1dbd commit 893ccea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/functional/interface_usdt_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
MAX_MSG_TYPE_LENGTH,
MAX_MSG_DATA_LENGTH
) + """
#define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
// A min() macro. Prefixed with _TRACEPOINT_TEST to avoid collision with other MIN macros.
#define _TRACEPOINT_TEST_MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
struct p2p_message
{
Expand All @@ -60,7 +61,7 @@
bpf_usdt_readarg_p(3, ctx, &msg.peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
bpf_usdt_readarg_p(4, ctx, &msg.msg_type, MAX_MSG_TYPE_LENGTH);
bpf_usdt_readarg(5, ctx, &msg.msg_size);
bpf_usdt_readarg_p(6, ctx, &msg.msg, MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
bpf_usdt_readarg_p(6, ctx, &msg.msg, _TRACEPOINT_TEST_MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
inbound_messages.perf_submit(ctx, &msg, sizeof(msg));
return 0;
}
Expand All @@ -73,7 +74,7 @@
bpf_usdt_readarg_p(3, ctx, &msg.peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH);
bpf_usdt_readarg_p(4, ctx, &msg.msg_type, MAX_MSG_TYPE_LENGTH);
bpf_usdt_readarg(5, ctx, &msg.msg_size);
bpf_usdt_readarg_p(6, ctx, &msg.msg, MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
bpf_usdt_readarg_p(6, ctx, &msg.msg, _TRACEPOINT_TEST_MIN(msg.msg_size, MAX_MSG_DATA_LENGTH));
outbound_messages.perf_submit(ctx, &msg, sizeof(msg));
return 0;
};
Expand Down

0 comments on commit 893ccea

Please sign in to comment.