From e6dec3a203d017319a637d8a8b048879da158538 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Fri, 1 Jun 2018 20:10:09 +0200 Subject: [PATCH] iptables plugin: fix implicit conversion warnings CC src/iptables_la-iptables.lo src/iptables.c:139:29: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] table_len = strlen(table) + 1; ~ ~~~~~~~~~~~~~~^~~ src/iptables.c:147:29: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] chain_len = strlen(chain) + 1; ~ ~~~~~~~~~~~~~~^~~ 2 warnings generated. --- src/iptables.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/iptables.c b/src/iptables.c index 8fad588e..225ed2c1 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -103,9 +103,7 @@ static int iptables_config(const char *key, const char *value) { ip_chain_t temp = {0}; ip_chain_t *final, **list; char *table; - int table_len; char *chain; - int chain_len; char *value_copy; char *fields[4]; @@ -136,16 +134,16 @@ static int iptables_config(const char *key, const char *value) { table = fields[0]; chain = fields[1]; - table_len = strlen(table) + 1; - if ((unsigned int)table_len > sizeof(temp.table)) { + size_t table_len = strlen(table) + 1; + if (table_len > sizeof(temp.table)) { ERROR("Table `%s' too long.", table); free(value_copy); return 1; } sstrncpy(temp.table, table, table_len); - chain_len = strlen(chain) + 1; - if ((unsigned int)chain_len > sizeof(temp.chain)) { + size_t chain_len = strlen(chain) + 1; + if (chain_len > sizeof(temp.chain)) { ERROR("Chain `%s' too long.", chain); free(value_copy); return 1; -- 2.11.0