From e6033f49decf5d1e6e9929cbefb7c099d8766964 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 30 Aug 2013 11:46:29 +0200 Subject: netsniff-ng: Simplify dump file creation logic Instead of using goto, just check stats if stat() returned 0 and used ctx->dump_dir afterwards. This makes the logic a bit easier to follow. Signed-off-by: Tobias Klauser --- netsniff-ng.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'netsniff-ng.c') diff --git a/netsniff-ng.c b/netsniff-ng.c index 331e476..a428996 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -950,23 +950,19 @@ static void recv_only_or_dump(struct ctx *ctx) drop_privileges(ctx->enforce, ctx->uid, ctx->gid); if (dump_to_pcap(ctx)) { - __label__ try_file; struct stat stats; fmemset(&stats, 0, sizeof(stats)); ret = stat(ctx->device_out, &stats); - if (ret < 0) { + if (ret < 0) ctx->dump_dir = 0; - goto try_file; - } + else + ctx->dump_dir = S_ISDIR(stats.st_mode); - ctx->dump_dir = S_ISDIR(stats.st_mode); - if (ctx->dump_dir) { + if (ctx->dump_dir) fd = begin_multi_pcap_file(ctx); - } else { - try_file: + else fd = begin_single_pcap_file(ctx); - } } printf("Running! Hang up with ^C!\n\n"); -- cgit v1.2.3-54-g00ecf