From nobody Tue Feb 27 20:00:07 2024 X-Original-To: dev-commits-src-all@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 4TkpHW6rZMz5CKrq; Tue, 27 Feb 2024 20:00:07 +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 4TkpHW60q2z59QR; Tue, 27 Feb 2024 20:00:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709064007; 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=nnT+oaUcUq5tZxvvmPt+dIceGu1sMPcC7uSWLQWFnpg=; b=wPk4aCbvUMF1zIahvebhd9tCiL2mSQQ38MXjtfP/FMmT+8jRsNx7f+HqkC9xkMRivgd1y/ zTW4NJdizXDI03L9ksSV1UR4wPUz6STw/rRDlamXemVSUyAjq/RsktY/99mpThbT5msony WSwEXoFSLwEV5WDFTaPL6Nl1LNeXSvwvP7HY1JGxYyJslMVWK2c03i0QgRbZb/SegS0H/p lNthZbxbyXI2fHV+unkmUaCY9DF1lQlVi0X1awC5LaHcCeEKv15wXBkZCamGnJ1VN8YNEW sJCiGLW3tqf6axCymXXAKOLvpS798ifeknFzEmhZT111S1ot1f6c1QQGn9X0rg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709064007; a=rsa-sha256; cv=none; b=YQKyHRNBbiB7l14nsLCDBQcsUjNF7geVDzbya5xPCaisaH7YNu0HIVoLvd1snILeDLFP2X WK+iht2IB/KCrAjHTEfKFGemDNETR1QetStNUmTqaRLzi6J1UcTIjCR9Mza1WbLAUbq+73 2kVvvoR7rWDY2QOZtgLKxhi7hw0iADMVo7qNSMjlsyD+r5HoVfcu8zHmpr+PlTU+gLw0IR rtMLF+jbf+hPq6tnQebqgtYKH5vPP4AngxMqq8uzebujRvAZqzQzElgUsLr+VJ9kgEmuQm mXyn5SG/FYnB4KYbFH74yZ6rv2GubZp8KrHy60+KirSfiakAyeEGvqn3sUKmhA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709064007; 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=nnT+oaUcUq5tZxvvmPt+dIceGu1sMPcC7uSWLQWFnpg=; b=pXS73aMAtGQvLmjX3bS+TyCjtFfvyYg6jrHKIByU5PJMNp5Fhz5lHJdcDHZTs0Bp10Ptve QeoYX/qOvaWbMSiDqWQs33eocOJ+sZL+AUtbmv2KFC0SRtEQhlQfd8A+3f3erl7TeapOXp 4SyYNavNR+3yL4D/FTKrzcnNvpvctzAawElsyvJPapBvNJSIYNT3C8o+G+fs6MiSD3MZzk Gc1QbWsq1DL3jS01Nq9rj6cKdgDjwAEiPsDu+iSwwn5UED5eXI8u2Z+weZCEYAMUkCJOow 2roEZY47kdwhwHueabCfRGWiKL/wrlXepVuXO4ZxGSgwATLzJgpvj2R9LUMpLQ== 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 4TkpHW55tZzR8d; Tue, 27 Feb 2024 20:00:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41RK07v4014655; Tue, 27 Feb 2024 20:00:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41RK07Hk014650; Tue, 27 Feb 2024 20:00:07 GMT (envelope-from git) Date: Tue, 27 Feb 2024 20:00:07 GMT Message-Id: <202402272000.41RK07Hk014650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 69945c49fea7 - main - netlink: Don't use a zero-length array List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 69945c49fea7ac2352c1fd7d22f70f2e3861ba81 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=69945c49fea7ac2352c1fd7d22f70f2e3861ba81 commit 69945c49fea7ac2352c1fd7d22f70f2e3861ba81 Author: John Baldwin AuthorDate: 2024-02-27 19:59:52 +0000 Commit: John Baldwin CommitDate: 2024-02-27 19:59:52 +0000 netlink: Don't use a zero-length array Define SNL_DECLARE_FIELD_PARSER* macros to create a parser that has no output attributes only input fields and use this to define the snl_donemsg_parser. This removes the need for the zero-length nla_p_donemsg[] variable. Zero length arrays are not valid in ISO C. Reviewed by: jrtc27, melifaro Differential Revision: https://reviews.freebsd.org/D43918 --- sys/netlink/netlink_snl.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index 6636d53f2353..89ba5b5aef5d 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -174,6 +174,18 @@ static const struct snl_hdr_parser _name = { \ #define SNL_DECLARE_PARSER(_name, _t, _fp, _np) \ SNL_DECLARE_PARSER_EXT(_name, sizeof(_t), 0, _fp, _np, NULL) +#define SNL_DECLARE_FIELD_PARSER_EXT(_name, _sz_h_in, _sz_out, _fp, _cb) \ +static const struct snl_hdr_parser _name = { \ + .in_hdr_size = _sz_h_in, \ + .out_size = _sz_out, \ + .fp = &((_fp)[0]), \ + .fp_size = NL_ARRAY_LEN(_fp), \ + .cb_post = _cb, \ +} + +#define SNL_DECLARE_FIELD_PARSER(_name, _t, _fp) \ + SNL_DECLARE_FIELD_PARSER_EXT(_name, sizeof(_t), 0, _fp, NULL) + #define SNL_DECLARE_ATTR_PARSER_EXT(_name, _sz_out, _np, _cb) \ static const struct snl_hdr_parser _name = { \ .out_size = _sz_out, \ @@ -921,14 +933,12 @@ SNL_DECLARE_PARSER(snl_errmsg_parser, struct nlmsgerr, nlf_p_errmsg, nla_p_errms #define _IN(_field) offsetof(struct nlmsgerr, _field) #define _OUT(_field) offsetof(struct snl_errmsg_data, _field) -static const struct snl_attr_parser nla_p_donemsg[] = {}; - static const struct snl_field_parser nlf_p_donemsg[] = { { .off_in = _IN(error), .off_out = _OUT(error), .cb = snl_field_get_uint32 }, }; #undef _IN #undef _OUT -SNL_DECLARE_PARSER(snl_donemsg_parser, struct nlmsgerr, nlf_p_donemsg, nla_p_donemsg); +SNL_DECLARE_FIELD_PARSER(snl_donemsg_parser, struct nlmsgerr, nlf_p_donemsg); static inline bool snl_parse_errmsg(struct snl_state *ss, struct nlmsghdr *hdr, struct snl_errmsg_data *e)