From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: zhaoxiao <zhaoxiao@uniontech.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: Fix the warning by the min()
Date: Wed, 17 Nov 2021 22:19:34 +0000 [thread overview]
Message-ID: <YZV/9lsblb4HB+T+@google.com> (raw)
In-Reply-To: <8881d7b4-0c31-cafd-1158-0d42c1c7f43a@redhat.com>
On Tue, Nov 16, 2021, Paolo Bonzini wrote:
> However, the second reason is that "r < 0" is a very common way to express
> "if there was an error". In this case that would be
>
> r = __kvm_io_bus_write(vcpu, bus, &range, val);
> if (r < 0) // "if __kvm_io_bus_write failed"
> return r;
>
> return 0;
>
> That "r < 0" is what will catch the attention of the person that is reading
> the code, no matter if it is an "if" or (as in the existing code), a
> "return". Using "min" removes the idiom that tells the person "this is
> checking for errors".
+1, there is zero chance that I would realize "min(r, 0)" is "handling" errors.
next prev parent reply other threads:[~2021-11-17 22:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211116121014.1675-1-zhaoxiao@uniontech.com>
2021-11-16 15:56 ` [PATCH] KVM: Fix the warning by the min() Paolo Bonzini
2021-11-17 22:19 ` Sean Christopherson [this message]
2021-11-17 0:55 zhaoxiao
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=YZV/9lsblb4HB+T+@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=zhaoxiao@uniontech.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;
as well as URLs for NNTP newsgroup(s).