public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>, libc-alpha@sourceware.org
Cc: jakub@redhat.com, fweimer@redhat.com
Subject: Re: [PATCH v5 1/2] string: _FORTIFY_SOURCE=3 using __builtin_dynamic_object_size
Date: Fri, 18 Dec 2020 14:12:55 -0800	[thread overview]
Message-ID: <f9bd77e1-cb6f-8521-78ea-2aea872bf704@cs.ucla.edu> (raw)
In-Reply-To: <20201216152410.232149-2-siddhesh@sourceware.org>

On 12/16/20 7:24 AM, Siddhesh Poyarekar via Libc-alpha wrote:

> +# elif _FORTIFY_SOURCE > 3 && __glibc_clang_prereq(9, 0)
> +#  warning _FORTIFY_SOURCE > 3 unsupported falling back to 3
> +#  define __USE_FORTIFY_LEVEL 3
> +# elif _FORTIFY_SOURCE > 3
> +#  warning _FORTIFY_SOURCE > 3 unsupported falling back to 2

That'd be a strange warning to get, no?

> +#  define __USE_FORTIFY_LEVEL 2
> +# elif _FORTIFY_SOURCE > 2 && !__glibc_clang_prereq(9, 0)
> +#  warning _FORTIFY_SOURCE=3 requires LLVM 9.0 or later, falling back to 2
> +#  define __USE_FORTIFY_LEVEL 2
> +# elif _FORTIFY_SOURCE > 2
> +#  define __USE_FORTIFY_LEVEL 3
>  # elif _FORTIFY_SOURCE > 1
>  #  define __USE_FORTIFY_LEVEL 2

This code is in an unusual order 3, 2, 2, 3, 2 for __USE_FORTIFY_LEVEL, 
which makes it hard to follow.

Also, the warning shouldn't imply that one should use LLVM 9.0 or later. 
It's not our job to recommend LLVM versions, plus that warning's wording 
would likely become dated anyway.

Also, there should be spaces before the parens.

How about something like the following instead?  It uses simpler and more 
future-proof warnings, and I find it easier to follow:

   +# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
   +#  if _FORTIFY_SOURCE > 3
   +#   warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
   +#  endif
   +#  define __USE_FORTIFY_LEVEL 3
    # elif _FORTIFY_SOURCE > 1
   +#  if _FORTIFY_SOURCE > 2
   +#   warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
   +#  endif
    #  define __USE_FORTIFY_LEVEL 2

  reply	other threads:[~2020-12-18 22:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 15:24 [PATCH v5 0/2] _FORTIFY_SOURCE=3 Siddhesh Poyarekar
2020-12-16 15:24 ` [PATCH v5 1/2] string: _FORTIFY_SOURCE=3 using __builtin_dynamic_object_size Siddhesh Poyarekar
2020-12-18 22:12   ` Paul Eggert [this message]
2020-12-19  6:22     ` Siddhesh Poyarekar
2020-12-16 15:24 ` [PATCH v5 2/2] nonstring: " Siddhesh Poyarekar
2020-12-18  4:01 ` [PATCH v5 0/2] _FORTIFY_SOURCE=3 Siddhesh Poyarekar

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=f9bd77e1-cb6f-8521-78ea-2aea872bf704@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=jakub@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@sourceware.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).