From nobody Tue Apr 23 04:52:43 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 4VNqVg3QFVz5JQML; Tue, 23 Apr 2024 04:52:43 +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 4VNqVg2Zjpz4YSB; Tue, 23 Apr 2024 04:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713847963; 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=TRFF0fks9dOC3eyHfASATQTxgmWqAhnQVBE5yp5prr4=; b=txSsS88Tg/GYmsb3mHVa0WprwREg2zC7WbztEha7+tg95kkg0BNnFwxSU2lXTFtNiCKQix MBJFFs6GXKEb/0Esw0NIMTGevwBfcsywutaVXFA5SojUbOpGZoaUEw2ibWSFNr6yrOA0zI 7u+sYOVM8W/7Ir+R6rdFHVCvnDVVyG8ClcE84fCIlSlHIZoeo/q0C3tVAJMRpZCyuBjB1R JKnyJQLskSSjCGWmPsmskXhFQUGdM9aU3g3UbYMUKtEwR7BelRXdKW2eUmJ9uxLWQmDYCe UnJJ/3IzX3HON31/ls7tQXTV3otChZdAIbiJK4gS6ON69NyjLpvsceySZUEKJQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713847963; a=rsa-sha256; cv=none; b=dmQOI7tJjqQYrpN23/EmD6OQCXTGYWrFVTLX2cjD8KfZPhY52a+PUATOnraOW6aMxuZnRf DKzrPTQb+KX9NWv4XJ4RO8wnEEMmLiGdlVrkJAwKcssSXcaUlEexXI7yfuUu3/5C4JE553 OTBBscGgkBkxvH5N+MryP3W2krD6yDYM/AAWi4zT3i/eGNKaT96g8rdIT/1hKQAjX4oCGe pufs5hMDF31Cr8hmNRZb6IGKH1dN9Zuj4s19AVBelSSJnHp9dx+D3Eot2dg8kTLeEyoCE+ Es1y4/fMTwrQKnoDWoxOaXESN8YNPuoM5ierviVfS7VbLiVD6VV/V60Ubpv+fQ== 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=1713847963; 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=TRFF0fks9dOC3eyHfASATQTxgmWqAhnQVBE5yp5prr4=; b=Tfr6uE93K/xLbogQcIlSHbZGiX85RnbCATZKGugIV1knBpStLjWA44J3pnUjnvgsfSB+IB Zy45qAXxItW6bRVKufUC8ehZCjCINq+ayNroc+hgTyE+28lUCOs3Tht8afBdnVkrVtSGlr rus4OSjwWwjlXgbB6zpEm61UpLvr5A2gWXOimKS+KQCZgxnVnyz/jbqFBGhXhQm8h1OSWt j1/JVf/ovQ6EgJdqlVNAoaHCeFzDcII7qGhsZ7J87m8dztmVVE2SdYuG7wNlbrXvr7LeYz Jy0SoTvjJB0f3canTzrgE7m7EyElnqRDKxZ1qt1xV3x3zHHRpxuSrGRCupeVbQ== 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 4VNqVg293hzHmT; Tue, 23 Apr 2024 04:52:43 +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 43N4qh1T063684; Tue, 23 Apr 2024 04:52:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43N4qhYd063681; Tue, 23 Apr 2024 04:52:43 GMT (envelope-from git) Date: Tue, 23 Apr 2024 04:52:43 GMT Message-Id: <202404230452.43N4qhYd063681@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 50ecbc5142e1 - main - libipsec: make const-correct 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 50ecbc5142e1c58f2132b351da19c5e4aa5f4e6a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=50ecbc5142e1c58f2132b351da19c5e4aa5f4e6a commit 50ecbc5142e1c58f2132b351da19c5e4aa5f4e6a Author: Lexi Winter AuthorDate: 2024-04-22 21:56:24 +0000 Commit: Warner Losh CommitDate: 2024-04-23 04:36:34 +0000 libipsec: make const-correct - add const to the appropriate places in the libipsec public API and the relevant internal functions needed to support that. - replace caddr_t with c_caddr_t in ipsec_dump_policy() - update the ipsec_dump_policy manpage to use c_caddr_t (this manpage was already wrong as it had "char *" instead of caddr_t previously). While here, update pfkeyv2.h to not cast away const in the PFKEY_*() macros. This should not cause any ABI changes as the actual types have not changed. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1099 --- lib/libipsec/ipsec_dump_policy.c | 4 ++-- lib/libipsec/ipsec_get_policylen.c | 2 +- lib/libipsec/ipsec_set_policy.3 | 6 +++--- lib/libipsec/policy_parse.y | 20 ++++++++++---------- sys/net/pfkeyv2.h | 8 ++++---- sys/netipsec/ipsec.h | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/libipsec/ipsec_dump_policy.c b/lib/libipsec/ipsec_dump_policy.c index 49b643d80115..5ad8a84b2052 100644 --- a/lib/libipsec/ipsec_dump_policy.c +++ b/lib/libipsec/ipsec_dump_policy.c @@ -67,9 +67,9 @@ static char *set_address(char *, size_t, struct sockaddr *); * When delimiter == NULL, alternatively ' '(space) is applied. */ char * -ipsec_dump_policy(caddr_t policy, char *delimiter) +ipsec_dump_policy(c_caddr_t policy, const char *delimiter) { - struct sadb_x_policy *xpl = (struct sadb_x_policy *)policy; + const struct sadb_x_policy *xpl = (const struct sadb_x_policy *)policy; struct sadb_x_ipsecrequest *xisr; size_t off, buflen; char *buf; diff --git a/lib/libipsec/ipsec_get_policylen.c b/lib/libipsec/ipsec_get_policylen.c index 8080bec0f48e..2454d875e1fa 100644 --- a/lib/libipsec/ipsec_get_policylen.c +++ b/lib/libipsec/ipsec_get_policylen.c @@ -41,7 +41,7 @@ #include "ipsec_strerror.h" int -ipsec_get_policylen(caddr_t policy) +ipsec_get_policylen(c_caddr_t policy) { return policy ? PFKEY_EXTLEN(policy) : -1; } diff --git a/lib/libipsec/ipsec_set_policy.3 b/lib/libipsec/ipsec_set_policy.3 index 6a40e03af45f..ce4d8d244292 100644 --- a/lib/libipsec/ipsec_set_policy.3 +++ b/lib/libipsec/ipsec_set_policy.3 @@ -41,11 +41,11 @@ .Sh SYNOPSIS .In netipsec/ipsec.h .Ft "char *" -.Fn ipsec_set_policy "char *policy" "int len" +.Fn ipsec_set_policy "const char *policy" "int len" .Ft int -.Fn ipsec_get_policylen "char *buf" +.Fn ipsec_get_policylen "const char *buf" .Ft "char *" -.Fn ipsec_dump_policy "char *buf" "char *delim" +.Fn ipsec_dump_policy "c_caddr_t *buf" "const char *delim" .Sh DESCRIPTION The .Fn ipsec_set_policy diff --git a/lib/libipsec/policy_parse.y b/lib/libipsec/policy_parse.y index 65894e37965a..35512dcc1f58 100644 --- a/lib/libipsec/policy_parse.y +++ b/lib/libipsec/policy_parse.y @@ -77,16 +77,16 @@ static struct sockaddr *p_src = NULL; static struct sockaddr *p_dst = NULL; struct _val; -extern void yyerror(char *msg); -static struct sockaddr *parse_sockaddr(struct _val *buf); +extern void yyerror(const char *msg); +static struct sockaddr *parse_sockaddr(const struct _val *buf); static int rule_check(void); static int init_x_policy(void); static int set_x_request(struct sockaddr *src, struct sockaddr *dst); -static int set_sockaddr(struct sockaddr *addr); +static int set_sockaddr(const struct sockaddr *addr); static void policy_parse_request_init(void); -static caddr_t policy_parse(char *msg, int msglen); +static caddr_t policy_parse(const char *msg, int msglen); -extern void __policy__strbuffer__init__(char *msg); +extern void __policy__strbuffer__init__(const char *msg); extern void __policy__strbuffer__free__(void); extern int yylex(void); @@ -211,7 +211,7 @@ addresses %% void -yyerror(char *msg) +yyerror(const char *msg) { fprintf(stderr, "libipsec: %s while parsing \"%s\"\n", msg, __libipsecyytext); @@ -220,7 +220,7 @@ yyerror(char *msg) } static struct sockaddr * -parse_sockaddr(struct _val *buf) +parse_sockaddr(const struct _val *buf) { struct addrinfo hints, *res; char *serv = NULL; @@ -346,7 +346,7 @@ set_x_request(struct sockaddr *src, struct sockaddr *dst) } static int -set_sockaddr(struct sockaddr *addr) +set_sockaddr(const struct sockaddr *addr) { if (addr == NULL) { __ipsec_errcode = EIPSEC_NO_ERROR; @@ -383,7 +383,7 @@ policy_parse_request_init(void) } static caddr_t -policy_parse(char *msg, int msglen) +policy_parse(const char *msg, int msglen) { int error; pbuf = NULL; @@ -413,7 +413,7 @@ policy_parse(char *msg, int msglen) } caddr_t -ipsec_set_policy(char *msg, int msglen) +ipsec_set_policy(const char *msg, int msglen) { caddr_t policy; diff --git a/sys/net/pfkeyv2.h b/sys/net/pfkeyv2.h index 912607a11582..a0246c9223ba 100644 --- a/sys/net/pfkeyv2.h +++ b/sys/net/pfkeyv2.h @@ -444,13 +444,13 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch"); /* Utilities */ #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1))) #define PFKEY_EXTLEN(msg) \ - PFKEY_UNUNIT64(((struct sadb_ext *)(msg))->sadb_ext_len) + PFKEY_UNUNIT64(((const struct sadb_ext *)(msg))->sadb_ext_len) #define PFKEY_ADDR_PREFIX(ext) \ - (((struct sadb_address *)(ext))->sadb_address_prefixlen) + (((const struct sadb_address *)(ext))->sadb_address_prefixlen) #define PFKEY_ADDR_PROTO(ext) \ - (((struct sadb_address *)(ext))->sadb_address_proto) + (((const struct sadb_address *)(ext))->sadb_address_proto) #define PFKEY_ADDR_SADDR(ext) \ - ((struct sockaddr *)((caddr_t)(ext) + sizeof(struct sadb_address))) + ((const struct sockaddr *)((c_caddr_t)(ext) + sizeof(struct sadb_address))) /* in 64bits */ #define PFKEY_UNUNIT64(a) ((a) << 3) diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h index eea0a39af5ea..88594d250fdb 100644 --- a/sys/netipsec/ipsec.h +++ b/sys/netipsec/ipsec.h @@ -350,9 +350,9 @@ extern int m_striphdr(struct mbuf *m, int skip, int hlen); #endif /* _KERNEL */ #ifndef _KERNEL -extern caddr_t ipsec_set_policy(char *, int); -extern int ipsec_get_policylen(caddr_t); -extern char *ipsec_dump_policy(caddr_t, char *); +extern caddr_t ipsec_set_policy(const char *, int); +extern int ipsec_get_policylen(c_caddr_t); +extern char *ipsec_dump_policy(c_caddr_t, const char *); extern const char *ipsec_strerror(void); #endif /* ! KERNEL */