[PATCH] as: fix bpf expression parsing regression

Will Hawkins hawkinsw@obs.cr
Mon Feb 19 16:32:21 GMT 2024


On Mon, Feb 19, 2024 at 6:16 AM Nick Clifton <nickc@redhat.com> wrote:
>
> Hi Will,
>
> > As a result of a switch instead of an if, as would issue non-specific
> > error messages when it encountered an operand it could not parse in bpf.
> > This patch fixes that regression and adds a test to prevent it from
> > reoccurring.
> >
> > Tested for bpf-unknown-none on x86_64-redhat-linux.
>
> Approved - please apply.
>
> > -  switch (exp->X_op == O_absent || exp_parse_failed)
> > +  if (exp->X_op == O_absent || exp_parse_failed)
> >       return NULL;
>
> I have to say that I am surprised that the original version of this
> code compiled at all.  Or at least compiled without generating any
> kind of warning message.

Funny you mentioned that! I only saw this problem because I compiled
with clang on macOS and it failed to compile. There are warnings for
gcc that will detect this idiom
(https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wswitch-bool)
and an unreachable body of a switch
(https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wswitch-unreachable)
but for some reason (and I tried multiple invocations) this did not
trigger it.

I hope the patch helps!

Thank you for accepting it!

Sincerely,
Will


>
> Cheers
>    Nick
>
>


More information about the Binutils mailing list