Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Aug 2020 17:41:30 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r364200 - in stable/12: lib/libc/net usr.sbin/nscd
Message-ID:  <202008131741.07DHfUoa051450@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Aug 13 17:41:29 2020
New Revision: 364200
URL: https://svnweb.freebsd.org/changeset/base/364200

Log:
  MFC r341009 by des:
  
  Style cleanup.

Modified:
  stable/12/lib/libc/net/nscachedcli.c
  stable/12/usr.sbin/nscd/nscdcli.c
  stable/12/usr.sbin/nscd/query.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/net/nscachedcli.c
==============================================================================
--- stable/12/lib/libc/net/nscachedcli.c	Thu Aug 13 17:37:54 2020	(r364199)
+++ stable/12/lib/libc/net/nscachedcli.c	Thu Aug 13 17:41:29 2020	(r364200)
@@ -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: stable/12/usr.sbin/nscd/nscdcli.c
==============================================================================
--- stable/12/usr.sbin/nscd/nscdcli.c	Thu Aug 13 17:37:54 2020	(r364199)
+++ stable/12/usr.sbin/nscd/nscdcli.c	Thu Aug 13 17:41:29 2020	(r364200)
@@ -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: stable/12/usr.sbin/nscd/query.c
==============================================================================
--- stable/12/usr.sbin/nscd/query.c	Thu Aug 13 17:37:54 2020	(r364199)
+++ stable/12/usr.sbin/nscd/query.c	Thu Aug 13 17:41:29 2020	(r364200)
@@ -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?202008131741.07DHfUoa051450>