]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: no need to nul-terminate buffer for nftnl_fprintf() calls
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2017 11:58:53 +0000 (13:58 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2017 12:17:24 +0000 (14:17 +0200)
This function bails out with -1 if we cannot print, and this buffer is
internally allocated. No need for this overly deffensive initialization.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/chain.c
src/common.c
src/gen.c
src/object.c
src/rule.c
src/set.c
src/set_elem.c
src/table.c

index 6df871df4131d5c5ecaea8bdb764025bd3fff3c9..5e30a8016cac724ac3f5f3b95d4dcb723d656d9d 100644 (file)
@@ -867,9 +867,6 @@ EXPORT_SYMBOL(nftnl_chain_snprintf);
 static int nftnl_chain_do_snprintf(char *buf, size_t size, const void *c,
                                   uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_chain_snprintf(buf, size, c, type, flags);
 }
 
index ba5a49fc84700166384a8256c376d62ed1342667..a95883c19080843333a6c0a4d129d672bc662d97 100644 (file)
@@ -94,9 +94,6 @@ EXPORT_SYMBOL(nftnl_parse_perror);
 int nftnl_cmd_header_snprintf(char *buf, size_t size, uint32_t cmd, uint32_t type,
                            uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        NFTNL_BUF_INIT(b, buf, size);
 
        if (cmd == NFTNL_CMD_UNSPEC)
@@ -138,9 +135,6 @@ int nftnl_cmd_header_fprintf(FILE *fp, uint32_t cmd, uint32_t type,
 int nftnl_cmd_footer_snprintf(char *buf, size_t size, uint32_t cmd, uint32_t type,
                            uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        NFTNL_BUF_INIT(b, buf, size);
 
        if (cmd == NFTNL_CMD_UNSPEC)
index a03648bba1c2e0ec704556b3a6f74e08edb0aaa6..e42dd4055cb47045f94a9de289bd22fdc8053220 100644 (file)
--- a/src/gen.c
+++ b/src/gen.c
@@ -203,9 +203,6 @@ EXPORT_SYMBOL(nftnl_gen_snprintf);
 static int nftnl_gen_do_snprintf(char *buf, size_t size, const void *gen,
                                 uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf = '\0';
-
        return nftnl_gen_snprintf(buf, size, gen, type, flags);
 }
 
index 8dc83b36c32eaf296bf9f9871fc8350e675ad2ac..f907dd22d13a79e68ae8f02a65238ac388882bfe 100644 (file)
@@ -488,9 +488,6 @@ EXPORT_SYMBOL(nftnl_obj_snprintf);
 static int nftnl_obj_do_snprintf(char *buf, size_t size, const void *obj,
                                 uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_obj_snprintf(buf, size, obj, type, flags);
 }
 
index f37806c0e07b9f679547de8e3172e5395883598f..7cbd15bbd93ce65bbc1b550402ebe12263e98d33 100644 (file)
@@ -836,9 +836,6 @@ EXPORT_SYMBOL(nftnl_rule_snprintf);
 static int nftnl_rule_do_snprintf(char *buf, size_t size, const void *r,
                                  uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_rule_snprintf(buf, size, r, type, flags);
 }
 
index a4e41d2a35475cf9e13bc2e0e4468ee8e79addbe..36e59c38536cb63748484203d819679014967b42 100644 (file)
--- a/src/set.c
+++ b/src/set.c
@@ -939,9 +939,6 @@ EXPORT_SYMBOL(nftnl_set_snprintf);
 static int nftnl_set_do_snprintf(char *buf, size_t size, const void *s,
                                 uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_set_snprintf(buf, size, s, type, flags);
 }
 
index a8f88a4f1813d7a3b5e6f514631f9e0416d34895..a99876a90cac8771e475ab183f89c40df35cd99b 100644 (file)
@@ -738,9 +738,6 @@ static int nftnl_set_elem_do_snprintf(char *buf, size_t size, const void *e,
                                      uint32_t cmd, uint32_t type,
                                      uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_set_elem_snprintf(buf, size, e, type, flags);
 }
 
index 4d8176c9be7802f7988c2e6d780bda1af15fec22..db870cd98437c91741460e5561fff3b115a05780 100644 (file)
@@ -417,9 +417,6 @@ EXPORT_SYMBOL(nftnl_table_snprintf);
 static int nftnl_table_do_snprintf(char *buf, size_t size, const void *t,
                                   uint32_t cmd, uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        return nftnl_table_snprintf(buf, size, t, type, flags);
 }