Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6899301iob; Wed, 11 May 2022 07:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySmuc6rWSsVVMKR8jnE46H4lzo+rAmAB6vDLRbsAGbiKOwHnbh1lXkWHWe8q5+JqvGWzdI X-Received: by 2002:a05:6402:b4d:b0:425:ec4a:a37e with SMTP id bx13-20020a0564020b4d00b00425ec4aa37emr29006870edb.292.1652280076681; Wed, 11 May 2022 07:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652280076; cv=none; d=google.com; s=arc-20160816; b=oJeveU27lBQr31kcjg8TfdJLG2oNqm9GBaCUzYod0hDyPoJ0LYKNUo4KFahsJd2xjv c2G3XKjedl7Z3ZmMcv+JIlb0zd3kBMBMDJuNN3+x06P3NF1U8hCsC8C7fNlkHnqHNYej uiQlGYKxmhCSGo6I1gJ2zVqxk1U+Lr4Ro0IuEdj8h/lz6IBN9oF6O4DeVHEFeIWwFqxh 2LJwxNyST+NBdumkIAIIXzYUsIukaNQ6OExDFXX10EnwEUyCxZ7SAvl3SnsI3eXVMoNQ Q6xv0QXHetGzlRNa5ataZMKEiv+M0OEj4j8r70xNNZDMzmr4BEUR23l/XWkEiJV+IdRk boxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RSGHn1F0BncOfTcKYhrKyIk0Nc9jRJLzLB3ecNcIZy4=; b=Lze6uq6h1DngFQqiiKFlhrXm9G3LAySaltZTJXEWbG29P0PKWUq0hbLo1K4+Eu8rKS 1R/ILAuc8VrxOHVS/OKcWdtpAgdNAn6/83sCNbJlete/WG1snw4RE1V5BPHgDj+4Enas 2pC788WIhx7vCwFDFkZBhPevubz4p2Nc9hsAIgnrLI7K/pGcT+++Ah9fnAAAWllqxTMG MIyoBGgJjJeHJ1f20XTZzexuNcmAnxBywGFe5oWFLvJzGIJsgPtCoX2/ZMYOeXLG74ns tTGnGgfofLVmqmP865QDmwhGijAIVVXhtJu/BXGb5evY5B3mmCCR1KiStOfAfcW6/mFn Datg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=jW12ZwQn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a056402268500b00418c2b5bd2fsi3175539edd.17.2022.05.11.07.40.18; Wed, 11 May 2022 07:41:16 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=jW12ZwQn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244423AbiEKOMu (ORCPT + 99 others); Wed, 11 May 2022 10:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244455AbiEKOMm (ORCPT ); Wed, 11 May 2022 10:12:42 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C718F6B64E for ; Wed, 11 May 2022 07:12:40 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 125-20020a1c1983000000b003941f354c62so1339127wmz.0 for ; Wed, 11 May 2022 07:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RSGHn1F0BncOfTcKYhrKyIk0Nc9jRJLzLB3ecNcIZy4=; b=jW12ZwQnnCztcNwkigLKzLeyKxuLaypSdNh5RLphYPfrxCmn7JNKcAFQyhsDExQ715 wJwjtZki4XfUaxqAYliizclV7JqcbjMJZH3O294nmneM4g9jdOzsk+Y7dwWTdMhJNmFr luTgFG70VKGd5rBsQuYZFTUjRfEcJ0/y7nPhAyW1ERcls1P51FqhBYBEYo8vF1V2mXNd 8SRsu7Z8MrurgPTYpBt1TQjav+1DEREjLXAbJ0D6pm6Q+pDArYfJ2vpNCWaWnM02wpn/ 0SNSQoIcK+vj+GrpRIllI9L4jtsan3nrlQwi8mHwvPTLx1sPHdv/4t0fc5sKaLD/XZ2s 9LPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RSGHn1F0BncOfTcKYhrKyIk0Nc9jRJLzLB3ecNcIZy4=; b=iuLsDhiqBEhqY25/QttT+CNauStvclM+o+SQf2wnNtkEBS91yi2HqDlHqMn3dgl+jY xK2ljA7d8qnrvDmis8ibcVXbE6HXH9lc+Pc/Pp2PzjOX6CuWIcbToBn39V9yFFoNRq8p EU0r25lS/I31wW3I574IuhguEtaaWxMqPJi+WNLnnZTfqyVQ9TVjPIKq4EXfDBa+QhpE 3ucLdloGkq8OBgwL5dr420kIfv3B6gf+ARfEpxscn/SgNppI5kURt2c4LOIRkpQSgep6 P+dobpnQ/GxvtRUfKs8cghnf0J9kXfYBDkOZnPS0nbt4sCmNVYMZA/6puzSGhRVCKQPx qckg== X-Gm-Message-State: AOAM531IUE2kGDaqFWRjt2ECtmnwhWb1opM+hX/NKGwQJhfR4l3gXlL0 VXXP4fWrvhtveEjMu7l9FSkxBXLok1Oi2EsmmzAx2A== X-Received: by 2002:a05:600c:1d08:b0:394:54ee:c994 with SMTP id l8-20020a05600c1d0800b0039454eec994mr5072481wms.137.1652278359083; Wed, 11 May 2022 07:12:39 -0700 (PDT) MIME-Version: 1.0 References: <20220511120621.36956-1-guozhengkui@vivo.com> In-Reply-To: <20220511120621.36956-1-guozhengkui@vivo.com> From: Anup Patel Date: Wed, 11 May 2022 19:42:27 +0530 Message-ID: Subject: Re: [PATCH] selftests: kvm: replace ternary operator with min() To: Guo Zhengkui Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , "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" , zhengkui_guo@outlook.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_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 Wed, May 11, 2022 at 5:38 PM 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 For KVM RISC-V: Acked-by: Anup Patel Thanks, Anup > --- > 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) > -- > 2.20.1 >