From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752933AbdK2IUR (ORCPT ); Wed, 29 Nov 2017 03:20:17 -0500 Received: from mail-qk0-f172.google.com ([209.85.220.172]:39221 "EHLO mail-qk0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752530AbdK2IUP (ORCPT ); Wed, 29 Nov 2017 03:20:15 -0500 X-Google-Smtp-Source: AGs4zMazCa1ybKZc2Q6GogQK1KwQd4cL0w8asN5gv3N97wNjGlH40rwz97RXzhLX9rymq5010hv1VHRZKQEK62qLMAU= MIME-Version: 1.0 In-Reply-To: <1511917656.19952.52.camel@perches.com> References: <20171127235253.GA20384@embeddedor.com> <20171128120512.Horde.1mz61Up1PsNtyHbrjWmK8L7@gator4166.hostgator.com> <20171128122235.Horde.vFP-9ZfAP0f9BFNePB8Z8xi@gator4166.hostgator.com> <20171128190032.2b1fa464@alans-desktop> <20171128143714.Horde.2uPOfQfKWjP7aGfH2w0lflN@gator4166.hostgator.com> <1511917656.19952.52.camel@perches.com> From: Geert Uytterhoeven Date: Wed, 29 Nov 2017 09:20:13 +0100 X-Google-Sender-Auth: p6ThJa6iQvnk1tGhcUc0pn5cqVg Message-ID: Subject: Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs To: Joe Perches Cc: "Gustavo A. R. Silva" , Linus Torvalds , Alan Cox , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "the arch/x86 maintainers" , LKML , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joe, On Wed, Nov 29, 2017 at 2:07 AM, Joe Perches wrote: > On Tue, 2017-11-28 at 14:37 -0600, Gustavo A. R. Silva wrote: >> Quoting Linus Torvalds : >> > On Tue, Nov 28, 2017 at 11:00 AM, Alan Cox >> > wrote: >> > > The notation in question has been standard in tools like lint since the >> > > end of the 1970s >> > >> > Yes. >> > >> > That said, maybe one option would be to annotate the "case:" and >> > "default:" statements if that makes people happier. >> > >> > IOW, we could do something like >> > >> > #define fallthrough __atttibute__((fallthrough)) >> > >> > and then write >> > >> > fallthrough case 1: >> > ... >> > >> > which while absolutely not traditional, might look and read a bit more >> > logical to people. I mean, it literally _is_ a "fallthrough case", so >> > it makes semantic sense. >> > >> >> This is elegant. The thing is that this makes it appear as if there is >> an unconditional fall through. >> >> It is not uncommon to have multiple break statements in the same case >> block and to fall through also. > > My preferred syntax would be to use __fallthrough or fallthrough > in the same manner as break; > > switch (foo) { > case bar: > bar(); > fallthrough; > case baz: > baz(); > break; > default; > qux(); > exit(1); > } Makes sense to me. Comments are fragile. In addition, they are stripped if you run cpp (or gcc -E) separately, unlike __atttibute__((fallthrough)). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds