public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
* switch fallthrough change
@ 2020-08-05 20:52 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-08-05 20:52 UTC (permalink / raw)
  To: cygwin-developers

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-05 20:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 20:52 switch fallthrough change Corinna Vinschen

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