Re: [PATCH v2 05/17] add support for Clang's Shadow Call Stack (SCS)

Sami Tolvanen
2019-10-25T20:51:52Z

On Fri, Oct 25, 2019 at 9:22 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
> > +static void scs_free(void *s)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < SCS_CACHE_SIZE; i++) {
> > + if (this_cpu_cmpxchg(scs_cache[i], 0, s) != 0)
> > + continue;
> > +
> > + return;
> > + }
>
> prefer:
>
> for ...:
> if foo() == 0:
> return
>
> to:
>
> for ...:
> if foo() != 0:
> continue
> return

This was essentially copied from free_thread_stack in kernel/fork.c,
but I agree, your way is cleaner. I'll change this in the next
version. Thanks!

Sami