From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft] datatype: return const pointer from datatype_get()
Date: Wed, 20 Sep 2023 22:09:19 +0200 [thread overview]
Message-ID: <20230920200922.867334-1-thaller@redhat.com> (raw)
"struct datatype" is for the most part immutable, and most callers deal
with const pointers. That's why datatype_get() accepts a const pointer
to increase the reference count (mutating the refcnt field).
It should also return a const pointer. In fact, all callers are fine
with that already.
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
include/datatype.h | 2 +-
src/datatype.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/datatype.h b/include/datatype.h
index 4e838a38b34f..09a7894567e4 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -174,7 +174,7 @@ struct datatype {
extern const struct datatype *datatype_lookup(enum datatypes type);
extern const struct datatype *datatype_lookup_byname(const char *name);
-extern struct datatype *datatype_get(const struct datatype *dtype);
+extern const struct datatype *datatype_get(const struct datatype *dtype);
extern void datatype_set(struct expr *expr, const struct datatype *dtype);
extern void __datatype_set(struct expr *expr, const struct datatype *dtype);
extern void datatype_free(const struct datatype *dtype);
diff --git a/src/datatype.c b/src/datatype.c
index 8d65ab8bcd7f..f5d700bd8d21 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -1211,7 +1211,7 @@ static struct datatype *datatype_alloc(void)
return dtype;
}
-struct datatype *datatype_get(const struct datatype *ptr)
+const struct datatype *datatype_get(const struct datatype *ptr)
{
struct datatype *dtype = (struct datatype *)ptr;
--
2.41.0
next reply other threads:[~2023-09-20 20:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 20:09 Thomas Haller [this message]
2023-09-20 22:00 ` [PATCH nft] datatype: return const pointer from datatype_get() Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230920200922.867334-1-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox