* [PATCH nft] datatype: return const pointer from datatype_get()
@ 2023-09-20 20:09 Thomas Haller
2023-09-20 22:00 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Haller @ 2023-09-20 20:09 UTC (permalink / raw)
To: NetFilter; +Cc: Thomas Haller
"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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-20 22:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 20:09 [PATCH nft] datatype: return const pointer from datatype_get() Thomas Haller
2023-09-20 22:00 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox