All of lore.kernel.org
 help / color / mirror / Atom feed
* [nft PATCH 0/2] Follow-up on nft_print() enhancement
@ 2017-09-29 11:26 Phil Sutter
  2017-09-29 11:26 ` [nft PATCH 1/2] main: Flush output from nft_gmp_print() Phil Sutter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Phil Sutter @ 2017-09-29 11:26 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Eric Leblond, Florian Westphal

This fixes two spots I forgot to clean up before submitting the patches.

Phil Sutter (2):
  main: Flush output from nft_gmp_print()
  main: Drop stdout hack to expose nft_print() implementation issues

 src/main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

-- 
2.13.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [nft PATCH 1/2] main: Flush output from nft_gmp_print()
  2017-09-29 11:26 [nft PATCH 0/2] Follow-up on nft_print() enhancement Phil Sutter
@ 2017-09-29 11:26 ` Phil Sutter
  2017-09-29 11:26 ` [nft PATCH 2/2] main: Drop stdout hack to expose nft_print() implementation issues Phil Sutter
  2017-09-29 11:27 ` [nft PATCH 0/2] Follow-up on nft_print() enhancement Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2017-09-29 11:26 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Eric Leblond, Florian Westphal

This adds a missing call to fflush() to nft_gmp_print() just like in
nft_print(). This is strictly not necessary since usually
nft_gmp_print() is followed by a call to nft_print() but better not rely
upon this assumption.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main.c b/src/main.c
index 079a05b80e511..6d2422ffeccf9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -403,6 +403,7 @@ int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...)
 	va_start(arg, fmt);
 	ret = gmp_vfprintf(octx->output_fp, fmt, arg);
 	va_end(arg);
+	fflush(octx->output_fp);
 
 	return ret;
 }
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [nft PATCH 2/2] main: Drop stdout hack to expose nft_print() implementation issues
  2017-09-29 11:26 [nft PATCH 0/2] Follow-up on nft_print() enhancement Phil Sutter
  2017-09-29 11:26 ` [nft PATCH 1/2] main: Flush output from nft_gmp_print() Phil Sutter
@ 2017-09-29 11:26 ` Phil Sutter
  2017-09-29 11:27 ` [nft PATCH 0/2] Follow-up on nft_print() enhancement Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2017-09-29 11:26 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Eric Leblond, Florian Westphal

This was helpful when testing nft_print() implementation, but breaks
'nft --help' output. Also, with this in place typical printf-debugging
would have to use stderr at all times which is confusing at least.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index 6d2422ffeccf9..fc79cfaa30e0c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -415,11 +415,9 @@ int main(int argc, char * const *argv)
 	bool interactive = false;
 	struct parser_state state;
 	int i, val, rc;
-	FILE *outfp = fdopen(dup(STDOUT_FILENO), "w");
 
 	nft = nft_ctx_new(NFT_CTX_DEFAULT);
-	nft_ctx_set_output(nft, outfp);
-	close(STDOUT_FILENO);
+	nft_ctx_set_output(nft, stdout);
 
 	while (1) {
 		val = getopt_long(argc, argv, OPTSTRING, options, NULL);
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [nft PATCH 0/2] Follow-up on nft_print() enhancement
  2017-09-29 11:26 [nft PATCH 0/2] Follow-up on nft_print() enhancement Phil Sutter
  2017-09-29 11:26 ` [nft PATCH 1/2] main: Flush output from nft_gmp_print() Phil Sutter
  2017-09-29 11:26 ` [nft PATCH 2/2] main: Drop stdout hack to expose nft_print() implementation issues Phil Sutter
@ 2017-09-29 11:27 ` Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-09-29 11:27 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel, Eric Leblond, Florian Westphal

On Fri, Sep 29, 2017 at 01:26:20PM +0200, Phil Sutter wrote:
> This fixes two spots I forgot to clean up before submitting the patches.

Applied, thanks Phil.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-29 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 11:26 [nft PATCH 0/2] Follow-up on nft_print() enhancement Phil Sutter
2017-09-29 11:26 ` [nft PATCH 1/2] main: Flush output from nft_gmp_print() Phil Sutter
2017-09-29 11:26 ` [nft PATCH 2/2] main: Drop stdout hack to expose nft_print() implementation issues Phil Sutter
2017-09-29 11:27 ` [nft PATCH 0/2] Follow-up on nft_print() enhancement Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.