Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp221223pxj; Wed, 16 Jun 2021 00:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsw0ChqE3EstAqaZzFvl2O3fJ6DLxb0Cdc1AGp6Ia5a29PbCXDJfhRPT2mi3thfXuUXPVY X-Received: by 2002:a02:b805:: with SMTP id o5mr2956569jam.110.1623828586494; Wed, 16 Jun 2021 00:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623828586; cv=none; d=google.com; s=arc-20160816; b=wKht9a6FVd5DnewaKYybv3VJgbUGlSJo4Gt9wz5cp4+v2YiaOBZD5bEC5ZLPdFR0Z2 4ldnpUk3Ka8tEw1Mxham21+xIdPW8GOJNrvxtHnvdje2JDS9JzlGIWCszhF4I42b2AjH LCPMVDaxvxfD74jf9W3JjxYKTWx8o/+EvDunKGasbLU1tAZMISsUIRDkSMivxCkytggQ mhJ2TwuM93dwh1JbPr8u1ELAx34c15rcY8w7/shKSdY2OkCviGuMCLYM6ETLmqwiqH3O o7wwC2NlIuyTWmzTRN649wSVRt4u36ScIaRnAjm+jSTrdJlox1CEIcI9l3M8GuIq8uhg BQGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pv9OKBcXtW955QK1+Qcg9ET4MhbCG3Hh6jis1Eygc08=; b=hHyGUItmZ4H86v2sHrWHALucBiSGuw5F+M6uLVrf+PtINcaHm0cp3fp48j+iwNcx8b R57rq2l/LUXvzAVv+3Lpl1A3+ahkY81eqbo59ix9NHS+YKgScLR+bNINwhagkggAe+ms 0HQ6ok5r0x5BlxQCPnCUTVoqXWP7j4BGXFAwA/S5oitZ3J6icJ56DGmDyIIifDS6+r6b 2SVhyEGOTIAobITHkTzGOiaIKROqbR6IUzH155xF/9A9D+40KApMQ4j3bcfTwDlU5jDe 0aPGbqoD9u8R4Y7vbqjI5BxQONsT0P79P2/fAM8nOOC7ATTxhWfQvytAROk2FUL1FMgd cRGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si1382417iov.2.2021.06.16.00.29.34; Wed, 16 Jun 2021 00:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbhFPH3s (ORCPT + 99 others); Wed, 16 Jun 2021 03:29:48 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:7296 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbhFPH3H (ORCPT ); Wed, 16 Jun 2021 03:29:07 -0400 Received: from localhost (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4G4c7n5tQ9z1BN7t; Wed, 16 Jun 2021 15:21:57 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 16 Jun 2021 15:26:53 +0800 Received: from localhost.localdomain (10.67.165.24) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 16 Jun 2021 15:26:53 +0800 From: Guangbin Huang To: , , , , CC: , , , Subject: [PATCH net-next 05/15] net: cosa: move out assignment in if condition Date: Wed, 16 Jun 2021 15:23:31 +0800 Message-ID: <1623828221-48349-6-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1623828221-48349-1-git-send-email-huangguangbin2@huawei.com> References: <1623828221-48349-1-git-send-email-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li Should not use assignment in if condition. Signed-off-by: Peng Li Signed-off-by: Guangbin Huang --- drivers/net/wan/cosa.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 7b57233..9b57b3a 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -355,7 +355,8 @@ static int __init cosa_init(void) goto out; } } else { - if (!(cosa_major=register_chrdev(0, "cosa", &cosa_fops))) { + cosa_major = register_chrdev(0, "cosa", &cosa_fops); + if (!cosa_major) { pr_warn("unable to register chardev\n"); err = -EIO; goto out; @@ -563,7 +564,8 @@ static int cosa_probe(int base, int irq, int dma) sema_init(&chan->wsem, 1); /* Register the network interface */ - if (!(chan->netdev = alloc_hdlcdev(chan))) { + chan->netdev = alloc_hdlcdev(chan); + if (!chan->netdev) { pr_warn("%s: alloc_hdlcdev failed\n", chan->name); err = -ENOMEM; goto err_hdlcdev; @@ -925,15 +927,15 @@ static int cosa_open(struct inode *inode, struct file *file) int ret = 0; mutex_lock(&cosa_chardev_mutex); - if ((n=iminor(file_inode(file))>>CARD_MINOR_BITS) - >= nr_cards) { + n = iminor(file_inode(file)) >> CARD_MINOR_BITS; + if (n >= nr_cards) { ret = -ENODEV; goto out; } cosa = cosa_cards+n; - if ((n=iminor(file_inode(file)) - & ((1<= cosa->nchannels) { + n = iminor(file_inode(file)) & ((1 << CARD_MINOR_BITS) - 1); + if (n >= cosa->nchannels) { ret = -ENODEV; goto out; } @@ -1095,7 +1097,8 @@ static inline int cosa_start(struct cosa_data *cosa, int address) return -EPERM; } cosa->firmware_status &= ~COSA_FW_RESET; - if ((i=startmicrocode(cosa, address)) < 0) { + i = startmicrocode(cosa, address); + if (i < 0) { pr_notice("cosa%d: start microcode at 0x%04x failed: %d\n", cosa->num, address, i); return -EIO; @@ -1475,7 +1478,8 @@ static int readmem(struct cosa_data *cosa, char __user *microcode, int length, i char c; int i; - if ((i=get_wait_data(cosa)) == -1) { + i = get_wait_data(cosa); + if (i == -1) { pr_info("0x%04x bytes remaining\n", length); return -11; } @@ -1523,9 +1527,10 @@ static int cosa_reset_and_read_id(struct cosa_data *cosa, char *idstring) * the port returns '\r', '\n' or '\x2e' permanently. */ for (i=0; i