Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp270375ybe; Tue, 10 Sep 2019 18:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAoofTDn7x69ecf65TzqKs/OowpI6VklaA8vnffj7LVqMUo/ZKBjKPTaFPI59jdaWaHsYM X-Received: by 2002:a17:906:a2d6:: with SMTP id by22mr27466076ejb.133.1568165642677; Tue, 10 Sep 2019 18:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568165642; cv=none; d=google.com; s=arc-20160816; b=DJjve4UT1DSQRO6N4Crl3HVGbA6tGziIhdvgOmCK5mAhOBQ0q60ZHZXf1nkiOFD7BH ZZ1pPZdQjYVgkP7PAjh3NKO+P/PGOZs1gr2FkzBmnFS+iwo515fDEW65QaduskRXvLMT IyEd9RtAPovAP4xEBuWg/ivvtgzw/v1g0yFOtTooxHUMPDTEWn1Tv8cNJm+9+N1Th//3 XnvPYLS6J9Zcw/ijYroCc4GU+oxCm1uw4qSuHf2+OzpCN4Vf1oHEfZ7ErQ7VtxvCOqSf +5gz9j+khDwym1d3CG0tLmJKkT24y9x9P0Jdg315Tc0hBRu9tCdoBaCqZzW3GFtw+r+b PDhw== 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=RGPCZG+q5EdS5MEPhIfUUfR2L5YR4tpcFausxBy8hKI=; b=xlpf7SeiFilGK+Wby2PW8lE6K9HNzvDQEeLEIA9m7DA3kIUCPlo7baD5dQ897wSDHl xpwKIIgmpIiWpI43Df7Y+g0ElO5nbjeZvHnwF1G8EDCRva4101f4EWvp6dcBWfTA+YGL cGxvZZw9D3EaDMLy4+OrBeOd0HwvZ9PEKR3yHEg8uJ/JwkmtLcUiFZkGbh1mT981uiT1 DzYht4DI7kbyvqAvfFQqb0lqGku/6fFN7YAz51CkJZA3lIXByd/shQI2/xQ308YiNXYd 3V+drRT1Lv6bTFVc25t4J/2jKHVnt72HjrVW2fhTiG4qcrk6868xCtQq29WsTAmxjA/d 0eQg== 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 d13si1814775edh.449.2019.09.10.18.33.26; Tue, 10 Sep 2019 18:34:02 -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 S1726561AbfIKBa4 (ORCPT + 99 others); Tue, 10 Sep 2019 21:30:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55550 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726224AbfIKBa4 (ORCPT ); Tue, 10 Sep 2019 21:30:56 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A8175ACB86E4CABFD3C3; Wed, 11 Sep 2019 09:30:53 +0800 (CST) Received: from [127.0.0.1] (10.177.96.96) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 11 Sep 2019 09:30:49 +0800 Subject: Re: [PATCH net 1/2] sctp: remove redundant assignment when call sctp_get_port_local To: Dan Carpenter CC: , , , , , , , References: <20190910071343.18808-1-maowenan@huawei.com> <20190910071343.18808-2-maowenan@huawei.com> <20190910185710.GF15977@kadam> <20190910192207.GE20699@kadam> From: maowenan Message-ID: <53556c87-a351-4314-cbd9-49a39d0b41aa@huawei.com> Date: Wed, 11 Sep 2019 09:30:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.0 MIME-Version: 1.0 In-Reply-To: <20190910192207.GE20699@kadam> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.96.96] 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/9/11 3:22, Dan Carpenter wrote: > On Tue, Sep 10, 2019 at 09:57:10PM +0300, Dan Carpenter wrote: >> On Tue, Sep 10, 2019 at 03:13:42PM +0800, Mao Wenan wrote: >>> There are more parentheses in if clause when call sctp_get_port_local >>> in sctp_do_bind, and redundant assignment to 'ret'. This patch is to >>> do cleanup. >>> >>> Signed-off-by: Mao Wenan >>> --- >>> net/sctp/socket.c | 3 +-- >>> 1 file changed, 1 insertion(+), 2 deletions(-) >>> >>> diff --git a/net/sctp/socket.c b/net/sctp/socket.c >>> index 9d1f83b10c0a..766b68b55ebe 100644 >>> --- a/net/sctp/socket.c >>> +++ b/net/sctp/socket.c >>> @@ -399,9 +399,8 @@ static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len) >>> * detection. >>> */ >>> addr->v4.sin_port = htons(snum); >>> - if ((ret = sctp_get_port_local(sk, addr))) { >>> + if (sctp_get_port_local(sk, addr)) >>> return -EADDRINUSE; >> >> sctp_get_port_local() returns a long which is either 0,1 or a pointer >> casted to long. It's not documented what it means and neither of the >> callers use the return since commit 62208f12451f ("net: sctp: simplify >> sctp_get_port"). > > Actually it was commit 4e54064e0a13 ("sctp: Allow only 1 listening > socket with SO_REUSEADDR") from 11 years ago. That patch fixed a bug, > because before the code assumed that a pointer casted to an int was the > same as a pointer casted to a long. commit 4e54064e0a13 treated non-zero return value as unexpected, so the current cleanup is ok? > > regards, > dan carpenter > > > . >