On Thu, 24 Jul 2025 22:51:51 -0400
Steven Rostedt <[email protected]> wrote:

> +#define for_each_shdr_str(len, ehdr, sec)    \
> +     for (const char *str = (void *)(ehdr) + shdr_offset(sec),       \
> +                     *end = (str) + shdr_size(sec);                  \
> +          len = strlen(str), (str) < end;                            \
> +          str += (len) + 1, len = strlen(str))

The second "len = strlen(str)" can be removed as the len = strlen(str) in
the conditional will work for every iteration too.

To keep the "end" from being declared before the loop, I had to have both
str and end declared in the loop as "const char *", but that meant I
couldn't initialize "len" in the start portion of the for loop. I then
moved it to the conditional portion, but forgot to remove it from the
increment portion.

The above should look like:

        for (const char *str = (void *)(ehdr) + shdr_offset(sec),
                        *end = str + shdr_size(sec);
             len = strlen(str), str < end;
             str += (len) + 1)

-- Steve

Reply via email to