Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Nov 2018 09:41:47 +0000 (UTC)
From:      =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341009 - in head: lib/libc/net usr.sbin/nscd
Message-ID:  <201811270941.wAR9flYD019783@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: des
Date: Tue Nov 27 09:41:47 2018
New Revision: 341009
URL: https://svnweb.freebsd.org/changeset/base/341009

Log:
  Style cleanup.

Modified:
  head/lib/libc/net/nscachedcli.c
  head/usr.sbin/nscd/nscdcli.c
  head/usr.sbin/nscd/query.c

Modified: head/lib/libc/net/nscachedcli.c
==============================================================================
--- head/lib/libc/net/nscachedcli.c	Tue Nov 27 09:04:06 2018	(r341008)
+++ head/lib/libc/net/nscachedcli.c	Tue Nov 27 09:41:47 2018	(r341009)
@@ -144,29 +144,27 @@ safe_read(struct cached_connection_ *connection, void 
 static int
 send_credentials(struct cached_connection_ *connection, int type)
 {
+	union {
+		struct cmsghdr hdr;
+		char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
+	} cmsg;
+	struct msghdr mhdr;
+	struct iovec iov;
 	struct kevent eventlist;
 	int nevents;
 	ssize_t result;
 	int res;
 
-	struct msghdr cred_hdr;
-	struct iovec iov;
-
-	struct {
-		struct cmsghdr hdr;
-		char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
-	} cmsg;
-
 	memset(&cmsg, 0, sizeof(cmsg));
-	cmsg.hdr.cmsg_len =  CMSG_LEN(sizeof(struct cmsgcred));
+	cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
 	cmsg.hdr.cmsg_level = SOL_SOCKET;
 	cmsg.hdr.cmsg_type = SCM_CREDS;
 
-	memset(&cred_hdr, 0, sizeof(struct msghdr));
-	cred_hdr.msg_iov = &iov;
-	cred_hdr.msg_iovlen = 1;
-	cred_hdr.msg_control = (caddr_t)&cmsg;
-	cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
+	memset(&mhdr, 0, sizeof(mhdr));
+	mhdr.msg_iov = &iov;
+	mhdr.msg_iovlen = 1;
+	mhdr.msg_control = &cmsg;
+	mhdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
 
 	iov.iov_base = &type;
 	iov.iov_len = sizeof(int);
@@ -178,8 +176,8 @@ send_credentials(struct cached_connection_ *connection
 	nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1,
 	    NULL);
 	if (nevents == 1 && eventlist.filter == EVFILT_WRITE) {
-		result = (_sendmsg(connection->sockfd, &cred_hdr,
-		    MSG_NOSIGNAL) == -1) ?  -1 : 0;
+		result = _sendmsg(connection->sockfd, &mhdr,
+		    MSG_NOSIGNAL) == -1 ? -1 : 0;
 		EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
 		    0, 0, NULL);
 		_kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);

Modified: head/usr.sbin/nscd/nscdcli.c
==============================================================================
--- head/usr.sbin/nscd/nscdcli.c	Tue Nov 27 09:04:06 2018	(r341008)
+++ head/usr.sbin/nscd/nscdcli.c	Tue Nov 27 09:41:47 2018	(r341009)
@@ -130,44 +130,41 @@ safe_read(struct nscd_connection_ *connection, void *d
 static int
 send_credentials(struct nscd_connection_ *connection, int type)
 {
+	union {
+		struct cmsghdr hdr;
+		char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
+	} cmsg;
+	struct msghdr mhdr;
+	struct iovec iov;
 	struct kevent eventlist;
 	int nevents;
 	ssize_t result;
 	int res;
 
-	struct msghdr	cred_hdr;
-	struct iovec	iov;
-
-	union {
-		struct cmsghdr	hdr;
-		char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
-	} cmsg;
-
 	TRACE_IN(send_credentials);
 	memset(&cmsg, 0, sizeof(cmsg));
 	cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
 	cmsg.hdr.cmsg_level = SOL_SOCKET;
 	cmsg.hdr.cmsg_type = SCM_CREDS;
 
-	memset(&cred_hdr, 0, sizeof(struct msghdr));
-	cred_hdr.msg_iov = &iov;
-	cred_hdr.msg_iovlen = 1;
-	cred_hdr.msg_control = &cmsg;
-	cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
+	memset(&mhdr, 0, sizeof(mhdr));
+	mhdr.msg_iov = &iov;
+	mhdr.msg_iovlen = 1;
+	mhdr.msg_control = &cmsg;
+	mhdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
 
 	iov.iov_base = &type;
 	iov.iov_len = sizeof(int);
 
 	EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
-		NOTE_LOWAT, sizeof(int), NULL);
+	    NOTE_LOWAT, sizeof(int), NULL);
 	res = kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
 
 	nevents = kevent(connection->write_queue, NULL, 0, &eventlist, 1, NULL);
 	if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
-		result = (sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ? -1
-	    		: 0;
+		result = sendmsg(connection->sockfd, &mhdr, 0) == -1 ? -1 : 0;
 		EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
-			0, 0, NULL);
+		    0, 0, NULL);
 		kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
 		TRACE_OUT(send_credentials);
 		return (result);

Modified: head/usr.sbin/nscd/query.c
==============================================================================
--- head/usr.sbin/nscd/query.c	Tue Nov 27 09:04:06 2018	(r341008)
+++ head/usr.sbin/nscd/query.c	Tue Nov 27 09:41:47 2018	(r341009)
@@ -155,38 +155,37 @@ clear_config_entry_part(struct configuration_entry *co
 static int
 on_query_startup(struct query_state *qstate)
 {
-	struct msghdr	cred_hdr;
-	struct iovec	iov;
+	union {
+		struct cmsghdr hdr;
+		char pad[CMSG_SPACE(sizeof(struct cmsgcred))];
+	} cmsg;
+	struct msghdr mhdr;
+	struct iovec iov;
 	struct cmsgcred *cred;
 	int elem_type;
 
-	union {
-		struct cmsghdr	hdr;
-		char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
-	} cmsg;
-
 	TRACE_IN(on_query_startup);
 	assert(qstate != NULL);
 
-	memset(&cred_hdr, 0, sizeof(struct msghdr));
-	cred_hdr.msg_iov = &iov;
-	cred_hdr.msg_iovlen = 1;
-	cred_hdr.msg_control = &cmsg;
-	cred_hdr.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
+	memset(&mhdr, 0, sizeof(mhdr));
+	mhdr.msg_iov = &iov;
+	mhdr.msg_iovlen = 1;
+	mhdr.msg_control = &cmsg;
+	mhdr.msg_controllen = sizeof(cmsg);
 
-	memset(&iov, 0, sizeof(struct iovec));
+	memset(&iov, 0, sizeof(iov));
 	iov.iov_base = &elem_type;
-	iov.iov_len = sizeof(int);
+	iov.iov_len = sizeof(elem_type);
 
-	if (recvmsg(qstate->sockfd, &cred_hdr, 0) == -1) {
+	if (recvmsg(qstate->sockfd, &mhdr, 0) == -1) {
 		TRACE_OUT(on_query_startup);
 		return (-1);
 	}
 
-	if (cred_hdr.msg_controllen < CMSG_LEN(sizeof(struct cmsgcred))
-		|| cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred))
-		|| cmsg.hdr.cmsg_level != SOL_SOCKET
-		|| cmsg.hdr.cmsg_type != SCM_CREDS) {
+	if (mhdr.msg_controllen != CMSG_SPACE(sizeof(struct cmsgcred)) ||
+	    cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(struct cmsgcred)) ||
+	    cmsg.hdr.cmsg_level != SOL_SOCKET ||
+	    cmsg.hdr.cmsg_type != SCM_CREDS) {
 		TRACE_OUT(on_query_startup);
 		return (-1);
 	}
@@ -206,9 +205,9 @@ on_query_startup(struct query_state *qstate)
 		return (-1);
 #else
 		if ((elem_type != CET_READ_REQUEST) &&
-			(elem_type != CET_MP_READ_SESSION_REQUEST) &&
-			(elem_type != CET_WRITE_REQUEST) &&
-			(elem_type != CET_MP_WRITE_SESSION_REQUEST)) {
+		    (elem_type != CET_MP_READ_SESSION_REQUEST) &&
+		    (elem_type != CET_WRITE_REQUEST) &&
+		    (elem_type != CET_MP_WRITE_SESSION_REQUEST)) {
 			TRACE_OUT(on_query_startup);
 			return (-1);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811270941.wAR9flYD019783>