net: make getname() functions return length rather than use int* parameter
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 12 Feb 2018 19:00:20 +0000 (20:00 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Feb 2018 19:15:04 +0000 (14:15 -0500)
commit9b2c45d479d0fb8647c9e83359df69162b5fbe5f
tree1004b2ce427a21084ff723b29026da6f263fc96b
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2
net: make getname() functions return length rather than use int* parameter

Changes since v1:
Added changes in these files:
    drivers/infiniband/hw/usnic/usnic_transport.c
    drivers/staging/lustre/lnet/lnet/lib-socket.c
    drivers/target/iscsi/iscsi_target_login.c
    drivers/vhost/net.c
    fs/dlm/lowcomms.c
    fs/ocfs2/cluster/tcp.c
    security/tomoyo/network.c

Before:
All these functions either return a negative error indicator,
or store length of sockaddr into "int *socklen" parameter
and return zero on success.

"int *socklen" parameter is awkward. For example, if caller does not
care, it still needs to provide on-stack storage for the value
it does not need.

None of the many FOO_getname() functions of various protocols
ever used old value of *socklen. They always just overwrite it.

This change drops this parameter, and makes all these functions, on success,
return length of sockaddr. It's always >= 0 and can be differentiated
from an error.

Tests in callers are changed from "if (err)" to "if (err < 0)", where needed.

rpc_sockname() lost "int buflen" parameter, since its only use was
to be passed to kernel_getsockname() as &buflen and subsequently
not used in any way.

Userspace API is not changed.

    text    data     bss      dec     hex filename
30108430 2633624  873672 33615726 200ef6e vmlinux.before.o
30108109 2633612  873672 33615393 200ee21 vmlinux.o

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: David S. Miller <davem@davemloft.net>
CC: linux-kernel@vger.kernel.org
CC: netdev@vger.kernel.org
CC: linux-bluetooth@vger.kernel.org
CC: linux-decnet-user@lists.sourceforge.net
CC: linux-wireless@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: linux-sctp@vger.kernel.org
CC: linux-nfs@vger.kernel.org
CC: linux-x25@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
55 files changed:
drivers/infiniband/hw/usnic/usnic_transport.c
drivers/isdn/mISDN/socket.c
drivers/net/ppp/pppoe.c
drivers/net/ppp/pptp.c
drivers/scsi/iscsi_tcp.c
drivers/soc/qcom/qmi_interface.c
drivers/staging/ipx/af_ipx.c
drivers/staging/irda/net/af_irda.c
drivers/staging/lustre/lnet/lnet/lib-socket.c
drivers/target/iscsi/iscsi_target_login.c
drivers/vhost/net.c
fs/dlm/lowcomms.c
fs/ocfs2/cluster/tcp.c
include/linux/net.h
include/net/inet_common.h
include/net/ipv6.h
include/net/sock.h
net/appletalk/ddp.c
net/atm/pvc.c
net/atm/svc.c
net/ax25/af_ax25.c
net/bluetooth/hci_sock.c
net/bluetooth/l2cap_sock.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c
net/can/raw.c
net/core/sock.c
net/decnet/af_decnet.c
net/ipv4/af_inet.c
net/ipv6/af_inet6.c
net/iucv/af_iucv.c
net/l2tp/l2tp_ip.c
net/l2tp/l2tp_ip6.c
net/l2tp/l2tp_ppp.c
net/llc/af_llc.c
net/netlink/af_netlink.c
net/netrom/af_netrom.c
net/nfc/llcp_sock.c
net/packet/af_packet.c
net/phonet/socket.c
net/qrtr/qrtr.c
net/rds/af_rds.c
net/rds/tcp.c
net/rose/af_rose.c
net/sctp/ipv6.c
net/smc/af_smc.c
net/socket.c
net/sunrpc/clnt.c
net/sunrpc/svcsock.c
net/sunrpc/xprtsock.c
net/tipc/socket.c
net/unix/af_unix.c
net/vmw_vsock/af_vsock.c
net/x25/af_x25.c
security/tomoyo/network.c