]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: fix enum/integer mismatches
authorFlorian Westphal <fw@strlen.de>
Sat, 29 Apr 2023 13:48:09 +0000 (15:48 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 29 Apr 2023 13:48:09 +0000 (15:48 +0200)
gcc 13 complains about type confusion:
cache.c:1178:5: warning: conflicting types for 'nft_cache_update' due to enum/integer mismatch;
have 'int(struct nft_ctx *, unsigned int,  struct list_head *, const struct nft_cache_filter *)' [-Wenum-int-mismatch]
cache.h:74:5: note: previous declaration of 'nft_cache_update' with type 'int(struct nft_ctx *, enum cmd_ops,  struct list_head *, const struct nft_cache_filter *)'

Same for:
rule.c:1915:13: warning: conflicting types for 'obj_type_name' due to enum/integer mismatch; have 'const char *(enum stmt_types)' [-Wenum-int-mismatch]
 1915 | const char *obj_type_name(enum stmt_types type)
      |             ^~~~~~~~~~~~~
expression.c:1543:24: warning: conflicting types for 'expr_ops_by_type' due to enum/integer mismatch; have 'const struct expr_ops *(uint32_t)' {aka 'const struct expr_ops *(unsigned int)'} [-Wenum-int-mismatch]
 1543 | const struct expr_ops *expr_ops_by_type(uint32_t value)
      |                        ^~~~~~~~~~~~~~~~

Convert to the stricter type (enum) where possible.

Signed-off-by: Florian Westphal <fw@strlen.de>
include/cache.h
include/rule.h
src/expression.c
src/rule.c

index 5bf78fe0255016838e8b5f69eb0731fc66b728be..934c3a74fa958170e7a1c9e8a371a44ba97bc95a 100644 (file)
@@ -71,7 +71,7 @@ enum cmd_ops;
 int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds,
                       struct list_head *msgs, struct nft_cache_filter *filter,
                       unsigned int *flags);
-int nft_cache_update(struct nft_ctx *ctx, enum cmd_ops cmd,
+int nft_cache_update(struct nft_ctx *ctx, unsigned int flags,
                     struct list_head *msgs,
                     const struct nft_cache_filter *filter);
 bool nft_cache_needs_update(struct nft_cache *cache);
index ef094c90b1c11eace22ccf778ef6a01bf821fabd..fa391529875089959480765243c0647d42e9b1d9 100644 (file)
@@ -519,7 +519,7 @@ struct obj *obj_lookup_fuzzy(const char *obj_name,
 void obj_print(const struct obj *n, struct output_ctx *octx);
 void obj_print_plain(const struct obj *obj, struct output_ctx *octx);
 const char *obj_type_name(uint32_t type);
-uint32_t obj_type_to_cmd(uint32_t type);
+enum cmd_obj obj_type_to_cmd(uint32_t type);
 
 struct flowtable {
        struct list_head        list;
index ce7fef091764ccb13c695cb11a5114116f072876..9b53f43b5267cd2358a554773b2442ce754a419e 100644 (file)
@@ -1540,7 +1540,7 @@ const struct expr_ops *expr_ops(const struct expr *e)
        return __expr_ops_by_type(e->etype);
 }
 
-const struct expr_ops *expr_ops_by_type(uint32_t value)
+const struct expr_ops *expr_ops_by_type(enum expr_types value)
 {
        /* value might come from unreliable source, such as "udata"
         * annotation of set keys.  Avoid BUG() assertion.
index c075d027f9ba5472bf4d4906359613cf55f23881..633a5a12486d067f5cde58ae1c97451abd51f25a 100644 (file)
@@ -1912,7 +1912,7 @@ static const char * const obj_type_name_array[] = {
        [NFT_OBJECT_CT_EXPECT]  = "ct expectation",
 };
 
-const char *obj_type_name(enum stmt_types type)
+const char *obj_type_name(unsigned int type)
 {
        assert(type <= NFT_OBJECT_MAX && obj_type_name_array[type]);
 
@@ -1930,7 +1930,7 @@ static uint32_t obj_type_cmd_array[NFT_OBJECT_MAX + 1] = {
        [NFT_OBJECT_CT_EXPECT]  = CMD_OBJ_CT_EXPECT,
 };
 
-uint32_t obj_type_to_cmd(uint32_t type)
+enum cmd_obj obj_type_to_cmd(uint32_t type)
 {
        assert(type <= NFT_OBJECT_MAX && obj_type_cmd_array[type]);