Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1032893iob; Fri, 13 May 2022 20:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx8r9ENYtHps7h7JPdrweAr1oFph8XMKQsnwmvAKuN2k3EsbKWkPduCgFiL93phzJAgIeR X-Received: by 2002:a5d:588e:0:b0:20c:7ec0:b804 with SMTP id n14-20020a5d588e000000b0020c7ec0b804mr5914224wrf.128.1652498638018; Fri, 13 May 2022 20:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652498638; cv=none; d=google.com; s=arc-20160816; b=ejPrVsCDj2I4pCL6jpq+XmylRs9FqbQeMeOc9BHcRlPw3EgbkTmPFJO1jFj5PVFNh5 ENaHvzLw+A+AYogdB+81nIAA37vWi3WUOOWlq1yubl6nvIkl6fZoOKYtzR6IH+3p9a6W jcH5BjE76IXFnlP/pwqpR3zlgobx9N3zxcnOvCc0q6g9jVGmyfP7pVgTBBKJHmteRsZW slRgL56Ii2t/oRGQRmIIoETY2If92F0L3Pk4keOM8OX/ar03cEVnNwpyr1NS5KD0bz1L r8+JpRZ6qQljT3/vNyq6ao4H20YeT18HkwqO/qBn5/PeSEnG+/H2FpPJFps88TuuxI11 bB0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=fs8s4x4j/+asSW1i8f2Pukqgr0Ir/tJgvdWyY3yoq3U=; b=CkV63S0HJq9wUrc/N/5jWRH3dT2UY9TR0IoqbwmtphTL4ALxUo7obOOUdPKBXy1J2S 1kdbXNskbu+CY2iK1yv3XwIs6m9jt4vHLHODDohfwztIAfAFUiL3HLStpAbbculHi7ZK byiXOjSyMZTdxFi9IUJ3HQwpFh1HhEvkiGsIzOIDH+1LWivJ5wLyVZTp2oN1L4m6kwud SDUA+2KZMPVX2f95eJ1RtY2otBYEhse2kDvULRIhMjJyL3jNZFP27xaMaw3c9m8q9amT hroZ5puDA3ZQ6ZMcx7cmWMDUbMlbJuVJN+F14n1VVTlwN9lo3Faaq7TnnfxdhGXw6z5M B7Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SUG5R4mv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i12-20020adfe48c000000b0020ad7285991si3277081wrm.775.2022.05.13.20.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SUG5R4mv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E73D93CD4C4; Fri, 13 May 2022 17:01:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354987AbiELOEb (ORCPT + 99 others); Thu, 12 May 2022 10:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354972AbiELOE3 (ORCPT ); Thu, 12 May 2022 10:04:29 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BC11EEE1B; Thu, 12 May 2022 07:04:26 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id dk23so10450019ejb.8; Thu, 12 May 2022 07:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fs8s4x4j/+asSW1i8f2Pukqgr0Ir/tJgvdWyY3yoq3U=; b=SUG5R4mvQVZygGuRddCDO8dZQacyk07/cAZawwDbBHFiIcz+Eh01oOdFt+8NMsiteQ s8AlWxu2/skdBIc9am1jSyRtORyb1BuvlFo2plpzUHEsxv9da1HNExENjJ/0t+nOi9bO k6oU2HkXL/cV0mXaW/mfigdUplLND8VcIPAZZRcd10cHVVgLxpSC20yq2GqMhOEn4o3v BX8j64LjIRumUuIVBipI3tL8S6DVa+sbn4U3DSEKiGesq+9Htf13sK9idkEcXbPWJtoW pmum4BbxGst/QvpAJs+YLlKzd9hKoO2n+ygfnHiEf87Cm4zp15vme9Bvbc6JHtHUcLB8 yScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fs8s4x4j/+asSW1i8f2Pukqgr0Ir/tJgvdWyY3yoq3U=; b=v4B3HHwlk9jnnCSMeZzI1PxJB6prSWalTvvucWTXhx+NZ1PbGCi41eDOQWYYEH0O+3 muOEYrZEVquXOOjvDXr+YsfSAaqZQJRZaxePEZHel8j4i8tA6aO4IkFHyXIaHj0cJ9W4 28be8uzT1XAahhlfBeARCdaypq7rl6NKnXK2vAvT6p4tNhQkA/St14A7NR5hGRh9uYHB SabIQYkJz30ql5GC917Acr3flgypcku2CDRsX173gT7kGQRqn6/LthrojbCCsbiRG/yE DrdNaI/2DBJBPvqv8aDmTlh6yK6Wfvt4BAIga4uV5t4jWiawAb0tIIiOCusVsAyq0Pyp ArjA== X-Gm-Message-State: AOAM531Z2Pg69vJsy5zCPsP3LGyejYQK8occa6UXxI3e3xO1VdLvgfM8 le6fTlZM6RoH0xjheWHlQ9U= X-Received: by 2002:a17:907:3e86:b0:6f5:917:10cc with SMTP id hs6-20020a1709073e8600b006f5091710ccmr63430ejc.53.1652364264897; Thu, 12 May 2022 07:04:24 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.googlemail.com with ESMTPSA id r10-20020a508d8a000000b00428bb4c952bsm2609603edh.31.2022.05.12.07.04.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 May 2022 07:04:24 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <0d4e0b40-a2b3-789f-3adb-9da30c61403f@redhat.com> Date: Thu, 12 May 2022 16:04:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] selftests: kvm: replace ternary operator with min() Content-Language: en-US To: Guo Zhengkui , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Anup Patel , "moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" , "moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" , "open list:KERNEL VIRTUAL MACHINE (KVM)" , "open list:KERNEL SELFTEST FRAMEWORK" , open list , "open list:RISC-V ARCHITECTURE" Cc: zhengkui_guo@outlook.com References: <20220511120621.36956-1-guozhengkui@vivo.com> From: Paolo Bonzini In-Reply-To: <20220511120621.36956-1-guozhengkui@vivo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 5/11/22 14:05, Guo Zhengkui wrote: > Fix the following coccicheck warnings: > > tools/testing/selftests/kvm/lib/s390x/ucall.c:25:15-17: WARNING > opportunity for min() > tools/testing/selftests/kvm/lib/x86_64/ucall.c:27:15-17: WARNING > opportunity for min() > tools/testing/selftests/kvm/lib/riscv/ucall.c:56:15-17: WARNING > opportunity for min() > tools/testing/selftests/kvm/lib/aarch64/ucall.c:82:15-17: WARNING > opportunity for min() > tools/testing/selftests/kvm/lib/aarch64/ucall.c:55:20-21: WARNING > opportunity for min() > > min() is defined in tools/include/linux/kernel.h. > > Signed-off-by: Guo Zhengkui > --- > tools/testing/selftests/kvm/lib/aarch64/ucall.c | 4 ++-- > tools/testing/selftests/kvm/lib/riscv/ucall.c | 2 +- > tools/testing/selftests/kvm/lib/s390x/ucall.c | 2 +- > tools/testing/selftests/kvm/lib/x86_64/ucall.c | 2 +- > 4 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/kvm/lib/aarch64/ucall.c b/tools/testing/selftests/kvm/lib/aarch64/ucall.c > index e0b0164e9af8..00be3ef195ca 100644 > --- a/tools/testing/selftests/kvm/lib/aarch64/ucall.c > +++ b/tools/testing/selftests/kvm/lib/aarch64/ucall.c > @@ -52,7 +52,7 @@ void ucall_init(struct kvm_vm *vm, void *arg) > * lower and won't match physical addresses. > */ > bits = vm->va_bits - 1; > - bits = vm->pa_bits < bits ? vm->pa_bits : bits; > + bits = min(vm->pa_bits, bits); > end = 1ul << bits; > start = end * 5 / 8; > step = end / 16; > @@ -79,7 +79,7 @@ void ucall(uint64_t cmd, int nargs, ...) > va_list va; > int i; > > - nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; > + nargs = min(nargs, UCALL_MAX_ARGS); > > va_start(va, nargs); > for (i = 0; i < nargs; ++i) > diff --git a/tools/testing/selftests/kvm/lib/riscv/ucall.c b/tools/testing/selftests/kvm/lib/riscv/ucall.c > index 9e42d8248fa6..34f16fe70ce8 100644 > --- a/tools/testing/selftests/kvm/lib/riscv/ucall.c > +++ b/tools/testing/selftests/kvm/lib/riscv/ucall.c > @@ -53,7 +53,7 @@ void ucall(uint64_t cmd, int nargs, ...) > va_list va; > int i; > > - nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; > + nargs = min(nargs, UCALL_MAX_ARGS); > > va_start(va, nargs); > for (i = 0; i < nargs; ++i) > diff --git a/tools/testing/selftests/kvm/lib/s390x/ucall.c b/tools/testing/selftests/kvm/lib/s390x/ucall.c > index 9d3b0f15249a..665267c1135d 100644 > --- a/tools/testing/selftests/kvm/lib/s390x/ucall.c > +++ b/tools/testing/selftests/kvm/lib/s390x/ucall.c > @@ -22,7 +22,7 @@ void ucall(uint64_t cmd, int nargs, ...) > va_list va; > int i; > > - nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; > + nargs = min(nargs, UCALL_MAX_ARGS); > > va_start(va, nargs); > for (i = 0; i < nargs; ++i) > diff --git a/tools/testing/selftests/kvm/lib/x86_64/ucall.c b/tools/testing/selftests/kvm/lib/x86_64/ucall.c > index a3489973e290..2ea31a0ebe30 100644 > --- a/tools/testing/selftests/kvm/lib/x86_64/ucall.c > +++ b/tools/testing/selftests/kvm/lib/x86_64/ucall.c > @@ -24,7 +24,7 @@ void ucall(uint64_t cmd, int nargs, ...) > va_list va; > int i; > > - nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; > + nargs = min(nargs, UCALL_MAX_ARGS); > > va_start(va, nargs); > for (i = 0; i < nargs; ++i) Queued, thanks. Paolo