Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1708943ybe; Wed, 11 Sep 2019 20:49:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkSn11zjLd/SVVXGLCl2O6VtzoEQQLxVBq8gseX6kulF6Ck1IMdCqTkN9qXIVGi+koyKG6 X-Received: by 2002:a50:884c:: with SMTP id c12mr39540950edc.134.1568260152643; Wed, 11 Sep 2019 20:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568260152; cv=none; d=google.com; s=arc-20160816; b=PUr2T7k3WVc+dPJQ1DfHNEq0rPVVJs9rzSLeBK4UGFe3mQk0/HM0whcPZArw1UuTd/ gJ0lEq5Zq6VJZtMCaPPn9xUpaIWCat7MNJEYlyVFA/SMKILhz/VAGIY4Bc9nDAMpZhto 8KEkB/H5RCL8Ep89P42Rz2QiIbV89bzLToputH9XmE9XTt0V9m3U46eVc8sWyWgaXYZC piWAN+bR6Bw8J6EZ2FYmgJ/SQqnGP/cMD6GLQFV1RGv/a4lPBYchCqy1lezQDNIvXter Q7jG80pb4zPQYErUMGodj9pp/vBSpChUKplpfAJgNpbNtP8ahL+0P4XMG0dU+ByutJeU Tq8w== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hYPPuXwxiHDIndljSiW8KIFhjTd0g1aG/VkbZW0mFAQ=; b=cYnTAMaNrbsidQjOELm/jgCIjQQTX7VJOcD2cRqdVeIlF2aa3thL+zOzaZneHVr0ks XcJzBPgjMuSu6fKy1Rx1hWOMgDkbj6CmN+x9sfMDzslHprLYcksMMfnDXfXwLxf8pYxC r9po8mngyXRioPyZNFCZiUlXs7gVRqeqdrK8exSJoeiU6W08yfY1IDeb9OyRsVXTrseR ChQ0LyEqKmGdwcESICvtY0bUUU3a6iqSynPHF0KIAjBPZtlYwjJoGvhwjEZxtWnJceg1 6cGEJe2ZID6TuRGO3mpoWM0wHaInwYSZh0z1gDGPWuUVYpjqapgYB5PJCaHgI6wA1Ps7 PHwg== 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 h17si12179025ejf.16.2019.09.11.20.48.48; Wed, 11 Sep 2019 20:49:12 -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 S1729685AbfILDpB (ORCPT + 99 others); Wed, 11 Sep 2019 23:45:01 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2217 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726157AbfILDpB (ORCPT ); Wed, 11 Sep 2019 23:45:01 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 035C1B7E71A04F8CF1B3; Thu, 12 Sep 2019 11:44:59 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Thu, 12 Sep 2019 11:44:52 +0800 From: Mao Wenan To: , , , CC: , , , , Mao Wenan Subject: [PATCH v2 net 1/3] sctp: change return type of sctp_get_port_local Date: Thu, 12 Sep 2019 12:02:17 +0800 Message-ID: <20190912040219.67517-2-maowenan@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190912040219.67517-1-maowenan@huawei.com> References: <7a450679-40ca-8a84-4cba-7a16f22ea3c0@huawei.com> <20190912040219.67517-1-maowenan@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently sctp_get_port_local() returns a long which is either 0,1 or a pointer casted to long. It's neither of the callers use the return value since commit 62208f12451f ("net: sctp: simplify sctp_get_port"). Now two callers are sctp_get_port and sctp_do_bind, they actually assumend a casted to an int was the same as a pointer casted to a long, and they don't save the return value just check whether it is zero or non-zero, so it would better change return type from long to int for sctp_get_port_local. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Mao Wenan --- net/sctp/socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9d1f83b10c0a..5e1934c48709 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -309,7 +309,7 @@ static int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len) return retval; } -static long sctp_get_port_local(struct sock *, union sctp_addr *); +static int sctp_get_port_local(struct sock *, union sctp_addr *); /* Verify this is a valid sockaddr. */ static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt, @@ -7998,7 +7998,7 @@ static void sctp_unhash(struct sock *sk) static struct sctp_bind_bucket *sctp_bucket_create( struct sctp_bind_hashbucket *head, struct net *, unsigned short snum); -static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) +static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr) { struct sctp_sock *sp = sctp_sk(sk); bool reuse = (sk->sk_reuse || sp->reuse); @@ -8108,7 +8108,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) if (sctp_bind_addr_conflict(&ep2->base.bind_addr, addr, sp2, sp)) { - ret = (long)sk2; + ret = 1; goto fail_unlock; } } @@ -8180,7 +8180,7 @@ static int sctp_get_port(struct sock *sk, unsigned short snum) addr.v4.sin_port = htons(snum); /* Note: sk->sk_num gets filled in if ephemeral port request. */ - return !!sctp_get_port_local(sk, &addr); + return sctp_get_port_local(sk, &addr); } /* -- 2.20.1