]> Sergey Matveev's repositories - bfs.git/commitdiff
Formatting fixes
authorTavian Barnes <tavianator@tavianator.com>
Wed, 27 Sep 2023 16:11:15 +0000 (12:11 -0400)
committerTavian Barnes <tavianator@tavianator.com>
Wed, 27 Sep 2023 16:12:46 +0000 (12:12 -0400)
25 files changed:
src/color.c
src/ctx.c
src/darray.c
src/diag.c
src/diag.h
src/dstring.c
src/eval.c
src/exec.c
src/fsade.c
src/ioq.c
src/opt.c
src/opt.h
src/parse.c
src/printf.c
src/pwcache.c
src/stat.c
src/trie.c
src/trie.h
src/xregex.c
src/xspawn.c
src/xtime.c
tests/bfstd.c
tests/mksock.c
tests/trie.c
tests/xtimegm.c

index 8d0b9950b53c2518106a7ed6a6d531244e5a856f..788d35d3c2d8fe1b609ad21d6e4f15a4a59e5efe 100644 (file)
@@ -1143,11 +1143,11 @@ static int print_expr(CFILE *cfile, const struct bfs_expr *expr, bool verbose) {
        if (verbose) {
                double rate = 0.0, time = 0.0;
                if (expr->evaluations) {
-                       rate = 100.0*expr->successes/expr->evaluations;
-                       time = (1.0e9*expr->elapsed.tv_sec + expr->elapsed.tv_nsec)/expr->evaluations;
+                       rate = 100.0 * expr->successes / expr->evaluations;
+                       time = (1.0e9 * expr->elapsed.tv_sec + expr->elapsed.tv_nsec) / expr->evaluations;
                }
                if (cbuff(cfile, " [${ylw}%zu${rs}/${ylw}%zu${rs}=${ylw}%g%%${rs}; ${ylw}%gns${rs}]",
-                         expr->successes, expr->evaluations, rate, time)) {
+                           expr->successes, expr->evaluations, rate, time)) {
                        return -1;
                }
        }
index 3a44e68a03481f7f738bf00905930861e7a42b21..9a24a33fff2735421ad7c9d0b9381c3dbbc169a7 100644 (file)
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -168,7 +168,6 @@ void bfs_ctx_flush(const struct bfs_ctx *ctx) {
                } else if (cfile == ctx->cout) {
                        bfs_error(ctx, "(standard output): %m.\n");
                }
-
        }
 
        // Flush the user/group caches, in case the executed command edits the
index 42b83976084a7a775bf23bfeefdb753b4d76b6cc..3e66a555ed3e7d48bd4c82b6eadcacbb7d9b603a 100644 (file)
@@ -55,7 +55,7 @@ void *darray_push(void *da, const void *item, size_t size) {
        size_t i = header->length++;
        if (i >= capacity) {
                capacity *= 2;
-               header = realloc(header, sizeof(*header) + capacity*size);
+               header = realloc(header, sizeof(*header) + capacity * size);
                if (!header) {
                        // This failure will be detected by darray_check()
                        return da;
@@ -64,7 +64,7 @@ void *darray_push(void *da, const void *item, size_t size) {
        }
 
        char *data = darray_data(header);
-       memcpy(data + i*size, item, size);
+       memcpy(data + i * size, item, size);
        return data;
 }
 
index fa9db397938411d2d8358cb0820426b87a862c1a..fa6652535779f9ad9768791413071c9935ca5b83 100644 (file)
@@ -4,9 +4,9 @@
 #include "diag.h"
 #include "alloc.h"
 #include "bfstd.h"
-#include "ctx.h"
 #include "color.h"
 #include "config.h"
+#include "ctx.h"
 #include "dstring.h"
 #include "expr.h"
 #include <errno.h>
@@ -31,14 +31,14 @@ void bfs_perror(const struct bfs_ctx *ctx, const char *str) {
        bfs_error(ctx, "%s: %m.\n", str);
 }
 
-void bfs_error(const struct bfs_ctx *ctx, const char *format, ...)  {
+void bfs_error(const struct bfs_ctx *ctx, const char *format, ...) {
        va_list args;
        va_start(args, format);
        bfs_verror(ctx, format, args);
        va_end(args);
 }
 
-bool bfs_warning(const struct bfs_ctx *ctx, const char *format, ...)  {
+bool bfs_warning(const struct bfs_ctx *ctx, const char *format, ...) {
        va_list args;
        va_start(args, format);
        bool ret = bfs_vwarning(ctx, format, args);
@@ -46,7 +46,7 @@ bool bfs_warning(const struct bfs_ctx *ctx, const char *format, ...)  {
        return ret;
 }
 
-bool bfs_debug(const struct bfs_ctx *ctx, enum debug_flags flag, const char *format, ...)  {
+bool bfs_debug(const struct bfs_ctx *ctx, enum debug_flags flag, const char *format, ...) {
        va_list args;
        va_start(args, format);
        bool ret = bfs_vdebug(ctx, flag, format, args);
index e019db06ea71aa66be101735aebc7d1dd1ea1ae1..fea8847b13952d6fe61215906680707c1bc5efb7 100644 (file)
@@ -8,8 +8,8 @@
 #ifndef BFS_DIAG_H
 #define BFS_DIAG_H
 
-#include "ctx.h"
 #include "config.h"
+#include "ctx.h"
 #include <stdarg.h>
 
 /**
index ef4e733323fdbc48de27212711ee0b27b10ce30e..f94774126b5140992b1b81589ca1b1327eb5ee11 100644 (file)
@@ -169,7 +169,7 @@ char *dstrprintf(const char *format, ...) {
 
 char *dstrvprintf(const char *format, va_list args) {
        // Guess a capacity to try to avoid reallocating
-       dchar *str = dstralloc(2*strlen(format));
+       dchar *str = dstralloc(2 * strlen(format));
        if (!str) {
                return NULL;
        }
@@ -195,7 +195,7 @@ int dstrcatf(dchar **str, const char *format, ...) {
 int dstrvcatf(dchar **str, const char *format, va_list args) {
        // Guess a capacity to try to avoid calling vsnprintf() twice
        size_t len = dstrlen(*str);
-       dstreserve(str, len + 2*strlen(format));
+       dstreserve(str, len + 2 * strlen(format));
        size_t cap = dstrheader(*str)->capacity;
 
        va_list copy;
index 35507510d2191eff3754fe9a2c574cc3742a6657..9f4896a53e9e498989a90d7cbdcc5a7d7ef07d74 100644 (file)
@@ -239,7 +239,7 @@ bool eval_time(const struct bfs_expr *expr, struct bfs_eval *state) {
        time_t diff = timespec_diff(&expr->reftime, time);
        switch (expr->time_unit) {
        case BFS_DAYS:
-               diff /= 60*24;
+               diff /= 60 * 24;
                fallthru;
        case BFS_MINUTES:
                diff /= 60;
@@ -271,7 +271,7 @@ bool eval_used(const struct bfs_expr *expr, struct bfs_eval *state) {
                return false;
        }
 
-       long long day_seconds = 60*60*24;
+       long long day_seconds = 60 * 60 * 24;
        diff = (diff + day_seconds - 1) / day_seconds;
        return bfs_expr_cmp(expr, diff);
 }
@@ -685,7 +685,7 @@ bool eval_fls(const struct bfs_expr *expr, struct bfs_eval *state) {
 
        uintmax_t ino = statbuf->ino;
        uintmax_t block_size = ctx->posixly_correct ? 512 : 1024;
-       uintmax_t blocks = ((uintmax_t)statbuf->blocks*BFS_STAT_BLKSIZE + block_size - 1)/block_size;
+       uintmax_t blocks = ((uintmax_t)statbuf->blocks * BFS_STAT_BLKSIZE + block_size - 1) / block_size;
        char mode[11];
        xstrmode(statbuf->mode, mode);
        char acl = bfs_check_acl(ftwbuf) > 0 ? '+' : ' ';
@@ -721,8 +721,8 @@ bool eval_fls(const struct bfs_expr *expr, struct bfs_eval *state) {
 
        time_t time = statbuf->mtime.tv_sec;
        time_t now = ctx->now.tv_sec;
-       time_t six_months_ago = now - 6*30*24*60*60;
-       time_t tomorrow = now + 24*60*60;
+       time_t six_months_ago = now - 6 * 30 * 24 * 60 * 60;
+       time_t tomorrow = now + 24 * 60 * 60;
        struct tm tm;
        if (xlocaltime(&time, &tm) != 0) {
                goto error;
@@ -823,7 +823,6 @@ bool eval_fprintx(const struct bfs_expr *expr, struct bfs_eval *state) {
                ++path;
        }
 
-
        if (fputc('\n', file) == EOF) {
                goto error;
        }
@@ -905,7 +904,7 @@ bool eval_size(const struct bfs_expr *expr, struct bfs_eval *state) {
        };
 
        off_t scale = scales[expr->size_unit];
-       off_t size = (statbuf->size + scale - 1)/scale; // Round up
+       off_t size = (statbuf->size + scale - 1) / scale; // Round up
        return bfs_expr_cmp(expr, size);
 }
 
@@ -918,7 +917,7 @@ bool eval_sparse(const struct bfs_expr *expr, struct bfs_eval *state) {
                return false;
        }
 
-       blkcnt_t expected = (statbuf->size + BFS_STAT_BLKSIZE - 1)/BFS_STAT_BLKSIZE;
+       blkcnt_t expected = (statbuf->size + BFS_STAT_BLKSIZE - 1) / BFS_STAT_BLKSIZE;
        return statbuf->blocks < expected;
 }
 
index 7b55522b8e5f9623be446f5e1a9b1dfc891deb36..0e0d5850f228841eda564fec0b7e61407a32161d 100644 (file)
@@ -5,9 +5,9 @@
 #include "alloc.h"
 #include "bfstd.h"
 #include "bftw.h"
-#include "ctx.h"
 #include "color.h"
 #include "config.h"
+#include "ctx.h"
 #include "diag.h"
 #include "dstring.h"
 #include "xspawn.h"
@@ -348,7 +348,7 @@ static int bfs_exec_spawn(const struct bfs_exec *execbuf) {
 
        if (execbuf->flags & BFS_EXEC_MULTI) {
                bfs_exec_debug(execbuf, "Executing '%s' ... [%zu arguments] (size %zu)\n",
-                              execbuf->argv[0], execbuf->argc - 1, execbuf->arg_size);
+                       execbuf->argv[0], execbuf->argc - 1, execbuf->arg_size);
        } else {
                bfs_exec_debug(execbuf, "Executing '%s' ... [%zu arguments]\n", execbuf->argv[0], execbuf->argc - 1);
        }
@@ -471,7 +471,7 @@ static bool bfs_exec_args_remain(const struct bfs_exec *execbuf) {
 static size_t bfs_exec_estimate_max(const struct bfs_exec *execbuf) {
        size_t min = execbuf->arg_min;
        size_t max = execbuf->arg_max;
-       return min + (max - min)/2;
+       return min + (max - min) / 2;
 }
 
 /** Update the ARG_MAX lower bound from a successful execution. */
@@ -486,7 +486,7 @@ static void bfs_exec_update_min(struct bfs_exec *execbuf) {
 
                size_t estimate = bfs_exec_estimate_max(execbuf);
                bfs_exec_debug(execbuf, "ARG_MAX between [%zu, %zu], trying %zu\n",
-                              execbuf->arg_min, execbuf->arg_max, estimate);
+                       execbuf->arg_min, execbuf->arg_max, estimate);
        }
 }
 
@@ -502,7 +502,7 @@ static size_t bfs_exec_update_max(struct bfs_exec *execbuf) {
 
        // Trim a fraction off the max size to avoid repeated failures near the
        // top end of the working range
-       size -= size/16;
+       size -= size / 16;
        if (size < execbuf->arg_max) {
                execbuf->arg_max = size;
 
@@ -515,7 +515,7 @@ static size_t bfs_exec_update_max(struct bfs_exec *execbuf) {
        // Binary search for a more precise bound
        size_t estimate = bfs_exec_estimate_max(execbuf);
        bfs_exec_debug(execbuf, "ARG_MAX between [%zu, %zu], trying %zu\n",
-                      execbuf->arg_min, execbuf->arg_max, estimate);
+               execbuf->arg_min, execbuf->arg_max, estimate);
        return estimate;
 }
 
@@ -589,7 +589,7 @@ static bool bfs_exec_would_overflow(const struct bfs_exec *execbuf, const char *
        size_t next_size = execbuf->arg_size + bfs_exec_arg_size(arg);
        if (next_size > arg_max) {
                bfs_exec_debug(execbuf, "Command size (%zu) would exceed maximum (%zu), executing buffered command\n",
-                              next_size, arg_max);
+                       next_size, arg_max);
                return true;
        }
 
@@ -601,7 +601,7 @@ static int bfs_exec_push(struct bfs_exec *execbuf, char *arg) {
        execbuf->argv[execbuf->argc] = arg;
 
        if (execbuf->argc + 1 >= execbuf->argv_cap) {
-               size_t cap = 2*execbuf->argv_cap;
+               size_t cap = 2 * execbuf->argv_cap;
                char **argv = realloc(execbuf->argv, sizeof_array(char *, cap));
                if (!argv) {
                        return -1;
index 8dec5a8951e25a9fed9093f65766571f02db83a8..cbff47b3b24b23f1c40ae69a1815192a8f077213 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "fsade.h"
 #include "atomic.h"
-#include "config.h"
 #include "bfstd.h"
 #include "bftw.h"
+#include "config.h"
 #include "dir.h"
 #include "dstring.h"
 #include "sanity.h"
@@ -292,7 +292,7 @@ int bfs_check_xattrs(const struct BFTW *ftwbuf) {
        ssize_t len;
 
 #if BFS_USE_SYS_EXTATTR_H
-       ssize_t (*extattr_list)(const char *, int, void*, size_t) =
+       ssize_t (*extattr_list)(const char *, int, void *, size_t) =
                ftwbuf->type == BFS_LNK ? extattr_list_link : extattr_list_file;
 
        len = extattr_list(path, EXTATTR_NAMESPACE_SYSTEM, NULL, 0);
@@ -331,7 +331,7 @@ int bfs_check_xattr_named(const struct BFTW *ftwbuf, const char *name) {
        ssize_t len;
 
 #if BFS_USE_SYS_EXTATTR_H
-       ssize_t (*extattr_get)(const char *, int, const char *, void*, size_t) =
+       ssize_t (*extattr_get)(const char *, int, const char *, void *, size_t) =
                ftwbuf->type == BFS_LNK ? extattr_get_link : extattr_get_file;
 
        len = extattr_get(path, EXTATTR_NAMESPACE_SYSTEM, name, NULL, 0);
index f7ca8c6d772fb0b35c02fd559fc78c32d532dfbe..d3ba2dee0e23a7f3dc7be466147bbb2a01a778a0 100644 (file)
--- a/src/ioq.c
+++ b/src/ioq.c
@@ -9,8 +9,8 @@
 #include "config.h"
 #include "diag.h"
 #include "dir.h"
-#include "thread.h"
 #include "sanity.h"
+#include "thread.h"
 #include <assert.h>
 #include <errno.h>
 #include <pthread.h>
index 14de081d0c42fea8a4920aed46477a01ddb72509..77c2798a5767c0d6ed563254478166bccb151f4a 100644 (file)
--- a/src/opt.c
+++ b/src/opt.c
@@ -535,8 +535,8 @@ static struct bfs_expr *optimize_and_expr(const struct opt_state *state, struct
        expr->pure = lhs->pure && rhs->pure;
        expr->always_true = lhs->always_true && rhs->always_true;
        expr->always_false = lhs->always_false || rhs->always_false;
-       expr->cost = lhs->cost + lhs->probability*rhs->cost;
-       expr->probability = lhs->probability*rhs->probability;
+       expr->cost = lhs->cost + lhs->probability * rhs->cost;
+       expr->probability = lhs->probability * rhs->probability;
 
        return expr;
 }
@@ -606,8 +606,8 @@ static struct bfs_expr *optimize_or_expr(const struct opt_state *state, struct b
        expr->pure = lhs->pure && rhs->pure;
        expr->always_true = lhs->always_true || rhs->always_true;
        expr->always_false = lhs->always_false && rhs->always_false;
-       expr->cost = lhs->cost + (1 - lhs->probability)*rhs->cost;
-       expr->probability = lhs->probability + rhs->probability - lhs->probability*rhs->probability;
+       expr->cost = lhs->cost + (1 - lhs->probability) * rhs->cost;
+       expr->probability = lhs->probability + rhs->probability - lhs->probability * rhs->probability;
 
        return expr;
 }
@@ -1078,7 +1078,6 @@ static const struct {
        {eval_xattrname, 0.01},
 };
 
-
 /**
  * Table of simple predicates.
  */
@@ -1331,7 +1330,7 @@ static bool reorder_expr_recursive(const struct opt_state *state, struct bfs_exp
        if (expr->eval_fn == eval_and || expr->eval_fn == eval_or) {
                if (lhs->pure && rhs->pure) {
                        float rhs_prob = expr->eval_fn == eval_and ? rhs->probability : 1.0 - rhs->probability;
-                       float swapped_cost = rhs->cost + rhs_prob*lhs->cost;
+                       float swapped_cost = rhs->cost + rhs_prob * lhs->cost;
                        ret |= reorder_expr(state, expr, swapped_cost);
                }
        }
index 28cadb95d4975432a4b3042f7d6dae36f843e1d2..4aac1299dffcddaa83ba3324318c3ea1808b18f9 100644 (file)
--- a/src/opt.h
+++ b/src/opt.h
@@ -21,4 +21,3 @@ struct bfs_ctx;
 int bfs_optimize(struct bfs_ctx *ctx);
 
 #endif // BFS_OPT_H
-
index 3416d9eaa93ecadde054cad863c2ac44aa2885ad..7766a7b8ae89ae5f362ca1a9fdc8d229f9b1cd93 100644 (file)
@@ -41,8 +41,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/time.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <sys/wait.h>
 #include <time.h>
 #include <unistd.h>
@@ -1797,10 +1797,10 @@ static int parse_reftime(const struct parser_state *state, struct bfs_expr *expr
 #else
        int gmtoff = -timezone;
 #endif
-       int tz_hour = gmtoff/3600;
-       int tz_min = (labs(gmtoff)/60)%60;
+       int tz_hour = gmtoff / 3600;
+       int tz_min = (labs(gmtoff) / 60) % 60;
        fprintf(stderr, "  - %04d-%02d-%02dT%02d:%02d:%02d%+03d:%02d\n",
-               year, month, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tz_hour, tz_min);
+               year, month, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tz_hour, tz_min);
 
        if (xgmtime(&state->now.tv_sec, &tm) != 0) {
                parse_perror(state, "xgmtime()");
@@ -1832,8 +1832,8 @@ static struct bfs_expr *parse_newerxy(struct parser_state *state, int arg1, int
        expr->stat_field = parse_newerxy_field(arg[6]);
        if (!expr->stat_field) {
                parse_expr_error(state, expr,
-                                "For ${blu}-newer${bld}XY${rs}, ${bld}X${rs} should be ${bld}a${rs}, ${bld}c${rs}, ${bld}m${rs}, or ${bld}B${rs}, not ${err}%c${rs}.\n",
-                                arg[6]);
+                       "For ${blu}-newer${bld}XY${rs}, ${bld}X${rs} should be ${bld}a${rs}, ${bld}c${rs}, ${bld}m${rs}, or ${bld}B${rs}, not ${err}%c${rs}.\n",
+                       arg[6]);
                goto fail;
        }
 
@@ -1845,8 +1845,8 @@ static struct bfs_expr *parse_newerxy(struct parser_state *state, int arg1, int
                enum bfs_stat_field field = parse_newerxy_field(arg[7]);
                if (!field) {
                        parse_expr_error(state, expr,
-                                        "For ${blu}-newer${bld}XY${rs}, ${bld}Y${rs} should be ${bld}a${rs}, ${bld}c${rs}, ${bld}m${rs}, ${bld}B${rs}, or ${bld}t${rs}, not ${err}%c${rs}.\n",
-                                        arg[7]);
+                               "For ${blu}-newer${bld}XY${rs}, ${bld}Y${rs} should be ${bld}a${rs}, ${bld}c${rs}, ${bld}m${rs}, ${bld}B${rs}, or ${bld}t${rs}, not ${err}%c${rs}.\n",
+                               arg[7]);
                        goto fail;
                }
 
@@ -1855,7 +1855,6 @@ static struct bfs_expr *parse_newerxy(struct parser_state *state, int arg1, int
                        goto fail;
                }
 
-
                const struct timespec *reftime = bfs_stat_time(&sb, field);
                if (!reftime) {
                        parse_expr_error(state, expr, "Couldn't get file %s.\n", bfs_stat_field_name(field));
@@ -1905,7 +1904,7 @@ static struct bfs_expr *parse_nohidden(struct parser_state *state, int arg1, int
  */
 static struct bfs_expr *parse_noleaf(struct parser_state *state, int arg1, int arg2) {
        parse_warning(state, "${ex}%s${rs} does not apply the optimization that ${blu}%s${rs} inhibits.\n\n",
-                     BFS_COMMAND, state->argv[0]);
+               BFS_COMMAND, state->argv[0]);
        return parse_nullary_option(state);
 }
 
@@ -2730,12 +2729,12 @@ static struct bfs_expr *parse_help(struct parser_state *state, int arg1, int arg
        }
 
        cfprintf(cout, "Usage: ${ex}%s${rs} [${cyn}flags${rs}...] [${mag}paths${rs}...] [${blu}expression${rs}...]\n\n",
-                state->command);
+               state->command);
 
        cfprintf(cout, "${ex}%s${rs} is compatible with ${ex}find${rs}, with some extensions. "
-                      "${cyn}Flags${rs} (${cyn}-H${rs}/${cyn}-L${rs}/${cyn}-P${rs} etc.), ${mag}paths${rs},\n"
-                      "and ${blu}expressions${rs} may be freely mixed in any order.\n\n",
-                BFS_COMMAND);
+                      "${cyn}Flags${rs} (${cyn}-H${rs}/${cyn}-L${rs}/${cyn}-P${rs} etc.), ${mag}paths${rs},\n"
+                      "and ${blu}expressions${rs} may be freely mixed in any order.\n\n",
+               BFS_COMMAND);
 
        cfprintf(cout, "${bld}Flags:${rs}\n\n");
 
@@ -2807,7 +2806,7 @@ static struct bfs_expr *parse_help(struct parser_state *state, int arg1, int arg
        cfprintf(cout, "  ${blu}-ignore_readdir_race${rs}\n");
        cfprintf(cout, "  ${blu}-noignore_readdir_race${rs}\n");
        cfprintf(cout, "      Whether to report an error if ${ex}%s${rs} detects that the file tree is modified\n",
-                BFS_COMMAND);
+               BFS_COMMAND);
        cfprintf(cout, "      during the search (default: ${blu}-noignore_readdir_race${rs})\n");
        cfprintf(cout, "  ${blu}-maxdepth${rs} ${bld}N${rs}\n");
        cfprintf(cout, "  ${blu}-mindepth${rs} ${bld}N${rs}\n");
@@ -3462,14 +3461,14 @@ static struct bfs_expr *parse_whole_expr(struct parser_state *state) {
 
        if (state->mount_arg && state->xdev_arg) {
                parse_conflict_warning(state, state->mount_arg, 1, state->xdev_arg, 1,
-                                      "${blu}%s${rs} is redundant in the presence of ${blu}%s${rs}.\n\n",
-                                      state->xdev_arg[0], state->mount_arg[0]);
+                       "${blu}%s${rs} is redundant in the presence of ${blu}%s${rs}.\n\n",
+                       state->xdev_arg[0], state->mount_arg[0]);
        }
 
        if (state->ctx->warn && state->depth_arg && state->prune_arg) {
                parse_conflict_warning(state, state->depth_arg, 1, state->prune_arg, 1,
-                                      "${blu}%s${rs} does not work in the presence of ${blu}%s${rs}.\n",
-                                      state->prune_arg[0], state->depth_arg[0]);
+                       "${blu}%s${rs} does not work in the presence of ${blu}%s${rs}.\n",
+                       state->prune_arg[0], state->depth_arg[0]);
 
                if (state->interactive) {
                        bfs_warning(state->ctx, "Do you want to continue? ");
@@ -3483,8 +3482,8 @@ static struct bfs_expr *parse_whole_expr(struct parser_state *state) {
 
        if (state->ok_expr && state->files0_stdin_arg) {
                parse_conflict_error(state, state->ok_expr->argv, state->ok_expr->argc, state->files0_stdin_arg, 2,
-                                    "${blu}%s${rs} conflicts with ${blu}%s${rs} ${bld}%s${rs}.\n",
-                                    state->ok_expr->argv[0], state->files0_stdin_arg[0], state->files0_stdin_arg[1]);
+                       "${blu}%s${rs} conflicts with ${blu}%s${rs} ${bld}%s${rs}.\n",
+                       state->ok_expr->argv[0], state->files0_stdin_arg[0], state->files0_stdin_arg[1]);
                goto fail;
        }
 
@@ -3644,7 +3643,7 @@ void bfs_ctx_dump(const struct bfs_ctx *ctx, enum debug_flags flag) {
 static void dump_costs(const struct bfs_ctx *ctx) {
        const struct bfs_expr *expr = ctx->expr;
        bfs_debug(ctx, DEBUG_COST, "       Cost: ~${ylw}%g${rs}\n", expr->cost);
-       bfs_debug(ctx, DEBUG_COST, "Probability: ~${ylw}%g%%${rs}\n", 100.0*expr->probability);
+       bfs_debug(ctx, DEBUG_COST, "Probability: ~${ylw}%g%%${rs}\n", 100.0 * expr->probability);
 }
 
 struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) {
@@ -3654,7 +3653,7 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) {
                goto fail;
        }
 
-       static chardefault_argv[] = {BFS_COMMAND, NULL};
+       static char *default_argv[] = {BFS_COMMAND, NULL};
        if (argc < 1) {
                argc = 1;
                argv = default_argv;
index 5de5a2807425ee26dd7fcd7d59b618cf49a2755f..98bcb0f4a7778f14b51c1ed6af2cd092f83e9348 100644 (file)
@@ -113,14 +113,14 @@ static int bfs_printf_ctime(CFILE *cfile, const struct bfs_printf *directive, co
        }
 
        BFS_PRINTF_BUF(buf, "%s %s %2d %.2d:%.2d:%.2d.%09ld0 %4d",
-                      days[tm.tm_wday],
-                      months[tm.tm_mon],
-                      tm.tm_mday,
-                      tm.tm_hour,
-                      tm.tm_min,
-                      tm.tm_sec,
-                      (long)ts->tv_nsec,
-                      1900 + tm.tm_year);
+               days[tm.tm_wday],
+               months[tm.tm_mon],
+               tm.tm_mday,
+               tm.tm_hour,
+               tm.tm_min,
+               tm.tm_sec,
+               (long)ts->tv_nsec,
+               1900 + tm.tm_year);
 
        return dyn_fprintf(cfile->file, directive, buf);
 }
@@ -152,19 +152,19 @@ static int bfs_printf_strftime(CFILE *cfile, const struct bfs_printf *directive,
                break;
        case '+':
                ret = snprintf(buf, sizeof(buf), "%4d-%.2d-%.2d+%.2d:%.2d:%.2d.%09ld0",
-                              1900 + tm.tm_year,
-                              tm.tm_mon + 1,
-                              tm.tm_mday,
-                              tm.tm_hour,
-                              tm.tm_min,
-                              tm.tm_sec,
-                              (long)ts->tv_nsec);
+                       1900 + tm.tm_year,
+                       tm.tm_mon + 1,
+                       tm.tm_mday,
+                       tm.tm_hour,
+                       tm.tm_min,
+                       tm.tm_sec,
+                       (long)ts->tv_nsec);
                break;
        case 'k':
                ret = snprintf(buf, sizeof(buf), "%2d", tm.tm_hour);
                break;
        case 'l':
-               ret = snprintf(buf, sizeof(buf), "%2d", (tm.tm_hour + 11)%12 + 1);
+               ret = snprintf(buf, sizeof(buf), "%2d", (tm.tm_hour + 11) % 12 + 1);
                break;
        case 's':
                ret = snprintf(buf, sizeof(buf), "%lld", (long long)ts->tv_sec);
@@ -174,10 +174,10 @@ static int bfs_printf_strftime(CFILE *cfile, const struct bfs_printf *directive,
                break;
        case 'T':
                ret = snprintf(buf, sizeof(buf), "%.2d:%.2d:%.2d.%09ld0",
-                              tm.tm_hour,
-                              tm.tm_min,
-                              tm.tm_sec,
-                              (long)ts->tv_nsec);
+                       tm.tm_hour,
+                       tm.tm_min,
+                       tm.tm_sec,
+                       (long)ts->tv_nsec);
                break;
 
        // POSIX strftime() features
@@ -202,7 +202,7 @@ static int bfs_printf_b(CFILE *cfile, const struct bfs_printf *directive, const
                return -1;
        }
 
-       uintmax_t blocks = ((uintmax_t)statbuf->blocks*BFS_STAT_BLKSIZE + 511)/512;
+       uintmax_t blocks = ((uintmax_t)statbuf->blocks * BFS_STAT_BLKSIZE + 511) / 512;
        BFS_PRINTF_BUF(buf, "%ju", blocks);
        return dyn_fprintf(cfile->file, directive, buf);
 }
@@ -338,7 +338,7 @@ static int bfs_printf_k(CFILE *cfile, const struct bfs_printf *directive, const
                return -1;
        }
 
-       uintmax_t blocks = ((uintmax_t)statbuf->blocks*BFS_STAT_BLKSIZE + 1023)/1024;
+       uintmax_t blocks = ((uintmax_t)statbuf->blocks * BFS_STAT_BLKSIZE + 1023) / 1024;
        BFS_PRINTF_BUF(buf, "%ju", blocks);
        return dyn_fprintf(cfile->file, directive, buf);
 }
@@ -452,7 +452,7 @@ static int bfs_printf_S(CFILE *cfile, const struct bfs_printf *directive, const
        if (statbuf->size == 0 && statbuf->blocks == 0) {
                sparsity = 1.0;
        } else {
-               sparsity = (double)BFS_STAT_BLKSIZE*statbuf->blocks/statbuf->size;
+               sparsity = (double)BFS_STAT_BLKSIZE * statbuf->blocks / statbuf->size;
        }
        return dyn_fprintf(cfile->file, directive, sparsity);
 }
index 0e2f5c10a95e057fec5f5d684e8cabd8c8b3cba6..c728ba9f55bd537b20074053036a4b5fad39fb25 100644 (file)
@@ -4,7 +4,6 @@
 #include "pwcache.h"
 #include "alloc.h"
 #include "config.h"
-#include "darray.h"
 #include "trie.h"
 #include <errno.h>
 #include <grp.h>
index e8f48ee160d82922131efc8f6a405d4f8b9ceb32..d7387c6cd2e2e53fcf30161282c5ccab0b4ecd1f 100644 (file)
@@ -10,8 +10,8 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #if defined(STATX_BASIC_STATS) && (!__ANDROID__ || __ANDROID_API__ >= 30)
 #  define BFS_HAS_LIBC_STATX true
index 77aa2d050b713e8cfbd082b0581bd78e324b9866..55544e659c5b5ea7d06a2abeb4cde42e176f1aec 100644 (file)
@@ -700,7 +700,7 @@ static void trie_remove_impl(struct trie *trie, struct trie_leaf *leaf) {
        }
 
        if (child_index < parent_size) {
-               memmove(child, child + 1, (parent_size - child_index)*sizeof(*child));
+               memmove(child, child + 1, (parent_size - child_index) * sizeof(*child));
        }
 
        if (has_single_bit(parent_size)) {
index 2f51db59d19205c4544d4088f6371e767f41cda9..02088f12cb7f6d6dc458d2b068fbcad29b66b8ff 100644 (file)
@@ -4,8 +4,8 @@
 #ifndef BFS_TRIE_H
 #define BFS_TRIE_H
 
-#include "config.h"
 #include "alloc.h"
+#include "config.h"
 #include "list.h"
 #include <stddef.h>
 #include <stdint.h>
@@ -143,6 +143,6 @@ void trie_destroy(struct trie *trie);
  * Iterate over the leaves of a trie.
  */
 #define for_trie(leaf, trie) \
-       for_list(struct trie_leaf, leaf, trie)
+       for_list (struct trie_leaf, leaf, trie)
 
 #endif // BFS_TRIE_H
index beb6676edad697a26f00481bce4a11d6aeda616c..b9c04bf534faffa5e088033bad7fa518289e3888 100644 (file)
@@ -5,8 +5,8 @@
 #include "alloc.h"
 #include "config.h"
 #include "diag.h"
-#include "thread.h"
 #include "sanity.h"
+#include "thread.h"
 #include <errno.h>
 #include <pthread.h>
 #include <stdlib.h>
index 80bafefe64e7ee96104f3fdc273b549273719c6e..7fb63e0be3ca318ab29e3aae403b495af946e019 100644 (file)
@@ -187,7 +187,7 @@ fail:
 
        // In case of a write error, the parent will still see that we exited
        // unsuccessfully, but won't know why
-       (void) xwrite(pipefd[1], &error, sizeof(error));
+       (void)xwrite(pipefd[1], &error, sizeof(error));
 
        xclose(pipefd[1]);
        _Exit(127);
index 79dafad6e7aa03c9a70361379bd0c5ee0e9cd60a..e90bdb160cf8680ab6212a830ec602686e8b4af5 100644 (file)
@@ -81,7 +81,7 @@ static int safe_add(int *value, int delta) {
 
 static int floor_div(int n, int d) {
        int a = n < 0;
-       return (n + a)/d - a;
+       return (n + a) / d - a;
 }
 
 static int wrap(int *value, int max, int *next) {
@@ -93,7 +93,7 @@ static int wrap(int *value, int max, int *next) {
 static int month_length(int year, int month) {
        static const int month_lengths[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int ret = month_lengths[month];
-       if (month == 1 && year%4 == 0 && (year%100 != 0 || (year + 300)%400 == 0)) {
+       if (month == 1 && year % 4 == 0 && (year % 100 != 0 || (year + 300) % 400 == 0)) {
                ++ret;
        }
        return ret;
@@ -156,13 +156,13 @@ int xtimegm(struct tm *tm, time_t *timep) {
                leap_days = floor_div(tm->tm_year + 3, 4) - floor_div(tm->tm_year + 99, 100) + floor_div(tm->tm_year + 299, 400) - 17;
        }
 
-       long long epoch_days = 365LL*(tm->tm_year - 70) + leap_days + tm->tm_yday;
-       tm->tm_wday = (epoch_days + 4)%7;
+       long long epoch_days = 365LL * (tm->tm_year - 70) + leap_days + tm->tm_yday;
+       tm->tm_wday = (epoch_days + 4) % 7;
        if (tm->tm_wday < 0) {
                tm->tm_wday += 7;
        }
 
-       long long epoch_time = tm->tm_sec + 60*(tm->tm_min + 60*(tm->tm_hour + 24*epoch_days));
+       long long epoch_time = tm->tm_sec + 60 * (tm->tm_min + 60 * (tm->tm_hour + 24 * epoch_days));
        *timep = (time_t)epoch_time;
        if ((long long)*timep != epoch_time) {
                goto overflow;
@@ -296,7 +296,7 @@ end:
                        goto error;
                }
 
-               int offset = 60*tz_hour + tz_min;
+               int offset = 60 * tz_hour + tz_min;
                if (tz_negative) {
                        result->tv_sec -= offset;
                } else {
index 83964e52e900ccf9253bdb8ea3be0e53422710f6..33b3792924f57b7bcfdd15786a1ee49ab839039c 100644 (file)
@@ -7,8 +7,8 @@
 #include <errno.h>
 #include <langinfo.h>
 #include <locale.h>
-#include <stdio.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
index 42ef322217e5b7af359e78ac92fad86212ffb489..7023b4fbf012b6ba4c35c09cc80ed8f4879db32d 100644 (file)
@@ -9,8 +9,8 @@
 #include "../src/bfstd.h"
 #include <errno.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
index 6ea94a288fd382ebb3ca019c48aac1f7561a8845..656fd85c9f4b34c5e10399516bafd282c31685a6 100644 (file)
@@ -120,11 +120,11 @@ int main(void) {
        bfs_verify(!trie_find_mem(&trie, longstr, longsize));
        bfs_verify(trie_insert_mem(&trie, longstr, longsize));
 
-       memset(longstr + longsize/2, 0xAB, longsize/2);
+       memset(longstr + longsize / 2, 0xAB, longsize / 2);
        bfs_verify(!trie_find_mem(&trie, longstr, longsize));
        bfs_verify(trie_insert_mem(&trie, longstr, longsize));
 
-       memset(longstr, 0xAA, longsize/2);
+       memset(longstr, 0xAA, longsize / 2);
        bfs_verify(!trie_find_mem(&trie, longstr, longsize));
        bfs_verify(trie_insert_mem(&trie, longstr, longsize));
 
index b2479b788dc4c0f4e271e36beb78b6a3a029ed86..973b2ebdd7f5ca8a0b3e1ca37be507f1c1b570aa 100644 (file)
@@ -42,9 +42,9 @@ static bool tm_equal(const struct tm *tma, const struct tm *tmb) {
 
 static void tm_print(FILE *file, const struct tm *tm) {
        fprintf(file, "Y%d M%d D%d  h%d m%d s%d  wd%d yd%d%s\n",
-               tm->tm_year, tm->tm_mon, tm->tm_mday,
-               tm->tm_hour, tm->tm_min, tm->tm_sec,
-               tm->tm_wday, tm->tm_yday,
+               tm->tm_year, tm->tm_mon, tm->tm_mday,
+               tm->tm_hour, tm->tm_min, tm->tm_sec,
+               tm->tm_wday, tm->tm_yday,
                tm->tm_isdst ? (tm->tm_isdst < 0 ? " (DST?)" : " (DST)") : "");
 }