public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: CGEL <cgel.zte@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Jing Yangyang <jing.yangyang@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] x86:mmu: fix boolreturn.cocci warnings
Date: Wed, 25 Aug 2021 17:59:17 +0000	[thread overview]
Message-ID: <YSaE9Umzb33B12kY@google.com> (raw)
In-Reply-To: <20210824071052.61304-1-deng.changcheng@zte.com.cn>

"KVM: x86/mmu" in the shortlog please.

On Tue, Aug 24, 2021, CGEL wrote:
> From: Jing Yangyang <jing.yangyang@zte.com.cn>
> 
> ./arch/x86/kvm/mmu/mmu.c:1501: 9-10:WARNING:return of 0/1 in
> function 'kvm_set_pte_rmapp' with return type bool
> ./arch/x86/kvm/mmu/mmu.c:1642:10-11:WARNING:return of 0/1 in
> function 'kvm_test_age_rmapp' with return type bool

Huh, I could have sworn this was fixed, but obviously not.

> Return statements in functions returning bool should use true/false
> instead of 1/0.
> 
> Generated by: scripts/coccinelle/misc/boolreturn.cocci
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>
> ---
>  arch/x86/kvm/mmu/mmu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index c5232a0..78025e0 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -1498,7 +1498,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
>  
>  	if (need_flush && kvm_available_flush_tlb_with_range()) {
>  		kvm_flush_remote_tlbs_with_address(kvm, gfn, 1);
> -		return 0;
> +		return false;

Please also fix need_flush in this function, e.g. 

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 4853c033e6ce..0a275d988c7d 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1456,7 +1456,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
 {
        u64 *sptep;
        struct rmap_iterator iter;
-       int need_flush = 0;
+       bool need_flush = false;
        u64 new_spte;
        kvm_pfn_t new_pfn;

@@ -1468,7 +1468,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
                rmap_printk("spte %p %llx gfn %llx (%d)\n",
                            sptep, *sptep, gfn, level);

-               need_flush = 1;
+               need_flush = true;

                if (pte_write(pte)) {
                        pte_list_remove(kvm, rmap_head, sptep);

>  	}
>  
>  	return need_flush;
> @@ -1639,8 +1639,8 @@ static bool kvm_test_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
>  
>  	for_each_rmap_spte(rmap_head, &iter, sptep)
>  		if (is_accessed_spte(*sptep))
> -			return 1;
> -	return 0;
> +			return true;
> +	return false;
>  }
>  
>  #define RMAP_RECYCLE_THRESHOLD 1000
> -- 
> 1.8.3.1
> 
> 

      reply	other threads:[~2021-08-25 17:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  7:10 [PATCH linux-next] x86:mmu: fix boolreturn.cocci warnings CGEL
2021-08-25 17:59 ` Sean Christopherson [this message]

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=YSaE9Umzb33B12kY@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=cgel.zte@gmail.com \
    --cc=jing.yangyang@zte.com.cn \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    --cc=zealci@zte.com.cn \
    /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