[Toybox] [PATCH] Fix xsignal_all_killers().

enh enh at google.com
Thu Sep 2 12:40:03 PDT 2021


On Wed, Sep 1, 2021 at 9:15 AM Rob Landley <rob at landley.net> wrote:

> On 8/30/21 4:00 PM, enh wrote:
> >     Your commit changed list_signals() to start from 1 but didn't do the
> same for
> >     xsignal_all_killers(). One character fix.
> >
> > yeah, i sent you a more complicated fix in case someone was tempted to
> reorder
> > the array (note that in list_signals() the loop variable is the signal
> number,
> > but in xsignal_all_killers() the loop variable is the array index), but
> (a) your
> > smaller fix works and (b) we know we have a test that will catch this if
> someone
> > does break it, so lgtm :-)
>
> It would break list_signals() if they reordered the list, so I didn't add
> a new
> dependency. :)
>

no, it's cleverer than that... that's what fooled me into not looking for
code that directly accesses the array --- list_signals() iterates through
_signal numbers_ and asks num_to_sig() to search the table for each one:

  for (; i<=NSIG; i++) {
    if ((name = num_to_sig(i))) {
      printf("%2d) SIG%-9s", i, name);
      if (++count % cols == 0) putchar('\n');
    }
  }


> > thanks! (and sorry for not running all the tests! it's _just_ slow
> enough on my
> > laptop to run them all that i tend to only run the specific toy's tests.)
>
> Eh, I should have done it here myself. (Touching an individual command file
> doesn't break other commands, but touching lib/ or main.c does.)
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210902/dece50e5/attachment.htm>


More information about the Toybox mailing list