Re: [PATCH 2/4] kmsan: another take at fixing memcpy tests

From: Alexander Potapenko
Date: Thu Mar 02 2023 - 09:50:48 EST


> > +#define DO_NOT_OPTIMIZE(var) asm("" ::: "memory")
>
> That's just a normal "barrier()" - use that instead?

Ok, will do (I still think I'd better hide it behind a macro so that
we can change the implementation of DO_NOT_OPTIMIZE in the future if
the compiler starts outsmarting us again.

> > +/*
> > + * Test case: ensure that memcpy() correctly copies initialized values.
> > + */
> > +static void test_init_memcpy(struct kunit *test)
> > +{
> > + EXPECTATION_NO_REPORT(expect);
> > + volatile int src;
> > + volatile int dst = 0;
> > +
> > + // Ensure DO_NOT_OPTIMIZE() does not cause extra checks.
>
> ^^ this comment seems redundant now, given DO_NOT_OPTIMIZE() has a
> comment (it's also using //-style comment).

Moved it to the test description:

/*
* Test case: ensure that memcpy() correctly copies initialized values.
* Also serves as a regression test to ensure DO_NOT_OPTIMIZE() does not cause
* extra checks.
*/

I think it's still relevant here.