summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-08-06 11:36:54 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-08-06 11:42:13 +0200
commitec75831c439ebd3475e0ba6766188d963538129a (patch)
tree399708dbe2dac766c27093c348e792e22d04ddc0
parent99d25746b94b602f7b0f2381b73e0f52d11fca31 (diff)
src: fully constify nft_*_get functions
We have several char * field that were not constify to avoid gcc compilation warnings when calling free. Since (99d2574 src: add xfree and use it), we can fully constify these objects fields without trouble. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/libnftables/chain.h2
-rw-r--r--include/libnftables/set.h2
-rw-r--r--src/chain.c12
-rw-r--r--src/expr/log.c2
-rw-r--r--src/expr_ops.h2
-rw-r--r--src/internal.h4
-rw-r--r--src/set.c2
-rw-r--r--src/table.c2
8 files changed, 14 insertions, 14 deletions
diff --git a/include/libnftables/chain.h b/include/libnftables/chain.h
index 53fd407..e80d007 100644
--- a/include/libnftables/chain.h
+++ b/include/libnftables/chain.h
@@ -35,7 +35,7 @@ void nft_chain_attr_set_s32(struct nft_chain *t, uint16_t attr, int32_t data);
void nft_chain_attr_set_u64(struct nft_chain *t, uint16_t attr, uint64_t data);
void nft_chain_attr_set_str(struct nft_chain *t, uint16_t attr, const char *str);
-void *nft_chain_attr_get(struct nft_chain *c, uint16_t attr);
+const void *nft_chain_attr_get(struct nft_chain *c, uint16_t attr);
const char *nft_chain_attr_get_str(struct nft_chain *c, uint16_t attr);
uint32_t nft_chain_attr_get_u32(struct nft_chain *c, uint16_t attr);
int32_t nft_chain_attr_get_s32(struct nft_chain *c, uint16_t attr);
diff --git a/include/libnftables/set.h b/include/libnftables/set.h
index 4fc3a8d..06380d4 100644
--- a/include/libnftables/set.h
+++ b/include/libnftables/set.h
@@ -26,7 +26,7 @@ void nft_set_attr_set(struct nft_set *s, uint16_t attr, const void *data);
void nft_set_attr_set_u32(struct nft_set *s, uint16_t attr, uint32_t val);
void nft_set_attr_set_str(struct nft_set *s, uint16_t attr, const char *str);
-void *nft_set_attr_get(struct nft_set *s, uint16_t attr);
+const void *nft_set_attr_get(struct nft_set *s, uint16_t attr);
const char *nft_set_attr_get_str(struct nft_set *s, uint16_t attr);
uint32_t nft_set_attr_get_u32(struct nft_set *s, uint16_t attr);
diff --git a/src/chain.c b/src/chain.c
index 1f1760a..0dd3461 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -31,8 +31,8 @@ struct nft_chain {
struct list_head head;
char name[NFT_CHAIN_MAXNAMELEN];
- char *type;
- char *table;
+ const char *type;
+ const char *table;
uint8_t family;
uint32_t policy;
uint32_t hooknum;
@@ -186,7 +186,7 @@ void nft_chain_attr_set_str(struct nft_chain *c, uint16_t attr, const char *str)
}
EXPORT_SYMBOL(nft_chain_attr_set_str);
-void *nft_chain_attr_get(struct nft_chain *c, uint16_t attr)
+const void *nft_chain_attr_get(struct nft_chain *c, uint16_t attr)
{
if (!(c->flags & (1 << attr)))
return NULL;
@@ -227,21 +227,21 @@ EXPORT_SYMBOL(nft_chain_attr_get_str);
uint32_t nft_chain_attr_get_u32(struct nft_chain *c, uint16_t attr)
{
- uint32_t *val = nft_chain_attr_get(c, attr);
+ const uint32_t *val = nft_chain_attr_get(c, attr);
return val ? *val : 0;
}
EXPORT_SYMBOL(nft_chain_attr_get_u32);
int32_t nft_chain_attr_get_s32(struct nft_chain *c, uint16_t attr)
{
- int32_t *val = nft_chain_attr_get(c, attr);
+ const int32_t *val = nft_chain_attr_get(c, attr);
return val ? *val : 0;
}
EXPORT_SYMBOL(nft_chain_attr_get_s32);
uint64_t nft_chain_attr_get_u64(struct nft_chain *c, uint16_t attr)
{
- uint64_t *val = nft_chain_attr_get(c, attr);
+ const uint64_t *val = nft_chain_attr_get(c, attr);
return val ? *val : 0;
}
EXPORT_SYMBOL(nft_chain_attr_get_u64);
diff --git a/src/expr/log.c b/src/expr/log.c
index 5b9b871..10abd68 100644
--- a/src/expr/log.c
+++ b/src/expr/log.c
@@ -26,7 +26,7 @@ struct nft_expr_log {
uint32_t group;
uint32_t snaplen;
uint32_t qthreshold;
- char *prefix;
+ const char *prefix;
};
static int
diff --git a/src/expr_ops.h b/src/expr_ops.h
index 78413fc..a46a309 100644
--- a/src/expr_ops.h
+++ b/src/expr_ops.h
@@ -16,7 +16,7 @@ struct nft_rule_expr;
struct expr_ops {
struct list_head head;
- char *name;
+ const char *name;
size_t alloc_len;
int max_attr;
int (*set)(struct nft_rule_expr *e, uint16_t type, const void *data, size_t data_len);
diff --git a/src/internal.h b/src/internal.h
index 4d39660..8d11acf 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -73,8 +73,8 @@ struct nft_set {
uint32_t family;
uint32_t set_flags;
- char *table;
- char *name;
+ const char *table;
+ const char *name;
uint32_t key_type;
uint32_t key_len;
uint32_t data_type;
diff --git a/src/set.c b/src/set.c
index 6e1be38..6afbc03 100644
--- a/src/set.c
+++ b/src/set.c
@@ -148,7 +148,7 @@ void nft_set_attr_set_str(struct nft_set *s, uint16_t attr, const char *str)
}
EXPORT_SYMBOL(nft_set_attr_set_str);
-void *nft_set_attr_get(struct nft_set *s, uint16_t attr)
+const void *nft_set_attr_get(struct nft_set *s, uint16_t attr)
{
if (!(s->flags & (1 << attr)))
return NULL;
diff --git a/src/table.c b/src/table.c
index 92ad37d..6875dd7 100644
--- a/src/table.c
+++ b/src/table.c
@@ -28,7 +28,7 @@
struct nft_table {
struct list_head head;
- char *name;
+ const char *name;
uint8_t family;
uint32_t table_flags;
uint32_t flags;