]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
datatype: return const pointer from datatype_get()
authorThomas Haller <thaller@redhat.com>
Wed, 20 Sep 2023 20:09:19 +0000 (22:09 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 20 Sep 2023 22:00:38 +0000 (00:00 +0200)
"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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/datatype.h
src/datatype.c

index 4e838a38b34f1058d6042287269d113b12ac3337..09a7894567e4d34312bc980a1ac91926498fb58f 100644 (file)
@@ -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);
index 8d65ab8bcd7f981d82b0a6a179ff1cf396b18ebc..f5d700bd8d21ead4b0cfa57a41e68a31c99bd788 100644 (file)
@@ -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;