All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org, michal.orzel@amd.com,
	xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com,
	consulting@bugseng.com,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: Re: [XEN PATCH 01/11] x86/efi: move variable declaration to address MISRA C:2012 Rule 2.1
Date: Fri, 04 Aug 2023 09:12:36 +0200	[thread overview]
Message-ID: <f9c2ad3ce68035e99358cd6aa282b089@bugseng.com> (raw)
In-Reply-To: <3af75576-4a34-ab0e-3c1a-20a143e993e8@suse.com>

On 03/08/2023 10:57, Jan Beulich wrote:
> On 03.08.2023 04:08, Stefano Stabellini wrote:
>> On Wed, 2 Aug 2023, Nicola Vetrini wrote:
>>> The variable declaration is moved where it's actually used, rather
>>> than being declared in the switch before any clause, thus being
>>> classified as unreachable code.
>>> 
>>> No functional changes.
>>> 
>>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>>> ---
>>>  xen/arch/x86/efi/efi-boot.h | 5 ++---
>>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/xen/arch/x86/efi/efi-boot.h 
>>> b/xen/arch/x86/efi/efi-boot.h
>>> index 92f4cfe8bd..b00441b1a2 100644
>>> --- a/xen/arch/x86/efi/efi-boot.h
>>> +++ b/xen/arch/x86/efi/efi-boot.h
>>> @@ -390,8 +390,6 @@ static void __init efi_arch_edd(void)
>>>          {
>>>              switch ( DevicePathType(devp.DevPath) )
>>>              {
>>> -                const u8 *p;
>>> -
>>>              case ACPI_DEVICE_PATH:
>>>                  if ( state != root || boot_edd_info_nr > 
>>> EDD_INFO_MAX )
>>>                      break;
>>> @@ -463,7 +461,8 @@ static void __init efi_arch_edd(void)
>>>                  params->device_path_info_length =
>>>                      sizeof(struct edd_device_params) -
>>>                      offsetof(struct edd_device_params, key);
>>> -                for ( p = (const u8 *)&params->key; p < 
>>> &params->checksum; ++p )
>>> +                for ( const u8 *p = (const u8 *)&params->key;
>>> +                      p < &params->checksum; ++p )
>> 
>> In Xen we don't mix declaration and code. So the following is not
>> something we use:
>> 
>>   for (int i = 0; i < 10; i++)
> 
> You're aware that we gained a couple of such uses already? I also think
> that when we discussed this we said this style could be at least
> okay-ish (until formalized in ./CODING_STYLE).
> 
> What I'm unhappy with here is the retaining of u8, when it could easily
> become uint8_t at this occasion.
> 
> Jan

Sure

-- 
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)


  reply	other threads:[~2023-08-04  7:12 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 14:38 [XEN PATCH 00/11] xen: address MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 01/11] x86/efi: move variable declaration to " Nicola Vetrini
2023-08-03  2:08   ` Stefano Stabellini
2023-08-03  8:57     ` Jan Beulich
2023-08-04  7:12       ` Nicola Vetrini [this message]
2023-08-02 14:38 ` [XEN PATCH 02/11] x86: move declarations " Nicola Vetrini
2023-08-02 14:44   ` Andrew Cooper
2023-08-03  2:13   ` Stefano Stabellini
2023-08-03  9:01     ` Jan Beulich
2023-08-03 14:22       ` Nicola Vetrini
2023-08-03 19:23         ` Stefano Stabellini
2023-08-04  1:14           ` Stefano Stabellini
2023-08-04  7:06         ` Jan Beulich
2023-08-04  9:50           ` Nicola Vetrini
2023-08-04 20:26           ` Stefano Stabellini
2023-08-07  7:18             ` Jan Beulich
2023-08-03  9:05   ` Jan Beulich
2023-08-02 14:38 ` [XEN PATCH 03/11] x86/uaccess: " Nicola Vetrini
2023-08-03  2:14   ` Stefano Stabellini
2023-08-02 14:38 ` [XEN PATCH 04/11] x86emul: move variable definitions " Nicola Vetrini
2023-08-03  2:33   ` Stefano Stabellini
2023-08-03  9:09     ` Jan Beulich
2023-08-02 14:38 ` [XEN PATCH 05/11] drivers/pci: " Nicola Vetrini
2023-08-03  2:36   ` Stefano Stabellini
2023-08-02 14:38 ` [XEN PATCH 06/11] xen/ioreq: move variable declaration " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 07/11] xen: " Nicola Vetrini
2023-08-03  9:16   ` Jan Beulich
2023-08-03 23:50     ` Stefano Stabellini
2023-08-04  6:42       ` Jan Beulich
2023-08-08  9:03         ` Nicola Vetrini
2023-08-16 10:01           ` Nicola Vetrini
2023-08-16 10:31             ` Jan Beulich
2023-08-16 10:47               ` Nicola Vetrini
2023-08-16 11:23                 ` Jan Beulich
2023-08-16 13:43                   ` Nicola Vetrini
2023-08-16 15:00                     ` Jan Beulich
2023-08-16 19:28                   ` Stefano Stabellini
2023-08-18 12:57                     ` Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 08/11] xen: move declarations to " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 09/11] x86/xstate: moved BUILD_BUG_ON " Nicola Vetrini
2023-08-02 14:38 ` [XEN PATCH 10/11] xen/sched: add ASSERT_UNREACHABLE() " Nicola Vetrini
2023-08-03  9:17   ` Jan Beulich
2023-08-07  8:13     ` Nicola Vetrini
2023-08-07  8:50       ` Jan Beulich
2023-08-08 15:25   ` Julien Grall
2023-08-08 15:36     ` Jan Beulich
2023-08-08 15:44       ` Julien Grall
2023-08-08 15:53         ` Nicola Vetrini
2023-08-08 15:57           ` Julien Grall
2023-08-08 21:14             ` Stefano Stabellini
2023-08-09  6:01               ` Jan Beulich
2023-08-11 18:41               ` Julien Grall
2023-08-02 14:38 ` [XEN PATCH 11/11] x86/mm: Add assertion " Nicola Vetrini
2023-08-03  9:20   ` Jan Beulich
2023-08-03  9:30     ` Nicola Vetrini
2023-08-03 15:41       ` Jan Beulich

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=f9c2ad3ce68035e99358cd6aa282b089@bugseng.com \
    --to=nicola.vetrini@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ayan.kumar.halder@amd.com \
    --cc=consulting@bugseng.com \
    --cc=jbeulich@suse.com \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenia.ragiadakou@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.