lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v2 1/7] KVM: selftests: Replace int with uint32_t for nevents
    From
    On Thu, Apr 20, 2023, Jinrong Liang wrote:
    > From: Jinrong Liang <cloudliang@tencent.com>
    >
    > From: Jinrong Liang <cloudliang@tencent.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.

    \
     
     \ /
      Last update: 2023-05-25 18:24    [W:5.980 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site