summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-02-12 17:36:31 -0500
committerTavian Barnes <tavianator@tavianator.com>2019-03-06 22:28:25 -0800
commit7fc960a23eab7fce9f5e0666b1a9b3f5eae832af (patch)
tree440adf2f92ab6e7dbd0540afab05b6e4c0d6810f /eval.c
parentb1d0e0e97ce747534a945a6fe0c3a15ccd8dbf00 (diff)
downloadbfs-7fc960a23eab7fce9f5e0666b1a9b3f5eae832af.tar.xz
bftw: Switch from taking separate parameters to a parameters struct
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 53eacf8..028b31d 100644
--- a/eval.c
+++ b/eval.c
@@ -1383,8 +1383,6 @@ int eval_cmdline(const struct cmdline *cmdline) {
return EXIT_SUCCESS;
}
- int nopenfd = infer_fdlimit(cmdline);
-
struct callback_args args = {
.cmdline = cmdline,
.ret = EXIT_SUCCESS,
@@ -1397,14 +1395,28 @@ int eval_cmdline(const struct cmdline *cmdline) {
args.seen = &seen;
}
+ struct bftw_args bftw_args = {
+ .callback = cmdline_callback,
+ .ptr = &args,
+ .nopenfd = infer_fdlimit(cmdline),
+ .flags = cmdline->flags,
+ };
+
for (struct root *root = cmdline->roots; root && !args.quit; root = root->next) {
if (cmdline->debug & DEBUG_SEARCH) {
- fprintf(stderr, "bftw(\"%s\", cmdline_callback, %d, ", root->path, nopenfd);
- dump_bftw_flags(cmdline->flags);
- fprintf(stderr, ", &args)\n");
+ fprintf(stderr,
+ "bftw(\"%s\", { "
+ ".callback = cmdline_callback, "
+ ".ptr = &args, "
+ ".nopenfd = %d, "
+ ".flags = ",
+ root->path,
+ bftw_args.nopenfd);
+ dump_bftw_flags(bftw_args.flags);
+ fprintf(stderr, " })\n");
}
- if (bftw(root->path, cmdline_callback, nopenfd, cmdline->flags, &args) != 0) {
+ if (bftw(root->path, &bftw_args) != 0) {
args.ret = EXIT_FAILURE;
perror("bftw()");
}