lkml.org 
[lkml]   [2018]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] net: make getname() functions return length rather than use int* parameter
From
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Mon, 12 Feb 2018 15:15:18 +0100

> 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>

Please do an allmodconfig build, there are still some conversions you
missed:

security/tomoyo/network.c: In function ‘tomoyo_socket_listen_permission’:
security/tomoyo/network.c:658:19: warning: passing argument 3 of ‘sock->ops->getname’ makes integer from pointer without a cast [-Wint-conversion]
&addr, &addr_len, 0);
^
security/tomoyo/network.c:658:19: note: expected ‘int’ but argument is of type ‘int *’
security/tomoyo/network.c:657:21: error: too many arguments to function ‘sock->ops->getname’
const int error = sock->ops->getname(sock, (struct sockaddr *)
^~~~
fs/dlm/lowcomms.c: In function ‘lowcomms_error_report’:
fs/dlm/lowcomms.c:495:6: error: too many arguments to function ‘kernel_getpeername’
kernel_getpeername(con->sock, (struct sockaddr *)&saddr, &buflen)) {
^~~~~~~~~~~~~~~~~~
fs/dlm/lowcomms.c: In function ‘tcp_accept_from_sock’:
fs/dlm/lowcomms.c:761:7: warning: passing argument 3 of ‘newsock->ops->getname’ makes integer from pointer without a cast [-Wint-conversion]
&len, 2)) {
^
fs/dlm/lowcomms.c:761:7: note: expected ‘int’ but argument is of type ‘int *’
fs/dlm/lowcomms.c:760:6: error: too many arguments to function ‘newsock->ops->getname’
if (newsock->ops->getname(newsock, (struct sockaddr *)&peeraddr,
^~~~~~~
\
 
 \ /
  Last update: 2018-02-12 18:49    [W:0.055 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site