summaryrefslogtreecommitdiff
path: root/netsniff-ng.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-08-30 11:46:29 +0200
committerTobias Klauser <tklauser@distanz.ch>2013-08-30 11:46:29 +0200
commite6033f49decf5d1e6e9929cbefb7c099d8766964 (patch)
tree5f2dfd10889a8bc30f84eb8c106aa6037e7900f7 /netsniff-ng.c
parent5e67d9ebf4cfb76f359ea25ad425de81f80700cc (diff)
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 <tklauser@distanz.ch>
Diffstat (limited to 'netsniff-ng.c')
-rw-r--r--netsniff-ng.c14
1 files changed, 5 insertions, 9 deletions
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");