From: Ackerley Tng <ackerleytng@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, seanjc@google.com
Subject: Re: [PATCH] KVM: guest_memfd: Drop a superfluous local var in kvm_gmem_fault_user_mapping()
Date: Thu, 09 Oct 2025 16:46:33 -0700 [thread overview]
Message-ID: <diqza51zhc4m.fsf@google.com> (raw)
In-Reply-To: <20251007222733.349460-1-seanjc@google.com> (message from Sean Christopherson on Tue, 7 Oct 2025 15:27:33 -0700)
Sean Christopherson <seanjc@google.com> writes:
> Drop the local "int err" that's buried in the middle guest_memfd's user
> fault handler to avoid the potential for variable shadowing, e.g. if an
> "err" variable were also declared at function scope.
>
Is the takeaway here that the variable name "err", if used, should be
defined at function scope?
IOW, would this code have been okay if any other variable name were
used, like if err_folio were used instead of err?
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Ackerley Tng <ackerleytng@google.com>
> ---
> virt/kvm/guest_memfd.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 94bafd6c558c..abbec01d7a3a 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -330,12 +330,10 @@ static vm_fault_t kvm_gmem_fault_user_mapping(struct vm_fault *vmf)
>
> folio = kvm_gmem_get_folio(inode, vmf->pgoff);
> if (IS_ERR(folio)) {
> - int err = PTR_ERR(folio);
> -
> - if (err == -EAGAIN)
> + if (PTR_ERR(folio) == -EAGAIN)
> return VM_FAULT_RETRY;
>
> - return vmf_error(err);
> + return vmf_error(PTR_ERR(folio));
> }
>
> if (WARN_ON_ONCE(folio_test_large(folio))) {
>
> base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac
next prev parent reply other threads:[~2025-10-09 23:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 22:27 [PATCH] KVM: guest_memfd: Drop a superfluous local var in kvm_gmem_fault_user_mapping() Sean Christopherson
2025-10-09 23:46 ` Ackerley Tng [this message]
2025-10-10 22:11 ` Sean Christopherson
2025-10-10 22:33 ` Ackerley Tng
2025-10-15 18:02 ` Sean Christopherson
2025-10-20 15:51 ` Sean Christopherson
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=diqza51zhc4m.fsf@google.com \
--to=ackerleytng@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox