]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: do not nul-terminate internal helper functions
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2017 12:11:43 +0000 (14:11 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2017 12:21:42 +0000 (14:21 +0200)
Public API already does this for us, no need to do this again from
internal helper functions.

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

index 5e30a8016cac724ac3f5f3b95d4dcb723d656d9d..a11bcf5cba03ea6181841eb2a34c2219b2f45fcb 100644 (file)
@@ -827,9 +827,6 @@ static int nftnl_chain_cmd_snprintf(char *buf, size_t size,
 {
        int ret, remain = size, offset = 0;
 
-       if (size)
-               buf[0] = '\0';
-
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
index c925e2013c2fda7371386c37d0912643a435e278..a246952f7f01be4147582c273ca4aa2ca6eb0b95 100644 (file)
@@ -194,9 +194,6 @@ int nftnl_data_reg_snprintf(char *buf, size_t size,
                            uint32_t output_format, uint32_t flags,
                            int reg_type)
 {
-       if (size)
-               buf[0] = '\0';
-
        switch(reg_type) {
        case DATA_VALUE:
                switch(output_format) {
index e42dd4055cb47045f94a9de289bd22fdc8053220..58b3a96dbdcb933e4facad08b02a71f80c96d0aa 100644 (file)
--- a/src/gen.c
+++ b/src/gen.c
@@ -168,9 +168,6 @@ static int nftnl_gen_cmd_snprintf(char *buf, size_t size,
 {
        int ret, remain = size, offset = 0;
 
-       if (size)
-               buf[0] = '\0';
-
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
index f907dd22d13a79e68ae8f02a65238ac388882bfe..9a4ee712a2a95e8ab5a59131136ded1aa8dd8f1e 100644 (file)
@@ -448,9 +448,6 @@ static int nftnl_obj_cmd_snprintf(char *buf, size_t size,
 {
        int ret, remain = size, offset = 0;
 
-       if (size)
-               buf[0] = '\0';
-
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
index 7cbd15bbd93ce65bbc1b550402ebe12263e98d33..a9e9870cbea9571f68d1b501b9346c4a8d3b3029 100644 (file)
@@ -792,9 +792,6 @@ static int nftnl_rule_cmd_snprintf(char *buf, size_t size,
        int ret, remain = size, offset = 0;
        uint32_t inner_flags = flags;
 
-       if (size)
-               buf[0] = '\0';
-
        inner_flags &= ~NFTNL_OF_EVENT_ANY;
 
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
index cc43866c13bce825f0a02f096870c357abd107c5..3de9b87283292ae5afc8dd17aa0247564ac661ab 100644 (file)
@@ -846,9 +846,6 @@ nftnl_ruleset_do_snprintf(char *buf, size_t size, const struct nftnl_ruleset *rs
        void *prev = NULL;
        uint32_t inner_flags = flags;
 
-       if (size)
-               buf[0] = '\0';
-
        /* dont pass events flags to child calls of _snprintf() */
        inner_flags &= ~NFTNL_OF_EVENT_ANY;
 
@@ -922,9 +919,6 @@ static int nftnl_ruleset_cmd_snprintf(char *buf, size_t size,
                                    const struct nftnl_ruleset *r, uint32_t cmd,
                                    uint32_t type, uint32_t flags)
 {
-       if (size)
-               buf[0] = '\0';
-
        switch (type) {
        case NFTNL_OUTPUT_DEFAULT:
        case NFTNL_OUTPUT_JSON:
index 36e59c38536cb63748484203d819679014967b42..592ea246b05e5695a45ab2877204c1773885272d 100644 (file)
--- a/src/set.c
+++ b/src/set.c
@@ -895,9 +895,6 @@ static int nftnl_set_cmd_snprintf(char *buf, size_t size,
        if (type == NFTNL_OUTPUT_XML)
                return 0;
 
-       if (size)
-               buf[0] = '\0';
-
        /* prevent set_elems to print as events */
        inner_flags &= ~NFTNL_OF_EVENT_ANY;
 
index a99876a90cac8771e475ab183f89c40df35cd99b..e45dbc6bfe3e419fdedae2bea68e769a30a14cd9 100644 (file)
@@ -696,8 +696,6 @@ static int nftnl_set_elem_cmd_snprintf(char *buf, size_t size,
 
        if (type == NFTNL_OUTPUT_XML)
                return 0;
-       if (size)
-               buf[0] = '\0';
 
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
index db870cd98437c91741460e5561fff3b115a05780..cf61ddaad3a68112ed7e0a510a797f1f13444ad3 100644 (file)
@@ -378,9 +378,6 @@ static int nftnl_table_cmd_snprintf(char *buf, size_t size,
 {
        int ret, remain = size, offset = 0;
 
-       if (size)
-               buf[0] = '\0';
-
        ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);