All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: yexingchen116@gmail.com, seanjc@google.com
Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	ye xingchen <ye.xingchen@zte.com.cn>
Subject: Re: [PATCH linux-next] KVM: x86: Replace IS_ERR() with IS_ERR_VALUE()
Date: Mon, 7 Nov 2022 09:30:38 -0800	[thread overview]
Message-ID: <b151d65b-7b67-002c-49f2-b7334c201130@zytor.com> (raw)
In-Reply-To: <20221020113943.400103-1-ye.xingchen@zte.com.cn>

On 10/20/22 04:39, yexingchen116@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Avoid type casts that are needed for IS_ERR() and use
> IS_ERR_VALUE() instead.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>   arch/x86/kvm/x86.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 4bd5f8a751de..1c260f716c3b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -12414,7 +12414,7 @@ void __user * __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
>   		 */
>   		hva = vm_mmap(NULL, 0, size, PROT_READ | PROT_WRITE,
>   			      MAP_SHARED | MAP_ANONYMOUS, 0);
> -		if (IS_ERR((void *)hva))
> +		if (IS_ERR_VALUE(hva))
>   			return (void __user *)hva;
>   	} else {
>   		if (!slot || !slot->npages)

This seems to imply IS_ERR() is misdesigned.

It would be nice to have IS_ERR() contain the appropriate casts. If we 
want to enforce that the argument is a pointer, add IS_ERR_PTR()?

	-hpa

  parent reply	other threads:[~2022-11-07 17:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 11:39 [PATCH linux-next] KVM: x86: Replace IS_ERR() with IS_ERR_VALUE() yexingchen116
2022-10-20 17:37 ` Sean Christopherson
2022-11-07 17:30 ` H. Peter Anvin [this message]
2022-11-16  9:18 ye.xingchen
2023-01-28  0:05 ` 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=b151d65b-7b67-002c-49f2-b7334c201130@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=ye.xingchen@zte.com.cn \
    --cc=yexingchen116@gmail.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.