Re: [PATCH 02/10] compiler.h: drop fallback overflow checkers
From: Nick Desaulniers <hidden>
Date: 2021-09-14 15:34:11
Also in:
lkml
On Fri, Sep 10, 2021 at 5:04 PM Nathan Chancellor [off-list ref] wrote:
On Fri, Sep 10, 2021 at 04:40:39PM -0700, Nick Desaulniers wrote:quoted
diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 0f12345c21fb..4669632bd72b 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h@@ -6,12 +6,9 @@ #include <linux/limits.h> /* - * In the fallback code below, we need to compute the minimum and - * maximum values representable in a given type. These macros may also - * be useful elsewhere, so we provide them outside the - * COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW block. - * - * It would seem more obvious to do something like + * We need to compute the minimum and maximum values representable in a given + * type. These macros may also be useful elsewhere. It would seem more obvious + * to do something like: * * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0) * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0)The signed and type macros right below this comment can be removed as they were only used in the !COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW case.
Did you check for users outside of this header? I see: type_min -> lib/test_scanf.c:189 include/rdma/uverbs_ioctl.h:951 include/rdma/uverbs_ioctl.h:973 type_max -> lib/test_scanf.c:189 lib/test_scanf.c:190 include/rdma/uverbs_ioctl.h:952 include/rdma/uverbs_ioctl.h:962 include/rdma/uverbs_ioctl.h:974 include/rdma/uverbs_ioctl.h:985 is_signed_type has many many users throughout the kernel. Or were you referring to other defines?
Also applies to the tools/ version.
The version in tools/ should probably be "refreshed" ie. copy+pasted over. Why there is a separate copy under tools/... -- Thanks, ~Nick Desaulniers