]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: constify location parameter in cmd_add_loc()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Oct 2020 21:51:16 +0000 (23:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Oct 2020 21:51:47 +0000 (23:51 +0200)
Constify pointer to location object to compile check for unintentional
updates.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/rule.h
src/cmd.c
src/rule.c

index 10e71047fb0731c3eb547b9cbb794e2089129a92..119fc19d79c89dbc8c831a5a843d5a50f6e5f470 100644 (file)
@@ -704,8 +704,8 @@ struct cmd {
                struct obj      *object;
        };
        struct {
-               uint16_t        offset;
-               struct location *location;
+               uint16_t                offset;
+               const struct location   *location;
        } attr[NFT_NLATTR_LOC_MAX];
        int                     num_attrs;
        const void              *arg;
@@ -720,7 +720,7 @@ extern struct cmd *cmd_alloc_obj_ct(enum cmd_ops op, int type,
                                    const struct location *loc, struct obj *obj);
 extern void cmd_free(struct cmd *cmd);
 
-void cmd_add_loc(struct cmd *cmd, uint16_t offset, struct location *loc);
+void cmd_add_loc(struct cmd *cmd, uint16_t offset, const struct location *loc);
 
 #include <payload.h>
 #include <expression.h>
index e0cf3e7716cb0e850ff61e196f07aaaa656f5f44..9cb5b6a3f33d7ac4b5d69cd0a6568854495b290d 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -10,7 +10,7 @@
 #include <string.h>
 
 static int nft_cmd_enoent_table(struct netlink_ctx *ctx, const struct cmd *cmd,
-                               struct location *loc)
+                               const struct location *loc)
 {
        struct table *table;
 
@@ -25,7 +25,7 @@ static int nft_cmd_enoent_table(struct netlink_ctx *ctx, const struct cmd *cmd,
 }
 
 static int nft_cmd_enoent_chain(struct netlink_ctx *ctx, const struct cmd *cmd,
-                               struct location *loc)
+                               const struct location *loc)
 {
        const struct table *table;
        struct chain *chain;
@@ -42,7 +42,7 @@ static int nft_cmd_enoent_chain(struct netlink_ctx *ctx, const struct cmd *cmd,
 }
 
 static int nft_cmd_enoent_rule(struct netlink_ctx *ctx, const struct cmd *cmd,
-                              struct location *loc)
+                              const struct location *loc)
 {
        unsigned int flags = NFT_CACHE_TABLE |
                             NFT_CACHE_CHAIN;
@@ -76,7 +76,7 @@ static int nft_cmd_enoent_rule(struct netlink_ctx *ctx, const struct cmd *cmd,
 }
 
 static int nft_cmd_enoent_set(struct netlink_ctx *ctx, const struct cmd *cmd,
-                             struct location *loc)
+                             const struct location *loc)
 {
        const struct table *table;
        struct set *set;
@@ -95,7 +95,7 @@ static int nft_cmd_enoent_set(struct netlink_ctx *ctx, const struct cmd *cmd,
 }
 
 static int nft_cmd_enoent_obj(struct netlink_ctx *ctx, const struct cmd *cmd,
-                             struct location *loc)
+                             const struct location *loc)
 {
        const struct table *table;
        struct obj *obj;
@@ -112,7 +112,8 @@ static int nft_cmd_enoent_obj(struct netlink_ctx *ctx, const struct cmd *cmd,
 }
 
 static int nft_cmd_enoent_flowtable(struct netlink_ctx *ctx,
-                                   const struct cmd *cmd, struct location *loc)
+                                   const struct cmd *cmd,
+                                   const struct location *loc)
 {
        const struct table *table;
        struct flowtable *ft;
@@ -130,7 +131,7 @@ static int nft_cmd_enoent_flowtable(struct netlink_ctx *ctx,
 }
 
 static void nft_cmd_enoent(struct netlink_ctx *ctx, const struct cmd *cmd,
-                          struct location *loc, int err)
+                          const struct location *loc, int err)
 {
        int ret = 0;
 
@@ -173,7 +174,7 @@ static void nft_cmd_enoent(struct netlink_ctx *ctx, const struct cmd *cmd,
 void nft_cmd_error(struct netlink_ctx *ctx, struct cmd *cmd,
                   struct mnl_err *err)
 {
-       struct location *loc = NULL;
+       const struct location *loc = NULL;
        int i;
 
        for (i = 0; i < cmd->num_attrs; i++) {
index e57009b23c8e749c588bad83e02ab2baa1039bf7..dddfdf5182b09c87ecf55e7e006e44d8c1d278d6 100644 (file)
@@ -1473,7 +1473,7 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj,
        return cmd;
 }
 
-void cmd_add_loc(struct cmd *cmd, uint16_t offset, struct location *loc)
+void cmd_add_loc(struct cmd *cmd, uint16_t offset, const struct location *loc)
 {
        if (cmd->num_attrs > NFT_NLATTR_LOC_MAX)
                return;