Skip to content

Commit

Permalink
Define the iterator in the for scope (#190)
Browse files Browse the repository at this point in the history
Otherwise running two FOREACHes in the same scope won't work as it tries to
redefine the variable.
  • Loading branch information
haesbaert authored May 2, 2024
1 parent 02c7f0d commit 62d0aff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions GPL/Events/EbpfEventProto.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ enum ebpf_varlen_field_type {

// Convenience macro to iterate all the variable length fields in an event
#define FOR_EACH_VARLEN_FIELD(vl_fields_start, cursor) \
uint32_t __i = 0; \
cursor = (struct ebpf_varlen_field *)vl_fields_start.data; \
for (; __i < vl_fields_start.nfields; \
cursor = (struct ebpf_varlen_field *)((char *)cursor + cursor->size + \
sizeof(struct ebpf_varlen_field)), \
__i++)
cursor = (struct ebpf_varlen_field *)vl_fields_start.data; \
for (uint32_t __i = 0; __i < vl_fields_start.nfields; \
cursor = (struct ebpf_varlen_field *)((char *)cursor + cursor->size + \
sizeof(struct ebpf_varlen_field)), \
__i++)

struct ebpf_varlen_fields_start {
uint32_t nfields;
Expand Down

0 comments on commit 62d0aff

Please sign in to comment.