[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 08/11] xen/compiler: import 'fallthrough' keyword from linux


  • To: Rahul Singh <Rahul.Singh@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 12 Jan 2021 11:36:21 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xQ8sdCuQpZ8aafS6v6i39dOZitmU8Op4n+cuk7Sy9P8=; b=aGmKvRQxLw3cRmgAOWCHFVuTn5tG/TGCLc5SoSh688nIuKDRY4xLvccKxLrSeHpm57X6eEpeyxqMAY35Y2lHPfQG6tTHWyw3osrUOXnkBVkEsqZr7UvmQpA4V0GOsKc6xo7II/KUYPOlhsc6cQ9PsANQJn1WNLfXWTeM6rZ6VkX6HaJS2CpSebdTLp6WxX6J3B20cPvTJJ2NGZSo6mMJpOIu+xV5uxCRaRCR6EcWDZgGT1msiZZF96dq+5c5Dk8ojhfH3Age5G+CvwOI/i727YLccJKQ0BecbH894SvbPepE5dlh8LLX41STOk5fRjXwWd67z9MJRE1Zn8CNmJccEw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ngPcQ0n0lrTq7dSnA0cHbcTvH5STz4xy9WehVuM+CNXQkgbZ6GhQ8MFwzH5vHksPzgMxpUqFoKPXZEdZSOSus2nW2bQBy9lurJtJScpqrwBripOPwk4QL0ZFYPCS9l+/tNNR4Kt9Y2PBq2khNI5AcK+f8PwGpGwD96FwkAdXotgyh4kxlwHO8N3Qnx74vcdh3mzb3Dr9Q/cwE0Ke9X7nW5EkM1H7WidvT4nUopUb0TU9urqjk/5PI6RSPWpikaY+AGXMu5A/OwpQ4uURapK+qlXQ8WSJil2MAGovEj3R3FCCCXFxlv//F2hGWRs8g4EGdGOXZvf0BkNpRYP6b22fhw==
  • Authentication-results-original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 12 Jan 2021 11:36:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHW5c27CajBWtWb2Eu4HMlGCx2Xjqoj4q8A
  • Thread-topic: [PATCH v4 08/11] xen/compiler: import 'fallthrough' keyword from linux

Hi,

> On 8 Jan 2021, at 14:46, Rahul Singh <Rahul.Singh@xxxxxxx> wrote:
> 
> -Wimplicit-fallthrough warns when a switch case falls through. Warning
> can be suppress by either adding a /* fallthrough */ comment, or by
> using a null statement: __attribute__ ((fallthrough))
> 
> Define the pseudo keyword 'fallthrough' for the ability to convert the
> various case block /* fallthrough */ style comments to null statement
> "__attribute__((__fallthrough__))"
> 
> In C mode, GCC supports the __fallthrough__ attribute since 7.1,
> the same time the warning and the comment parsing were introduced.
> 
> fallthrough devolves to an empty "do {} while (0)" if the compiler
> version (any version less than gcc 7) does not support the attribute.
> 
> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> Changes in V4:
> - This patch is introduce in this verison.
> ---
> xen/include/xen/compiler.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
> 
> diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
> index e643e69128..0ec0b4698e 100644
> --- a/xen/include/xen/compiler.h
> +++ b/xen/include/xen/compiler.h
> @@ -33,6 +33,22 @@
> #define unreachable() __builtin_unreachable()
> #endif
> 
> +/*
> + * Add the pseudo keyword 'fallthrough' so case statement blocks
> + * must end with any of these keywords:
> + *   break;
> + *   fallthrough;
> + *   goto <label>;
> + *   return [expression];
> + *
> + *  gcc: 
> https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
> + */
> +#if (!defined(__clang__) && (__GNUC__ >= 7))
> +# define fallthrough        __attribute__((__fallthrough__))
> +#else
> +# define fallthrough        do {} while (0)  /* fallthrough */
> +#endif
> +
> #ifdef __clang__
> /* Clang can replace some vars with new automatic ones that go in .data;
>  * mark all explicit-segment vars 'used' to prevent that. */
> -- 
> 2.17.1
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.