Message ID | 15bbda6958ec01d0088c386537288dcfe1ad8731.1397032579.git.anarey@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 9 April 2014 10:53, Ana Rey <anarey@gmail.com> wrote: > Add an end of line in the exit of ruleset. > > Signed-off-by: Ana Rey <anarey@gmail.com> Hi Ana, Why do you need this here? The policy was to don't add any format stuff (tabs, newlines..) to XML|JSON formats and let the caller add the trailing \n if needed.. However, I see several inconsistencies already in the code: src/rule.c: ret = snprintf(buf+offset, len, "\n"); src/rule.c: ret = snprintf(buf+offset, len, "]\n"); src/rule.c: ret = snprintf(buf+offset, len, " }\n"); src/set.c: ret = snprintf(buf+offset, len, "\n");
2014-04-09 12:11 GMT+02:00 Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>: > On 9 April 2014 10:53, Ana Rey <anarey@gmail.com> wrote: >> Add an end of line in the exit of ruleset. >> >> Signed-off-by: Ana Rey <anarey@gmail.com> > > Hi Ana, > > Why do you need this here? > > The policy was to don't add any format stuff (tabs, newlines..) to > XML|JSON formats and let the caller add the trailing \n if needed.. Thank you for this advise. I'll remember it the next time. I solved this problem in the tests/nft-parsing-test.c (I'll send a new version of "[libnftnl PATCH 2/3] tests: New tools to uptade xml and json testfiles." patch and I deleted it of tihs patchset) Thank you! > > However, I see several inconsistencies already in the code: > src/rule.c: ret = snprintf(buf+offset, len, "\n"); > src/rule.c: ret = snprintf(buf+offset, len, "]\n"); > src/rule.c: ret = snprintf(buf+offset, len, " }\n"); > src/set.c: ret = snprintf(buf+offset, len, "\n"); > > -- > Arturo Borrero González
Please, Fotget this patch. 2014-04-09 10:53 GMT+02:00 Ana Rey <anarey@gmail.com>: > Add an end of line in the exit of ruleset. > > Signed-off-by: Ana Rey <anarey@gmail.com> > --- > src/ruleset.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/ruleset.c b/src/ruleset.c > index 3cbec09..181aeae 100644 > --- a/src/ruleset.c > +++ b/src/ruleset.c > @@ -818,7 +818,7 @@ nft_ruleset_do_snprintf(char *buf, size_t size, const struct nft_ruleset *rs, > SNPRINTF_BUFFER_SIZE(ret, size, len, offset); > } > > - ret = snprintf(buf+offset, size, "%s", nft_ruleset_o_closetag(type)); > + ret = snprintf(buf+offset, size, "%s\n", nft_ruleset_o_closetag(type)); > SNPRINTF_BUFFER_SIZE(ret, size, len, offset); > > return offset; > -- > 1.9.0 >
diff --git a/src/ruleset.c b/src/ruleset.c index 3cbec09..181aeae 100644 --- a/src/ruleset.c +++ b/src/ruleset.c @@ -818,7 +818,7 @@ nft_ruleset_do_snprintf(char *buf, size_t size, const struct nft_ruleset *rs, SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - ret = snprintf(buf+offset, size, "%s", nft_ruleset_o_closetag(type)); + ret = snprintf(buf+offset, size, "%s\n", nft_ruleset_o_closetag(type)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); return offset;
Add an end of line in the exit of ruleset. Signed-off-by: Ana Rey <anarey@gmail.com> --- src/ruleset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)