[Intel-gfx] [PATCH v2] overflow: Introduce overflows_type() and castable_to_type()
Kees Cook
keescook at chromium.org
Mon Sep 26 21:07:14 UTC 2022
On Mon, Sep 26, 2022 at 01:17:18PM -0700, Nick Desaulniers wrote:
> + Arnd
>
> On Mon, Sep 26, 2022 at 12:11 PM Kees Cook <keescook at chromium.org> wrote:
> > ---
> > v2:
> > - fix comment typo
> > - wrap clang pragma to avoid GCC warnings
> > - style nit cleanups
> > - rename __castable_to_type() to castable_to_type()
> > - remove prior overflows_type() definition
> > v1: https://lore.kernel.org/lkml/20220926003743.409911-1-keescook@chromium.org
> > diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c
> > index f385ca652b74..fffc3f86181d 100644
> > --- a/lib/overflow_kunit.c
> > +++ b/lib/overflow_kunit.c
> > @@ -16,6 +16,11 @@
> > #include <linux/types.h>
> > #include <linux/vmalloc.h>
> >
> > +/* We're expecting to do a lot of "always true" or "always false" tests. */
> > +#ifdef CONFIG_CC_IS_CLANG
> > +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
> > +#endif
>
> Any chance we can reuse parts of __diag_ignore or __diag_clang from
> include/linux/compiler_types.h or include/linux/compiler-clang.h
> respectively?
Hm, I'm not sure how those are supposed to be used. Those defines don't
seem to be used externally?
> Those are needed for pragmas within preprocessor macros, which we
> don't have here, but I suspect they may be more concise to use here.
Yeah, I was surprised when I had to wrap it in #ifdef given "clang" is
part of the string.
>
> > +#define TEST_SAME_TYPE(t1, t2, same) do { \
> > + typeof(t1) __t1h = type_max(t1); \
> > + typeof(t1) __t1l = type_min(t1); \
> > + typeof(t2) __t2h = type_max(t2); \
> > + typeof(t2) __t2l = type_min(t2); \
>
> Can we use __auto_type here rather than typeof(macro expansion)?
I'd rather it stay explicit -- otherwise we start to wander into "oops,
we got lucky" territory for what should be a really distinct test case.
--
Kees Cook
More information about the Intel-gfx
mailing list