public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: switch fallthrough change
Date: Wed, 5 Aug 2020 22:52:54 +0200	[thread overview]
Message-ID: <20200805205254.GG1107715@calimero.vinschen.de> (raw)

Hi folks,

Just a small headsup here.

I introduced a change already in the Linux kernel for a couple of
months.  Rather than various comments /*FALLTHRU*/, /* fall through */,
etc., Cygwin is using a statement

  fallthrough;

at the end of a switch case intentionally falling through to the
next case branch.  This is using a GCC attribute under the hood,
__attribute__ ((__fallthrough__)) introduced with GCC 7.1.

The advantage is a better control of the way a switch case ends.
It now *has* to end with either one of

  break;
  fallthrough;
  goto <label>;
  return [expression];
  continue;

otherwise GCC complains.  For this I added -Wimplicit-fallthrough=5 to
our build flags.  Just by checking our switch statements I found a
couple of missing break statements as well as one or two missing
intentional fallthrough comments.

For now this only affects the cygwin dir, not the utils or cygserver
dirs, lacking a common header file for this purpose.  Patches welcome.


Corinna

                 reply	other threads:[~2020-08-05 20:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200805205254.GG1107715@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-developers@cygwin.com \
    /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).