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

Re: [XEN PATCH 02/11] x86: move declarations to address MISRA C:2012 Rule 2.1


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 3 Aug 2023 11:05:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ct6eL2qweUjt6jjItz65Fg+I3CL67e6ZcInGGy57IiA=; b=FHCu2vf4XTRm8PhNG3/yL+s1lp7hQLiWsbvLlsM/X/OW4+6nBuN51/sgxEJU8ra0EWDNk6NXJ3ZHhl0aCeulcWwETjL8dVXom8ighLv1rHdJGJFdBQ5Xo9Dt0ImEt9CPOPMHchbSkz3Kl2s48QhqqPtMPqlB+jam82rgLd3GXc3y60ajjgx/Es6wlLzHCHjMNPclZrGUyeNCZ4prBYrU+PA/4MXfvWF3SIR6ryyI4P6tKCvVU8/SrtmfcWQcUCt8vrgqISMW3prDOG4CZEFOo2zNLBU+wHeg/ndm1LqqWJ5sEhUEWyfKD39mqLHzuASEXpQPsqfGfJnKcKqZ5CXuZw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyrX5O5fkmHRBI54yX/NnCP/daYMi+9aKIdG8MH5WGkLSvJcYbaxOQubjJg5CY7EiHHsdq3BVj+0kM/V6Z17ulBboLxfitPlp+XgDrEMYb5QFo0B6Pc5xjbSFPwEbzymvjj9UMoiENUHbXsHwMj+HlXjabXDaRcBNI2PMn8Y5HZKjdI2YdL02elvn6KuXaFL5KfSX3eIu3K6/PQFwTJfz5Y9JnQNWAmBMLL8F3zz26LW2mMzjE6xCbSodZRa5qweteHbw7llXavNb0PREoWAYu9Ma642ks4XhJFM2lUNI5Ay8A7n46eqaAI4QI1i4vO4r2tulKIOHZ51sPXVWu7qHQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 03 Aug 2023 09:05:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.08.2023 16:38, Nicola Vetrini wrote:
> Variable declarations between a switch statement guard and before
> any case label are unreachable code, and hence violate Rule 2.1:
> "A project shall not contain unreachable code".
> 
> Therefore the declarations are moved in the smallest enclosing
> scope, near other variable definitions.

This needs further clarification: There's no "code" involved here
in the sense that a compiler might eliminate it. Yet that's what
the rule's rationale is focusing on. There's no even mention of
declarations like the ones you move. In particular (and on top
of my comment on patch 1) ...

> --- a/xen/arch/x86/cpuid.c
> +++ b/xen/arch/x86/cpuid.c
> @@ -37,6 +37,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
>  {
>      const struct domain *d = v->domain;
>      const struct cpu_policy *p = d->arch.cpu_policy;
> +    const struct cpu_user_regs *regs;
>  
>      *res = EMPTY_LEAF;
>  
> @@ -136,8 +137,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
>       */
>      switch ( leaf )
>      {
> -        const struct cpu_user_regs *regs;
> -
>      case 0x1:
>          /* TODO: Rework topology logic. */
>          res->b &= 0x00ffffffu;

... I'm not happy to see scopes of variables widened.

Jan



 


Rackspace

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