diff options
| author | ozaki-r <ozaki-r@NetBSD.org> | 2014-11-26 09:53:53 +0000 |
|---|---|---|
| committer | ozaki-r <ozaki-r@NetBSD.org> | 2014-11-26 09:53:53 +0000 |
| commit | c3b42dac84ad3807b9d3071a80dc364321f839b8 (patch) | |
| tree | 03866ae292467d49ece9666c1e55d8da98db3756 /sys/compat/linux/common/linux_socket.c | |
| parent | 457104d216af1ab63954c1e766ef6526a2b4a2a6 (diff) | |
Tweak ifconf variants
The tweaks make the code intention clear and make further changes easy.
No functional change.
Diffstat (limited to 'sys/compat/linux/common/linux_socket.c')
| -rw-r--r-- | sys/compat/linux/common/linux_socket.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c index 18b8682b9f0..dbad73174b6 100644 --- a/sys/compat/linux/common/linux_socket.c +++ b/sys/compat/linux/common/linux_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $ */ +/* $NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1111,24 +1111,25 @@ linux_getifname(struct lwp *l, register_t *retval, void *data) int linux_getifconf(struct lwp *l, register_t *retval, void *data) { - struct linux_ifreq ifr, *ifrp; + struct linux_ifreq ifr, *ifrp = NULL; struct linux_ifconf ifc; struct ifnet *ifp; struct ifaddr *ifa; struct sockaddr *sa; struct osockaddr *osa; - int space, error = 0; + int space = 0, error = 0; const int sz = (int)sizeof(ifr); + bool docopy; error = copyin(data, &ifc, sizeof(ifc)); if (error) return error; - ifrp = ifc.ifc_req; - if (ifrp == NULL) - space = 0; - else + docopy = ifc.ifc_req != NULL; + if (docopy) { space = ifc.ifc_len; + ifrp = ifc.ifc_req; + } IFNET_FOREACH(ifp) { (void)strncpy(ifr.ifr_name, ifp->if_xname, @@ -1155,7 +1156,7 @@ linux_getifconf(struct lwp *l, register_t *retval, void *data) } } - if (ifrp != NULL) + if (docopy) ifc.ifc_len -= space; else ifc.ifc_len = -space; |
