summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/color.c6
-rw-r--r--src/ctx.c1
-rw-r--r--src/darray.c4
-rw-r--r--src/diag.c8
-rw-r--r--src/diag.h2
-rw-r--r--src/dstring.c4
-rw-r--r--src/eval.c15
-rw-r--r--src/exec.c16
-rw-r--r--src/fsade.c6
-rw-r--r--src/ioq.c2
-rw-r--r--src/opt.c11
-rw-r--r--src/opt.h1
-rw-r--r--src/parse.c45
-rw-r--r--src/printf.c46
-rw-r--r--src/pwcache.c1
-rw-r--r--src/stat.c2
-rw-r--r--src/trie.c2
-rw-r--r--src/trie.h4
-rw-r--r--src/xregex.c2
-rw-r--r--src/xspawn.c2
-rw-r--r--src/xtime.c12
21 files changed, 93 insertions, 99 deletions
diff --git a/src/color.c b/src/color.c
index 8d0b995..788d35d 100644
--- a/src/color.c
+++ b/src/color.c
@@ -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;
}
}
diff --git a/src/ctx.c b/src/ctx.c
index 3a44e68..9a24a33 100644
--- 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
diff --git a/src/darray.c b/src/darray.c
index 42b8397..3e66a55 100644
--- a/src/darray.c
+++ b/src/darray.c
@@ -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;
}
diff --git a/src/diag.c b/src/diag.c
index fa9db39..fa66525 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -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);
diff --git a/src/diag.h b/src/diag.h
index e019db0..fea8847 100644
--- a/src/diag.h
+++ b/src/diag.h
@@ -8,8 +8,8 @@
#ifndef BFS_DIAG_H
#define BFS_DIAG_H
-#include "ctx.h"
#include "config.h"
+#include "ctx.h"
#include <stdarg.h>
/**
diff --git a/src/dstring.c b/src/dstring.c
index ef4e733..f947741 100644
--- a/src/dstring.c
+++ b/src/dstring.c
@@ -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;
diff --git a/src/eval.c b/src/eval.c
index 3550751..9f4896a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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;
}
diff --git a/src/exec.c b/src/exec.c
index 7b55522..0e0d585 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -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;
diff --git a/src/fsade.c b/src/fsade.c
index 8dec5a8..cbff47b 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -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);
diff --git a/src/ioq.c b/src/ioq.c
index f7ca8c6..d3ba2de 100644
--- 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>
diff --git a/src/opt.c b/src/opt.c
index 14de081..77c2798 100644
--- 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);
}
}
diff --git a/src/opt.h b/src/opt.h
index 28cadb9..4aac129 100644
--- 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
-
diff --git a/src/parse.c b/src/parse.c
index 3416d9e..7766a7b 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -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 char* default_argv[] = {BFS_COMMAND, NULL};
+ static char *default_argv[] = {BFS_COMMAND, NULL};
if (argc < 1) {
argc = 1;
argv = default_argv;
diff --git a/src/printf.c b/src/printf.c
index 5de5a28..98bcb0f 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -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);
}
diff --git a/src/pwcache.c b/src/pwcache.c
index 0e2f5c1..c728ba9 100644
--- a/src/pwcache.c
+++ b/src/pwcache.c
@@ -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>
diff --git a/src/stat.c b/src/stat.c
index e8f48ee..d7387c6 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -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
diff --git a/src/trie.c b/src/trie.c
index 77aa2d0..55544e6 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -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)) {
diff --git a/src/trie.h b/src/trie.h
index 2f51db5..02088f1 100644
--- a/src/trie.h
+++ b/src/trie.h
@@ -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
diff --git a/src/xregex.c b/src/xregex.c
index beb6676..b9c04bf 100644
--- a/src/xregex.c
+++ b/src/xregex.c
@@ -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>
diff --git a/src/xspawn.c b/src/xspawn.c
index 80bafef..7fb63e0 100644
--- a/src/xspawn.c
+++ b/src/xspawn.c
@@ -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);
diff --git a/src/xtime.c b/src/xtime.c
index 79dafad..e90bdb1 100644
--- a/src/xtime.c
+++ b/src/xtime.c
@@ -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 {