All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Teddy Astie <teddy.astie@vates.tech>
Subject: Re: [PATCH 2/5] x86/PV: rename a local variable in pv_emulate_gate_op()
Date: Fri, 22 May 2026 12:24:00 +0200	[thread overview]
Message-ID: <ahAuwEqst5aCJSj2@macbook.local> (raw)
In-Reply-To: <871c0ca7-898f-4bc6-8115-d94d40b88301@suse.com>

On Wed, May 13, 2026 at 01:44:47PM +0200, Jan Beulich wrote:
> ... shadowing a function scope one, thus violating Misra C:2012 rule 5.3
> ("An identifier declared in an inner scope shall not hide an identifier
> declared in an outer scope"). No difference in generated code.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> Technically, as the outer scope "rc" isn't used again later, we could
> simply drop the inner decl. That seemed more error prone to me, though.
> 
> --- a/xen/arch/x86/pv/emul-gate-op.c
> +++ b/xen/arch/x86/pv/emul-gate-op.c
> @@ -286,16 +286,16 @@ void pv_emulate_gate_op(struct cpu_user_
>      if ( !jump )
>      {
>          unsigned int ss, esp, *stkp;
> -        int rc;
> +        int left;
>  #define push(item) do \
>          { \
>              --stkp; \
>              esp -= 4; \
> -            rc = __put_guest(item, stkp); \
> -            if ( rc ) \
> +            left = __put_guest(item, stkp); \
> +            if ( left ) \
>              { \
>                  pv_inject_page_fault(PFEC_write_access, \
> -                                     (unsigned long)(stkp + 1) - rc); \
> +                                     (unsigned long)(stkp + 1) - left); \
>                  return; \
>              } \
>          } while ( 0 )
> @@ -359,10 +359,11 @@ void pv_emulate_gate_op(struct cpu_user_
>                      unsigned int parm;
>  
>                      --ustkp;
> -                    rc = __get_guest(parm, ustkp);
> -                    if ( rc )
> +                    left = __get_guest(parm, ustkp);
> +                    if ( left )
>                      {
> -                        pv_inject_page_fault(0, (unsigned long)(ustkp + 1) - rc);
> +                        pv_inject_page_fault(0,
> +                                             (unsigned long)(ustkp + 1) - left);

__{put,get}_guest() return -EFAULT on error, and hence the
addition/subtraction here is wrong AFAICT.

Thanks, Roger.


  reply	other threads:[~2026-05-22 10:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 11:43 [PATCH 0/5] x86: Misra rule 5.3 Jan Beulich
2026-05-13 11:44 ` [PATCH 1/5] x86/guest: rename a local variable Jan Beulich
2026-05-13 21:17   ` Nicola Vetrini
2026-05-15 11:00   ` Andrew Cooper
2026-05-13 11:44 ` [PATCH 2/5] x86/PV: rename a local variable in pv_emulate_gate_op() Jan Beulich
2026-05-22 10:24   ` Roger Pau Monné [this message]
2026-05-22 10:25     ` Andrew Cooper
2026-05-13 11:45 ` [PATCH 3/5] x86/shadow: conditionalize / rename local variables Jan Beulich
2026-05-22 10:28   ` Roger Pau Monné
2026-05-13 11:46 ` [PATCH 4/5] x86/shadow: split a nested max() invocation Jan Beulich
2026-05-14  5:08   ` Nicola Vetrini
2026-05-15  6:15     ` Jan Beulich
2026-05-13 11:46 ` [PATCH 5/5] x86/shadow: rename a parameter of shadow_l<N>_index() Jan Beulich
2026-05-22 10:30   ` Roger Pau Monné

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=ahAuwEqst5aCJSj2@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /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.