Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp352186rwe; Fri, 14 Apr 2023 04:02:12 -0700 (PDT) X-Google-Smtp-Source: AKy350YsnKmgf11W91dpVdo9KhmsRvh444k+Rglq51ZVglqRataJYzf9le5TcRfuQ8HMoVhzdgFB X-Received: by 2002:a05:6a20:6a0d:b0:ec:628d:582 with SMTP id p13-20020a056a206a0d00b000ec628d0582mr6441046pzk.21.1681470132510; Fri, 14 Apr 2023 04:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681470132; cv=none; d=google.com; s=arc-20160816; b=fn+XamfFMO8RY7oxFBwYAWI65ZyieTUjFaJf+M0s5sNAuT9sbC4SfkHyUmrLDO6mo9 SEUO76P+UHSpFDcxlkUYrZumfjbe2/699HftGCtiqPZGflwCLQ8kPJMWVgpUt5dZ8zV3 9UjYHB+wHompSQ0CmNFplowH54b3Spga0oIB7XiiHvSoHI/wieJW9YteQ2NK6JVCITx8 lDht3DY3wcA7wgnwqUZzRvIsjEnlsk5pQRzPKAJLL0zbl400rXE7aJTVRsRlQcBohThR PW4Ic6EW5VCEna6U86FHoF2ezYbYLsekOIgifn80sWNK7VFO0pxeSuF0pc9Ku5UiqNfe lRyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mh/XSi4I3WO2A97bJ5WxQEPSGlXqsNCf/xgmHJn584A=; b=mIY/TKcydsXDYTMo1d62055Pg8g/Q+a+HiSMGu9/6xs4w3tIJB+vCHsq9yWzfQ8M76 g8lyO+Oxwq24148ussuK7ScGUoG9TzXAhPqhegA8hhZ4F0R7/cLlTALQmRjNxlv94FU7 CAevSMUj1IABbWSt5b3aRosPQeKR8Z7TEzH/ciVTtbaODgyumF36gRNRDKTkGbRLXxuz +0XW15LyyIPO0b+kEMP8nMhr60Wmv1YLnMJXY7lHgveip04HMX779YSSw6zjLbuWPXeG hsc/4yPcFEbEdjVTRkAf84oHg1mZ64Mq3XH0lXhpZEg0UbUf9tblFW1CbV1TpeJ8Cd7/ 3vSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WnuE6nxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t64-20020a638143000000b00519cded0624si4533417pgd.899.2023.04.14.04.01.57; Fri, 14 Apr 2023 04:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WnuE6nxk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230268AbjDNLBR (ORCPT + 99 others); Fri, 14 Apr 2023 07:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjDNLBN (ORCPT ); Fri, 14 Apr 2023 07:01:13 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C58D35B1; Fri, 14 Apr 2023 04:01:11 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id 98e67ed59e1d1-246f856d751so518535a91.0; Fri, 14 Apr 2023 04:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681470071; x=1684062071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mh/XSi4I3WO2A97bJ5WxQEPSGlXqsNCf/xgmHJn584A=; b=WnuE6nxkUlOOm8aUiTcKLZz3d1ReJdCFwQ12dlUaotuNneEvqUszV9C3QTDBUaGuzz D3FTTrB7hGVjgsny9xBMOSD7vV74BzAarOP3sRO1nwtkUMMNWyAxSkeZGmJe2nWX+lug bvqBzZK4lj/yPp58hBG+ndHEH16WbMjz9I0+z9G2UxFY0MCVqvtMAyk8CZ3bMmE8Jrhc 57HZpZmnozj5S3N7fensi2ui+XkRhPISg3gv1oCnXA0NgdtcL70TnZHQivTNE9zN7wmo +E3M5PqQlOGHawZa2yBaSNFLHKkoGTA7+VPNGPZAfqwBmWsoDCbKktPn/DHWL+L8+1al 0E5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681470071; x=1684062071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mh/XSi4I3WO2A97bJ5WxQEPSGlXqsNCf/xgmHJn584A=; b=fqjcEHPh/fPvR1489G1KYKZgbi65l6vBFOV06j0PEEwyhQ4cUPRuTB91W8EG2+3dML hh9oRtXLwU/MCdbxDwM8Y1htrNPyBY9pUtqhLQF5kG4MnzVku5GT9qWlh2BlSur6WoEb Wf6ZGCiI/usaOKeRAkCJ8SS2NWM0hzprIMNjys2hMy9m2zs3rRtAH8qHSIMNagfXh50U aLANtVeKkIggekzhXcq59R8FkpFbeKi4Adb/uUKbAR98MsOBGhDViz/0bQKRcufE5d/L Jl54PAHRPOmHsT5u+pRB4BPTjSLVuP/SO18bwyavxJTxhqgYOcHJIafiYjNK4X9MhB36 fR2g== X-Gm-Message-State: AAQBX9dhvR+XDIqQ1XRGkokOxsC9T0LVa8QpqNjb6TuHc004um0PuLr7 TSBjR54mAYkhO9NUU7bqQso= X-Received: by 2002:a05:6a00:2e1d:b0:636:ea6c:68d8 with SMTP id fc29-20020a056a002e1d00b00636ea6c68d8mr7585283pfb.27.1681470070694; Fri, 14 Apr 2023 04:01:10 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id r4-20020a170902ea4400b00194caf3e975sm2835821plg.208.2023.04.14.04.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 04:01:10 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Like Xu , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Jinrong Liang , linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] KVM: selftests: Replace int with uint32_t for nevents Date: Fri, 14 Apr 2023 19:00:50 +0800 Message-Id: <20230414110056.19665-2-cloudliang@tencent.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414110056.19665-1-cloudliang@tencent.com> References: <20230414110056.19665-1-cloudliang@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jinrong Liang 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. This change has been tested and verified to work correctly with all relevant code. Signed-off-by: Jinrong Liang --- .../selftests/kvm/x86_64/pmu_event_filter_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c index 1f60dfae69e0..c0521fc9e8f6 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c @@ -194,7 +194,7 @@ static struct kvm_pmu_event_filter *alloc_pmu_event_filter(uint32_t nevents) static struct kvm_pmu_event_filter * -create_pmu_event_filter(const uint64_t event_list[], int nevents, +create_pmu_event_filter(const uint64_t event_list[], uint32_t nevents, uint32_t action, uint32_t flags) { struct kvm_pmu_event_filter *f; @@ -648,7 +648,7 @@ const struct masked_events_test test_cases[] = { }; static int append_test_events(const struct masked_events_test *test, - uint64_t *events, int nevents) + uint64_t *events, uint32_t nevents) { const uint64_t *evts; int i; @@ -670,7 +670,7 @@ static bool bool_eq(bool a, bool b) } static void run_masked_events_tests(struct kvm_vcpu *vcpu, uint64_t *events, - int nevents) + uint32_t nevents) { int ntests = ARRAY_SIZE(test_cases); struct perf_counter c; @@ -695,7 +695,7 @@ static void run_masked_events_tests(struct kvm_vcpu *vcpu, uint64_t *events, } } -static void add_dummy_events(uint64_t *events, int nevents) +static void add_dummy_events(uint64_t *events, uint32_t nevents) { int i; @@ -714,7 +714,7 @@ static void add_dummy_events(uint64_t *events, int nevents) static void test_masked_events(struct kvm_vcpu *vcpu) { - int nevents = MAX_FILTER_EVENTS - MAX_TEST_EVENTS; + uint32_t nevents = MAX_FILTER_EVENTS - MAX_TEST_EVENTS; uint64_t events[MAX_FILTER_EVENTS]; /* Run the test cases against a sparse PMU event filter. */ @@ -726,7 +726,7 @@ static void test_masked_events(struct kvm_vcpu *vcpu) } static int run_filter_test(struct kvm_vcpu *vcpu, const uint64_t *events, - int nevents, uint32_t flags) + uint32_t nevents, uint32_t flags) { struct kvm_pmu_event_filter *f; int r; -- 2.31.1