From nobody Tue Jan 17 14:45:45 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NxBX96xZqz2sTgc; Tue, 17 Jan 2023 14:45:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NxBX96LMGz4CpK; Tue, 17 Jan 2023 14:45:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673966745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5RGe2Gty5P/y9loAC7CUIglQopOxgz2XE259/IDom20=; b=AeYseixjEx8eclK2RIPTkoQDM2zGHNnW2p09d9sNwyFM3NEXpan8yzbUHjRasFc8cwHb+S 3jq3zGufuJfeh7O8RrqrzJ92C3EwYkR/BzmEcwYNaVqZg8KjKg210ZaWZXdl0mXYQ9y8Nv kKU33tg7KS3zcFIskN6R3GBUSuQ9NhJ+RwyUG1wTbREObLK+IGjq72YjGxsegJQ2leRTh+ kG7Disn2a1NGpMBLhldphxVvXJEIMUvbdSrHAE/suHWUuUy7LOXQggprgCud3Aa5OwbkcA W1lXGkiiRBtOylIXnHA5LmaFygE4jXC7lG7JRxwgEQSIhxC2+4SkNnNh+wA/nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673966745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5RGe2Gty5P/y9loAC7CUIglQopOxgz2XE259/IDom20=; b=aWebsBIsIzD7saizmeR/SYZ4FQooSRGQG5mCGhJ7URcdhb+4RN+Lyh5gZzAyddC+3YUHOu dXjeXGzpjX8d5m00eql4EAw3mNeyv9iHlJYJcw8pudVUguzT0CT5150DQhmM3SdfbYI8l7 Qf5g7mzXKz15CqudbcNEZOrFQ5qKXqbYKGWmDOh4hJ7PgTukGqlCC8LG5YJOxmSG6m+jH4 jKa8OwdcwBz6nkO5aNKGPY7Xdcwh5caw2A7bwsZp4UaFS94w6skRv+8BA/WAakJhV5DErP s1OaVXYsfzf2gezTVosa9cc2LxMRZl/PSWvVFwJVnAz8DfLVV82j+UyGBiz33Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673966745; a=rsa-sha256; cv=none; b=rZplD9Pl548pAx7Ph6prye7ZHJZL+N/L6egAGX/13d/WxM6pFvnUyXaTRWUGmdPbEiH9pJ 9f63hZQhTx+KFM/QbFm9+ixYblWdoUUnl7pppNH6FhCYj8YQyAQK9iWULkq5d+yna5Dtzy 38Cb3gCnlJl6wAH0tEX3MWSoMfcOgiX2neCMiZMOb8W7GIVHheOApx3wnheEJNC1r1gImg 7opqmC7p1lFhrSShJalE8DiKXBQLvEEwpQdBoGJOvlP9Uyxeowz1YuTpNZ4l/GmK82HieV zKo19DKtMoQPDa4bP2DCea4WxPUU6by5WHHQGb+Fp3mgAPA++dC/zJQ0x5zxlw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NxBX95QJMzbPs; Tue, 17 Jan 2023 14:45:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30HEjjlH033690; Tue, 17 Jan 2023 14:45:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30HEjjj9033689; Tue, 17 Jan 2023 14:45:45 GMT (envelope-from git) Date: Tue, 17 Jan 2023 14:45:45 GMT Message-Id: <202301171445.30HEjjj9033689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 35472cb60ab9 - main - netlink: Fix indentation in netlink_message_writer.c List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 35472cb60ab95b4d99981492a87443022181eac2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=35472cb60ab95b4d99981492a87443022181eac2 commit 35472cb60ab95b4d99981492a87443022181eac2 Author: Mark Johnston AuthorDate: 2023-01-17 14:37:33 +0000 Commit: Mark Johnston CommitDate: 2023-01-17 14:37:33 +0000 netlink: Fix indentation in netlink_message_writer.c This file is indented with a mixture of tabs and spaces. No functional change intended. Reviewed by: melifaro Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38100 --- sys/netlink/netlink_message_writer.c | 135 +++++++++++++++++------------------ 1 file changed, 67 insertions(+), 68 deletions(-) diff --git a/sys/netlink/netlink_message_writer.c b/sys/netlink/netlink_message_writer.c index 0d27d5d0d47c..2187c40f2786 100644 --- a/sys/netlink/netlink_message_writer.c +++ b/sys/netlink/netlink_message_writer.c @@ -130,7 +130,7 @@ nlmsg_write_socket_buf(struct nl_writer *nw, void *buf, int datalen, int cnt) free(buf, M_NETLINK); int io_flags = (nw->ignore_limit) ? NL_IOF_IGNORE_LIMIT : 0; - return (nl_send_one(m, (struct nlpcb *)(nw->arg_ptr), cnt, io_flags)); + return (nl_send_one(m, (struct nlpcb *)(nw->arg_ptr), cnt, io_flags)); } static bool @@ -153,7 +153,7 @@ nlmsg_write_group_buf(struct nl_writer *nw, void *buf, int datalen, int cnt) if (!success) return (false); - nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); + nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); return (true); } @@ -182,7 +182,7 @@ nlmsg_write_chain_buf(struct nl_writer *nw, void *buf, int datalen, int cnt) free(buf, M_NETLINK); return (false); } - return (true); + return (true); } @@ -203,12 +203,12 @@ nlmsg_get_ns_mbuf(struct nl_writer *nw, int size, bool waitok) struct mbuf *m; int mflag = waitok ? M_WAITOK : M_NOWAIT; - m = m_get2(size, mflag, MT_DATA, M_PKTHDR); - if (__predict_false(m == NULL)) - return (false); - nw->alloc_len = M_TRAILINGSPACE(m); - nw->offset = 0; - nw->hdr = NULL; + m = m_get2(size, mflag, MT_DATA, M_PKTHDR); + if (__predict_false(m == NULL)) + return (false); + nw->alloc_len = M_TRAILINGSPACE(m); + nw->offset = 0; + nw->hdr = NULL; nw->_storage = (void *)m; nw->data = mtod(m, void *); nw->writer_type = NS_WRITER_TYPE_MBUF; @@ -216,9 +216,9 @@ nlmsg_get_ns_mbuf(struct nl_writer *nw, int size, bool waitok) nw->num_messages = 0; nw->enomem = false; memset(nw->data, 0, size); - NL_LOG(LOG_DEBUG2, "alloc mbuf %p req_len %d alloc_len %d data_ptr %p", - m, size, nw->alloc_len, nw->data); - return (true); + NL_LOG(LOG_DEBUG2, "alloc mbuf %p req_len %d alloc_len %d data_ptr %p", + m, size, nw->alloc_len, nw->data); + return (true); } static bool @@ -235,7 +235,7 @@ nlmsg_write_socket_mbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) m->m_pkthdr.len = datalen; m->m_len = datalen; int io_flags = (nw->ignore_limit) ? NL_IOF_IGNORE_LIMIT : 0; - return (nl_send_one(m, (struct nlpcb *)(nw->arg_ptr), cnt, io_flags)); + return (nl_send_one(m, (struct nlpcb *)(nw->arg_ptr), cnt, io_flags)); } static bool @@ -251,7 +251,7 @@ nlmsg_write_group_mbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) m->m_pkthdr.len = datalen; m->m_len = datalen; - nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); + nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); return (true); } @@ -281,7 +281,7 @@ nlmsg_write_chain_mbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) (*m0)->m_pkthdr.len += datalen; } - return (true); + return (true); } /* @@ -317,7 +317,6 @@ nlmsg_get_ns_lbuf(struct nl_writer *nw, int size, bool waitok) return (true); } - static bool nlmsg_write_socket_lbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) { @@ -341,7 +340,7 @@ nlmsg_write_socket_lbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) } int io_flags = (nw->ignore_limit) ? NL_IOF_IGNORE_LIMIT : 0; - return (nl_send_one(m, nlp, cnt, io_flags)); + return (nl_send_one(m, nlp, cnt, io_flags)); } /* Shouldn't be called (maybe except Linux code originating message) */ @@ -364,7 +363,7 @@ nlmsg_write_group_lbuf(struct nl_writer *nw, void *buf, int datalen, int cnt) m_append(m, datalen, data); free(buf, M_NETLINK); - nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); + nl_send_group(m, cnt, nw->arg_uint >> 16, nw->arg_uint & 0xFFFF); return (true); } @@ -437,36 +436,36 @@ nlmsg_get_buf(struct nl_writer *nw, int size, bool waitok, bool is_linux) bool nlmsg_get_unicast_writer(struct nl_writer *nw, int size, struct nlpcb *nlp) { - if (!nlmsg_get_buf(nw, size, false, nlp->nl_linux)) - return (false); - nw->arg_ptr = (void *)nlp; + if (!nlmsg_get_buf(nw, size, false, nlp->nl_linux)) + return (false); + nw->arg_ptr = (void *)nlp; nw->writer_target = NS_WRITER_TARGET_SOCKET; nlmsg_set_callback(nw); - return (true); + return (true); } bool nlmsg_get_group_writer(struct nl_writer *nw, int size, int protocol, int group_id) { - if (!nlmsg_get_buf(nw, size, false, false)) - return (false); - nw->arg_uint = (uint64_t)protocol << 16 | (uint64_t)group_id; + if (!nlmsg_get_buf(nw, size, false, false)) + return (false); + nw->arg_uint = (uint64_t)protocol << 16 | (uint64_t)group_id; nw->writer_target = NS_WRITER_TARGET_GROUP; nlmsg_set_callback(nw); - return (true); + return (true); } bool nlmsg_get_chain_writer(struct nl_writer *nw, int size, struct mbuf **pm) { - if (!nlmsg_get_buf(nw, size, false, false)) - return (false); + if (!nlmsg_get_buf(nw, size, false, false)) + return (false); *pm = NULL; - nw->arg_ptr = (void *)pm; + nw->arg_ptr = (void *)pm; nw->writer_target = NS_WRITER_TARGET_CHAIN; nlmsg_set_callback(nw); NL_LOG(LOG_DEBUG3, "setup cb %p (need %p)", nw->cb, &nlmsg_write_chain_mbuf); - return (true); + return (true); } void @@ -479,23 +478,23 @@ bool nlmsg_flush(struct nl_writer *nw) { - if (__predict_false(nw->hdr != NULL)) { - /* Last message has not been completed, skip it. */ - int completed_len = (char *)nw->hdr - nw->data; + if (__predict_false(nw->hdr != NULL)) { + /* Last message has not been completed, skip it. */ + int completed_len = (char *)nw->hdr - nw->data; /* Send completed messages */ nw->offset -= nw->offset - completed_len; nw->hdr = NULL; - } + } NL_LOG(LOG_DEBUG2, "OUT"); - bool result = nw->cb(nw, nw->_storage, nw->offset, nw->num_messages); - nw->_storage = NULL; + bool result = nw->cb(nw, nw->_storage, nw->offset, nw->num_messages); + nw->_storage = NULL; - if (!result) { - NL_LOG(LOG_DEBUG, "nw %p offset %d: flush with %p() failed", nw, nw->offset, nw->cb); - } + if (!result) { + NL_LOG(LOG_DEBUG, "nw %p offset %d: flush with %p() failed", nw, nw->offset, nw->cb); + } - return (result); + return (result); } /* @@ -506,8 +505,8 @@ nlmsg_flush(struct nl_writer *nw) bool nlmsg_refill_buffer(struct nl_writer *nw, int required_len) { - struct nl_writer ns_new = {}; - int completed_len, new_len; + struct nl_writer ns_new = {}; + int completed_len, new_len; if (nw->enomem) return (false); @@ -515,7 +514,7 @@ nlmsg_refill_buffer(struct nl_writer *nw, int required_len) NL_LOG(LOG_DEBUG3, "no space at offset %d/%d (want %d), trying to reclaim", nw->offset, nw->alloc_len, required_len); - /* Calculated new buffer size and allocate it s*/ + /* Calculated new buffer size and allocate it s*/ completed_len = (nw->hdr != NULL) ? (char *)nw->hdr - nw->data : nw->offset; if (completed_len > 0 && required_len < MCLBYTES) { /* We already ran out of space, use the largest effective size */ @@ -530,10 +529,10 @@ nlmsg_refill_buffer(struct nl_writer *nw, int required_len) } bool waitok = (nw->malloc_flag == M_WAITOK); bool is_linux = (nw->writer_type == NS_WRITER_TYPE_LBUF); - if (!nlmsg_get_buf(&ns_new, new_len, waitok, is_linux)) { + if (!nlmsg_get_buf(&ns_new, new_len, waitok, is_linux)) { nw->enomem = true; NL_LOG(LOG_DEBUG, "getting new buf failed, setting ENOMEM"); - return (false); + return (false); } if (nw->ignore_limit) nlmsg_ignore_limit(&ns_new); @@ -543,22 +542,22 @@ nlmsg_refill_buffer(struct nl_writer *nw, int required_len) nlmsg_set_callback(&ns_new); ns_new.arg_uint = nw->arg_uint; - /* Copy last (unfinished) header to the new storage */ - int last_len = nw->offset - completed_len; + /* Copy last (unfinished) header to the new storage */ + int last_len = nw->offset - completed_len; if (last_len > 0) { memcpy(ns_new.data, nw->hdr, last_len); ns_new.hdr = (struct nlmsghdr *)ns_new.data; ns_new.offset = last_len; } - NL_LOG(LOG_DEBUG2, "completed: %d bytes, copied: %d bytes", completed_len, last_len); + NL_LOG(LOG_DEBUG2, "completed: %d bytes, copied: %d bytes", completed_len, last_len); - /* Flush completed headers & switch to the new nw */ + /* Flush completed headers & switch to the new nw */ nlmsg_flush(nw); memcpy(nw, &ns_new, sizeof(struct nl_writer)); - NL_LOG(LOG_DEBUG2, "switched buffer: used %d/%d bytes", nw->offset, nw->alloc_len); + NL_LOG(LOG_DEBUG2, "switched buffer: used %d/%d bytes", nw->offset, nw->alloc_len); - return (true); + return (true); } bool @@ -570,23 +569,23 @@ nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type, MPASS(nw->hdr == NULL); int required_len = NETLINK_ALIGN(len + sizeof(struct nlmsghdr)); - if (__predict_false(nw->offset + required_len > nw->alloc_len)) { + if (__predict_false(nw->offset + required_len > nw->alloc_len)) { if (!nlmsg_refill_buffer(nw, required_len)) return (false); - } + } - hdr = (struct nlmsghdr *)(&nw->data[nw->offset]); + hdr = (struct nlmsghdr *)(&nw->data[nw->offset]); - hdr->nlmsg_len = len; - hdr->nlmsg_type = type; - hdr->nlmsg_flags = flags; - hdr->nlmsg_seq = seq; - hdr->nlmsg_pid = portid; + hdr->nlmsg_len = len; + hdr->nlmsg_type = type; + hdr->nlmsg_flags = flags; + hdr->nlmsg_seq = seq; + hdr->nlmsg_pid = portid; - nw->hdr = hdr; - nw->offset += sizeof(struct nlmsghdr); + nw->hdr = hdr; + nw->offset += sizeof(struct nlmsghdr); - return (true); + return (true); } bool @@ -600,11 +599,11 @@ nlmsg_end(struct nl_writer *nw) return (false); } - nw->hdr->nlmsg_len = (uint32_t)(nw->data + nw->offset - (char *)nw->hdr); + nw->hdr->nlmsg_len = (uint32_t)(nw->data + nw->offset - (char *)nw->hdr); NL_LOG(LOG_DEBUG2, "wrote msg len: %u type: %d: flags: 0x%X seq: %u pid: %u", nw->hdr->nlmsg_len, nw->hdr->nlmsg_type, nw->hdr->nlmsg_flags, nw->hdr->nlmsg_seq, nw->hdr->nlmsg_pid); - nw->hdr = NULL; + nw->hdr = NULL; nw->num_messages++; return (true); } @@ -612,10 +611,10 @@ nlmsg_end(struct nl_writer *nw) void nlmsg_abort(struct nl_writer *nw) { - if (nw->hdr != NULL) { - nw->offset = (uint32_t)((char *)nw->hdr - nw->data); - nw->hdr = NULL; - } + if (nw->hdr != NULL) { + nw->offset = (uint32_t)((char *)nw->hdr - nw->data); + nw->hdr = NULL; + } } void