Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5227904pxj; Wed, 26 May 2021 06:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIt+tvEkBgjr30WU9D4mopjB8KOpBiIROYM8UTNAYOikXp+tsHnueYeIY97wPMP/pgc845 X-Received: by 2002:a17:902:e00e:b029:ef:5f1c:18a8 with SMTP id o14-20020a170902e00eb02900ef5f1c18a8mr36102530plo.38.1622034047800; Wed, 26 May 2021 06:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622034047; cv=none; d=google.com; s=arc-20160816; b=gdArGMwAsC+Hwqfa07RguW5kcA4Dtz+20HKBkSItcM+XSyJPkBKJKf+duY1Zc+jt45 H9aiH+J/ASgjQ3YKfWLTkj0AHUu9V2gTrO53MsHOBQowzvnCmxcys0EuJm+Zqn64k20q vHKQke78VteJPltNCcXYuIi1Hvtcaui9JlOmoijSpyNSaOaqcsFdf/LAr/CIZiOLel6P 834xWNZYv2/eLfkoDiuiGVl3Y9dAt+X9af1wEykertMjFMrr0+F+hNOWE86ez3bHGI7k 644CA5HM++Wvf6e6endOeldEUM+gk5bI0zN9iWCDVqQ8PrO5UfQAPyqxMwhXyCTnq225 vXXw== 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=cQApVPHZsp/T3Bgw2BPJ+YvG57NUxMLDDxbbb+T59nI=; b=fORdEFkRnJ13W0U3Zo6KOhw9T+nPdcnPaqS7ot3w+90Gr7Y1cFdksRukkqCZmVYVWa JY5ypgkEEEapG3srq5gM+6JF6lN8HaTtaILIJHz7WAYx2jZD3GwwHx6y4JGmPCpdQaaC IEawWgnV45Q8NCU3Al+ZAROLwd6ZqJUd/JWUQsafznUUmKuO3zT0GyO14i0VWNEPJ5F1 x2r1KHNy3vJ5QLBPDyocAYWH/vc3J9ZVlivcNO/mObMf6Lj/ERRXuLjw8GJBkKLZb0rC KHeBzw6f99JYCTyhv3t8TrNhAUgu4Nmo8kZ4to2/yA/LhShs7oCGGOZ5XtYydbJkjFg2 P40g== 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 o2si21409556jaa.70.2021.05.26.06.00.30; Wed, 26 May 2021 06:00:47 -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 S234479AbhEZLuW (ORCPT + 99 others); Wed, 26 May 2021 07:50:22 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6713 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbhEZLta (ORCPT ); Wed, 26 May 2021 07:49:30 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FqpyC5MKtzncbK; Wed, 26 May 2021 19:44:19 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 26 May 2021 19:47:56 +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, 26 May 2021 19:47:56 +0800 From: Guangbin Huang To: , , , , CC: , , , , Subject: [PATCH net-next 05/10] net: wan: move out assignment in if condition Date: Wed, 26 May 2021 19:44:50 +0800 Message-ID: <1622029495-30357-6-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1622029495-30357-1-git-send-email-huangguangbin2@huawei.com> References: <1622029495-30357-1-git-send-email-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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/hdlc_fr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index 512ef79459da..a39e5082c20f 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -937,7 +937,8 @@ static int fr_rx(struct sk_buff *skb) pvc->state.becn ^= 1; } - if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { + skb = skb_share_check(skb, GFP_ATOMIC); + if (!skb) { frad->stats.rx_dropped++; return NET_RX_DROP; } @@ -1064,7 +1065,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) struct net_device *dev; int used; - if ((pvc = add_pvc(frad, dlci)) == NULL) { + pvc = add_pvc(frad, dlci); + if (!pvc) { netdev_warn(frad, "Memory squeeze on fr_add_pvc()\n"); return -ENOBUFS; } @@ -1121,10 +1123,12 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) struct pvc_device *pvc; struct net_device *dev; - if ((pvc = find_pvc(hdlc, dlci)) == NULL) + pvc = find_pvc(hdlc, dlci); + if (!pvc) return -ENOENT; - if ((dev = *get_dev_p(pvc, type)) == NULL) + dev = *get_dev_p(pvc, type); + if (!dev) return -ENOENT; if (dev->flags & IFF_UP) -- 2.8.1