Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4050356ybg; Fri, 25 Oct 2019 12:35:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcuQi3HwHHG6gnS3YSmwampq4DCvCTnothGsrNNzERSqKFpHIDCt8FYr3bpc17xR28QaPL X-Received: by 2002:a17:906:f252:: with SMTP id gy18mr5164934ejb.224.1572032145789; Fri, 25 Oct 2019 12:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572032145; cv=none; d=google.com; s=arc-20160816; b=fJ98uB7fMPYUB1jVXvaIv1NSVR6drDcl/SEQ+BqCpnyf+T4883IxpsJRgZZYsPVF8Y t22Rav+3tgWk57qqP+8dfF6rjTe6R9hmQ1oVgdRcAj3RRoCbBmdp1Kz2vJfA+QMK3J4T Z3E9F5GU1PtHYv41N2AWz3OS824CPZNjsYzClHJHrAee3/ynU7RUUFMRZuCFeYqdWopR wWOf5Mi4Ib3aNWNFi8m3eH+v1Tx+AaRK6d0hUuQ0uaFQ7VRRUD5G8t56n5cZbqKS+kIG uOA3uw7jNSjgLKr9ct+iNV13i0ccBIoriDBA45sdk9GHLNlretQFMhaQ+4uRviEMIcHi pHBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rGieHZoLYBwO35M5vhg+p2DdIKkutGfRsY0UShKCdzo=; b=FxSWnoLExswMFOgdILBhzwFAJfFGff0pWe3LS7p7aZ7P8O3UXiwzERqHrmfsYYymbq RmvXAWsFLTUD6gyZsxMtuU9xDKPwFDXLfcUB3wKk7vpntjddBxvoPluCLvBc6/8+u2hZ Lrw71QJZMJqVeeBTUZWh4yR7KwFX6CqlkcNk4Pas5uNuditaTcZloxicfvA3AOBP4fp5 1jS8iQtgtJae5xjuiclvSV0j5k/fELSJO40U5GB07/wPe+1FfWJpCB3TtQHkaAoybSGo R8IdTwtPXX8PjaNA05e6L3ca9aJzhylXgtzebcoaqPZsoCKEn8D449jpfU5GQ1EYtXmv 9jiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qh2si1800713ejb.372.2019.10.25.12.35.22; Fri, 25 Oct 2019 12:35:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394275AbfJYJpm (ORCPT + 99 others); Fri, 25 Oct 2019 05:45:42 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:43570 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392769AbfJYJpm (ORCPT ); Fri, 25 Oct 2019 05:45:42 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EE3213F827BF640EF8BF; Fri, 25 Oct 2019 17:45:40 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Fri, 25 Oct 2019 17:45:31 +0800 Subject: Re: [PATCH] crypto: qat - remove redundant condition accel_dev->is_vf To: Ard Biesheuvel CC: Giovanni Cabiddu , Herbert Xu , "David S. Miller" , , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List , "hushiyuan@huawei.com" , "linfeilong@huawei.com" References: <78b1532c-f8bf-48e4-d0a7-30ea0137d408@huawei.com> From: Yunfeng Ye Message-ID: <0b95f573-548b-4cec-e433-ef0ef16229cf@huawei.com> Date: Fri, 25 Oct 2019 17:45:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/25 17:33, Ard Biesheuvel wrote: > On Fri, 25 Oct 2019 at 09:24, Yunfeng Ye wrote: >> >> Warning is found by the code analysis tool: >> "Redundant condition: accel_dev->is_vf" >> >> So remove the redundant condition accel_dev->is_vf. >> >> Signed-off-by: Yunfeng Ye >> --- >> drivers/crypto/qat/qat_common/adf_dev_mgr.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/crypto/qat/qat_common/adf_dev_mgr.c b/drivers/crypto/qat/qat_common/adf_dev_mgr.c >> index 2d06409bd3c4..b54b8850fe20 100644 >> --- a/drivers/crypto/qat/qat_common/adf_dev_mgr.c >> +++ b/drivers/crypto/qat/qat_common/adf_dev_mgr.c >> @@ -196,7 +196,7 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev, >> atomic_set(&accel_dev->ref_count, 0); >> >> /* PF on host or VF on guest */ >> - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { >> + if (!accel_dev->is_vf || !pf) { > > I disagree with this change. There is no bug here, and the way the > condition is formulated self-documents the code, i.e., > > IF NOT is_vf > OR (is_vf BUT NOT pf) > > Using an automated tool to reduce every boolean expression to its > minimal representation doesn't seem that useful to me, since the > compiler is perfectly capable of doing that when generating the object > code. > ok, thanks, this modify just fix warning, and make code simple. > > > >> struct vf_id_map *map; >> >> list_for_each(itr, &accel_table) { >> @@ -292,7 +292,7 @@ void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev, >> struct adf_accel_dev *pf) >> { >> mutex_lock(&table_lock); >> - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { >> + if (!accel_dev->is_vf || !pf) { >> id_map[accel_dev->accel_id] = 0; >> num_devices--; >> } else if (accel_dev->is_vf && pf) { >> -- >> 2.7.4 >> > > . >