[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZG+LZ4rATc8elt38@google.com>
Date: Thu, 25 May 2023 09:23:03 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Jinrong Liang <ljr.kernel@...il.com>
Cc: Like Xu <like.xu.linux@...il.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Jonathan Corbet <corbet@....net>,
Shuah Khan <shuah@...nel.org>,
Aaron Lewis <aaronlewis@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Vishal Annapurve <vannapurve@...gle.com>,
Wanpeng Li <wanpengli@...cent.com>,
Bagas Sanjaya <bagasdotme@...il.com>,
Jinrong Liang <cloudliang@...cent.com>,
linux-kselftest@...r.kernel.org, linux-doc@...r.kernel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/7] KVM: selftests: Replace int with uint32_t for nevents
On Thu, Apr 20, 2023, Jinrong Liang wrote:
> From: Jinrong Liang <cloudliang@...cent.com>
>
> From: Jinrong Liang <cloudliang@...cent.com>
>
> Defined as type __u32, the nevents field in kvm_pmu_event_filter
> can only accept positive values within a specific range. Therefore,
> replacing int with uint32_t for nevents ensures consistency and
> readability in the code.
Not really. It fixes one type of inconsistency that is fairly common (userspace
passing an integer count to the kernel), and replaces it with a different type
of inconsistency (signed iterator comparing against an unsigned count). There's
already one of those in remove_event(), but I'd rather not create more.
Passing an unsigned int to track what *should* be a small-ish, postive integer
can also make it more difficult to detect bugs, e.g. assertions like this won't
work:
TEST_ASSERT(nevents >= 0);
If this code were being written from scratch then I wouldn't object to using
uint32_t everywhere, but I don't see the point of trying to retroactively change
the code.
Powered by blists - more mailing lists