linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Joe Perches <joe@perches.com>, Arnd Bergmann <arnd@kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	llvm@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/10] compiler.h: drop fallback overflow checkers
Date: Tue, 14 Sep 2021 09:04:43 -0700	[thread overview]
Message-ID: <8d1f262c-77fb-c40c-ac96-1c2c4eb36011@kernel.org> (raw)
In-Reply-To: <CAKwvOdn==O+yJHLbxSEyx=xwpKbOsXY9_YkyU2m7+kiEwtPMrA@mail.gmail.com>

On 9/14/2021 8:33 AM, Nick Desaulniers wrote:
> On Fri, Sep 10, 2021 at 5:04 PM Nathan Chancellor <nathan@kernel.org> wrote:
>>
>> On Fri, Sep 10, 2021 at 04:40:39PM -0700, Nick Desaulniers wrote:
>>> 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?

Ah, I did not even think to look outside this file, I figured they were 
intended to only be used here :/ good catch.

>>
>> 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/...
> 

Yes, they probably should, as I noted in commit d0ee23f9d78b ("tools: 
compiler-gcc.h: Guard error attribute use with __has_attribute"). At the 
same time, I don't really want to do it :)

Cheers,
Nathan

  reply	other threads:[~2021-09-14 16:04 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 23:40 [PATCH 00/10] raise minimum GCC version to 5.1 Nick Desaulniers
2021-09-10 23:40 ` [PATCH 01/10] Documentation: raise minimum supported version of GCC " Nick Desaulniers
2021-09-10 23:55   ` Nathan Chancellor
2021-09-11  0:16     ` Nick Desaulniers
2021-09-13 16:22   ` Kees Cook
2021-09-10 23:40 ` [PATCH 02/10] compiler.h: drop fallback overflow checkers Nick Desaulniers
2021-09-11  0:04   ` Nathan Chancellor
2021-09-14 15:33     ` Nick Desaulniers
2021-09-14 16:04       ` Nathan Chancellor [this message]
2021-09-13 16:21   ` Kees Cook
2021-09-10 23:40 ` [PATCH 03/10] mm/ksm: remove old GCC 4.9+ check Nick Desaulniers
2021-09-11  0:07   ` Nathan Chancellor
2021-09-13 16:22   ` Kees Cook
2021-09-10 23:40 ` [PATCH 04/10] Kconfig.debug: drop GCC 5+ version check for DWARF5 Nick Desaulniers
2021-09-11  0:08   ` Nathan Chancellor
2021-09-13 16:23   ` Kees Cook
2021-09-10 23:40 ` [PATCH 05/10] riscv: remove Kconfig check for GCC version for ARCH_RV64I Nick Desaulniers
2021-09-11  0:09   ` Nathan Chancellor
2021-09-13 16:23   ` Kees Cook
2021-10-05  0:40     ` Palmer Dabbelt
2021-10-05  0:50       ` Kees Cook
2021-10-05  0:57         ` Palmer Dabbelt
2021-09-10 23:40 ` [PATCH 06/10] powerpc: remove GCC version check for UPD_CONSTR Nick Desaulniers
2021-09-10 23:48   ` Nathan Chancellor
2021-09-11 10:43     ` Michael Ellerman
2021-09-11 15:34   ` Christophe Leroy
2021-09-10 23:40 ` [PATCH 07/10] arm64: remove GCC version check for ARCH_SUPPORTS_INT128 Nick Desaulniers
2021-09-11  0:10   ` Nathan Chancellor
2021-09-13 16:25   ` Kees Cook
2021-09-16 13:23   ` Catalin Marinas
2021-09-10 23:40 ` [PATCH 08/10] Makefile: drop GCC < 5 -fno-var-tracking-assignments workaround Nick Desaulniers
2021-09-11  0:11   ` Nathan Chancellor
2021-09-13 16:25   ` Kees Cook
2021-09-10 23:40 ` [PATCH 09/10] compiler-gcc.h: drop checks for older GCC versions Nick Desaulniers
2021-09-11  0:12   ` Nathan Chancellor
2021-09-13 16:26   ` Kees Cook
2021-09-10 23:40 ` [PATCH 10/10] vmlinux.lds.h: remove old check for GCC 4.9 Nick Desaulniers
2021-09-10 23:50   ` Nathan Chancellor
2021-09-14 15:21     ` Nick Desaulniers
2021-09-13 16:28   ` Kees Cook
2021-09-11  2:19 ` [PATCH 00/10] raise minimum GCC version to 5.1 Kees Cook
2021-09-11 10:42   ` Michael Ellerman
2021-09-13  9:49 ` Pavel Machek
2021-09-13 16:20   ` Kees Cook
2021-09-13 11:27 ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d1f262c-77fb-c40c-ac96-1c2c4eb36011@kernel.org \
    --to=nathan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@kernel.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH 02/10] compiler.h: drop fallback overflow checkers' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).