All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vihas Mak <makvihas@gmail.com>,
	seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com,
	jmattson@google.com, joro@8bytes.org, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: fix cocci warnings
Date: Tue, 16 Nov 2021 08:38:34 +0100	[thread overview]
Message-ID: <ce66f713-3d5f-cf3f-8813-d25ee1d2cec7@redhat.com> (raw)
In-Reply-To: <20211115204905.GQ174703@worktop.programming.kicks-ass.net>

On 11/15/21 21:49, Peter Zijlstra wrote:
> On Mon, Nov 15, 2021 at 06:06:08PM +0100, Paolo Bonzini wrote:
>> On 11/15/21 12:43, Peter Zijlstra wrote:
>>> On Sun, Nov 14, 2021 at 10:13:12PM +0530, Vihas Mak wrote:
>>>> change 0 to false and 1 to true to fix following cocci warnings:
>>>>
>>>>           arch/x86/kvm/mmu/mmu.c:1485:9-10: WARNING: return of 0/1 in function 'kvm_set_pte_rmapp' with return type bool
>>>>           arch/x86/kvm/mmu/mmu.c:1636:10-11: WARNING: return of 0/1 in function 'kvm_test_age_rmapp' with return type bool
>>>
>>> That script should be deleted, it's absolute garbage.
>>
>> Only a Sith deals in absolutes.
> 
> Is that a star-wars thingy?

Yes, it is.  "If you're not with me, then you're my enemy!" "Only a Sith 
deals in absolutes". :)

> In C 0 is a valid way to spell false, equally, any non-0 value is a
> valid way to spell true. Why would this rate a warn?

Because often 0 means success (if -errno means failure).  So if you 
write false/true consistently for bool and 0 only for int, it's one less 
thing that one can get wrong.  At least that's the rationale.

Paolo

> In fact, when casting _Bool to integer, you get 0 and 1. When looking at
> the memory content of the _Bool variable, you'll get 0 and 1. But we're
> not allowed to write 0 and 1?
> 


      reply	other threads:[~2021-11-16  7:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-14 16:43 [PATCH] KVM: x86: fix cocci warnings Vihas Mak
2021-11-15  9:59 ` Vitaly Kuznetsov
2021-11-15 11:33   ` Vihas Mak
2021-11-16  9:50   ` Paolo Bonzini
2021-11-16 18:16     ` Nick Desaulniers
2021-11-15 11:43 ` Peter Zijlstra
2021-11-15 17:06   ` Paolo Bonzini
2021-11-15 20:49     ` Peter Zijlstra
2021-11-16  7:38       ` Paolo Bonzini [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=ce66f713-3d5f-cf3f-8813-d25ee1d2cec7@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=makvihas@gmail.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.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.