From cac079d033259e72f0d11e81856c0266eada3b7f Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 18 Sep 2020 17:36:56 -0400 Subject: stat: Rename bfs_stat_flag to _flags Flags enums should be plural. --- bftw.c | 8 ++++---- bftw.h | 8 ++++---- color.c | 10 +++++----- eval.c | 4 ++-- parse.c | 2 +- stat.c | 10 +++++----- stat.h | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/bftw.c b/bftw.c index 1296360..af9b400 100644 --- a/bftw.c +++ b/bftw.c @@ -852,7 +852,7 @@ static enum bftw_type bftw_dirent_type(const struct dirent *de) { } /** Cached bfs_stat(). */ -static const struct bfs_stat *bftw_stat_impl(struct BFTW *ftwbuf, struct bftw_stat *cache, enum bfs_stat_flag flags) { +static const struct bfs_stat *bftw_stat_impl(struct BFTW *ftwbuf, struct bftw_stat *cache, enum bfs_stat_flags flags) { if (!cache->buf) { if (cache->error) { errno = cache->error; @@ -866,7 +866,7 @@ static const struct bfs_stat *bftw_stat_impl(struct BFTW *ftwbuf, struct bftw_st return cache->buf; } -const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag flags) { +const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags) { struct BFTW *mutbuf = (struct BFTW *)ftwbuf; const struct bfs_stat *ret; @@ -886,7 +886,7 @@ const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag f return ret; } -const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag flags) { +const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags) { if (flags & BFS_STAT_NOFOLLOW) { return ftwbuf->lstat_cache.buf; } else { @@ -894,7 +894,7 @@ const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat } } -enum bftw_type bftw_type(const struct BFTW *ftwbuf, enum bfs_stat_flag flags) { +enum bftw_type bftw_type(const struct BFTW *ftwbuf, enum bfs_stat_flags flags) { if (ftwbuf->stat_flags & BFS_STAT_NOFOLLOW) { if ((flags & BFS_STAT_NOFOLLOW) || ftwbuf->type != BFTW_LNK) { return ftwbuf->type; diff --git a/bftw.h b/bftw.h index 2198b52..687a4c5 100644 --- a/bftw.h +++ b/bftw.h @@ -110,7 +110,7 @@ struct BFTW { const char *at_path; /** Flags for bfs_stat(). */ - enum bfs_stat_flag stat_flags; + enum bfs_stat_flags stat_flags; /** Cached bfs_stat() info for BFS_STAT_NOFOLLOW. */ struct bftw_stat lstat_cache; /** Cached bfs_stat() info for BFS_STAT_FOLLOW. */ @@ -128,7 +128,7 @@ struct BFTW { * @return * A pointer to a bfs_stat() buffer, or NULL if the call failed. */ -const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag flags); +const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags); /** * Get bfs_stat() info for a file encountered during bftw(), if it has already @@ -141,7 +141,7 @@ const struct bfs_stat *bftw_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag f * @return * A pointer to a bfs_stat() buffer, or NULL if no stat info is cached. */ -const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flag flags); +const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat_flags flags); /** * Get the type of a file encountered during bftw(), with flags controlling @@ -155,7 +155,7 @@ const struct bfs_stat *bftw_cached_stat(const struct BFTW *ftwbuf, enum bfs_stat * @return * The type of the file, or BFTW_ERROR if an error occurred. */ -enum bftw_type bftw_type(const struct BFTW *ftwbuf, enum bfs_stat_flag flags); +enum bftw_type bftw_type(const struct BFTW *ftwbuf, enum bfs_stat_flags flags); /** * Walk actions returned by the bftw() callback. diff --git a/color.c b/color.c index 4b70e19..94f58fc 100644 --- a/color.c +++ b/color.c @@ -556,7 +556,7 @@ static bool is_link_broken(const struct BFTW *ftwbuf) { } /** Get the color for a file. */ -static const char *file_color(const struct colors *colors, const char *filename, const struct BFTW *ftwbuf, enum bfs_stat_flag flags) { +static const char *file_color(const struct colors *colors, const char *filename, const struct BFTW *ftwbuf, enum bfs_stat_flags flags) { enum bftw_type type = bftw_type(ftwbuf, flags); if (type == BFTW_ERROR) { goto error; @@ -716,7 +716,7 @@ static int print_colored(const struct colors *colors, const char *esc, const cha } /** Find the offset of the first broken path component. */ -static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flag flags, size_t max) { +static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flags flags, size_t max) { ssize_t ret = max; if (bftw_type(ftwbuf, flags) != BFTW_ERROR) { @@ -775,7 +775,7 @@ out: } /** Print the directories leading up to a file. */ -static int print_dirs_colored(CFILE *cfile, const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flag flags, size_t nameoff) { +static int print_dirs_colored(CFILE *cfile, const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flags flags, size_t nameoff) { const struct colors *colors = cfile->colors; FILE *file = cfile->file; @@ -804,7 +804,7 @@ static int print_dirs_colored(CFILE *cfile, const char *path, const struct BFTW } /** Print a path with colors. */ -static int print_path_colored(CFILE *cfile, const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flag flags) { +static int print_path_colored(CFILE *cfile, const char *path, const struct BFTW *ftwbuf, enum bfs_stat_flags flags) { const struct colors *colors = cfile->colors; FILE *file = cfile->file; @@ -829,7 +829,7 @@ static int print_path(CFILE *cfile, const struct BFTW *ftwbuf) { return fputs(ftwbuf->path, cfile->file) == EOF ? -1 : 0; } - enum bfs_stat_flag flags = ftwbuf->stat_flags; + enum bfs_stat_flags flags = ftwbuf->stat_flags; if (colors && colors->link_as_target && ftwbuf->type == BFTW_LNK) { flags = BFS_STAT_TRYFOLLOW; } diff --git a/eval.c b/eval.c index b50efd7..1498282 100644 --- a/eval.c +++ b/eval.c @@ -879,7 +879,7 @@ bool eval_xattrname(const struct expr *expr, struct eval_state *state) { */ bool eval_xtype(const struct expr *expr, struct eval_state *state) { const struct BFTW *ftwbuf = state->ftwbuf; - enum bfs_stat_flag flags = ftwbuf->stat_flags ^ (BFS_STAT_NOFOLLOW | BFS_STAT_TRYFOLLOW); + enum bfs_stat_flags flags = ftwbuf->stat_flags ^ (BFS_STAT_NOFOLLOW | BFS_STAT_TRYFOLLOW); enum bftw_type type = bftw_type(ftwbuf, flags); if (type == BFTW_ERROR) { eval_report_error(state); @@ -1051,7 +1051,7 @@ static bool eval_file_unique(struct eval_state *state, struct trie *seen) { /** * Log a stat() call. */ -static void debug_stat(const struct cmdline *cmdline, const struct BFTW *ftwbuf, const struct bftw_stat *cache, enum bfs_stat_flag flags) { +static void debug_stat(const struct cmdline *cmdline, const struct BFTW *ftwbuf, const struct bftw_stat *cache, enum bfs_stat_flags flags) { bfs_debug_prefix(cmdline, DEBUG_STAT); fprintf(stderr, "bfs_stat("); diff --git a/parse.c b/parse.c index 155f10b..a3af1d1 100644 --- a/parse.c +++ b/parse.c @@ -442,7 +442,7 @@ static int stat_arg(const struct parser_state *state, struct expr *expr, struct const struct cmdline *cmdline = state->cmdline; bool follow = cmdline->flags & (BFTW_FOLLOW_ROOTS | BFTW_FOLLOW_ALL); - enum bfs_stat_flag flags = follow ? BFS_STAT_TRYFOLLOW : BFS_STAT_NOFOLLOW; + enum bfs_stat_flags flags = follow ? BFS_STAT_TRYFOLLOW : BFS_STAT_NOFOLLOW; int ret = bfs_stat(AT_FDCWD, expr->sdata, flags, sb); if (ret != 0) { diff --git a/stat.c b/stat.c index cefefd6..55aece0 100644 --- a/stat.c +++ b/stat.c @@ -82,7 +82,7 @@ const char *bfs_stat_field_name(enum bfs_stat_field field) { /** * Check if we should retry a failed stat() due to a potentially broken link. */ -static bool bfs_stat_retry(int ret, enum bfs_stat_flag flags) { +static bool bfs_stat_retry(int ret, enum bfs_stat_flags flags) { return ret != 0 && (flags & (BFS_STAT_NOFOLLOW | BFS_STAT_TRYFOLLOW)) == BFS_STAT_TRYFOLLOW && is_nonexistence_error(errno); @@ -139,7 +139,7 @@ static void bfs_stat_convert(const struct stat *statbuf, struct bfs_stat *buf) { /** * bfs_stat() implementation backed by stat(). */ -static int bfs_stat_impl(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flag flags, struct bfs_stat *buf) { +static int bfs_stat_impl(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flags flags, struct bfs_stat *buf) { struct stat statbuf; int ret = fstatat(at_fd, at_path, &statbuf, at_flags); @@ -177,7 +177,7 @@ static int bfs_statx(int at_fd, const char *at_path, int at_flags, unsigned int /** * bfs_stat() implementation backed by statx(). */ -static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flag flags, struct bfs_stat *buf) { +static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flags flags, struct bfs_stat *buf) { unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; struct statx xbuf; int ret = bfs_statx(at_fd, at_path, at_flags, mask, &xbuf); @@ -276,7 +276,7 @@ static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, enum bfs /** * Allows calling stat with custom at_flags. */ -static int bfs_stat_explicit(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flag flags, struct bfs_stat *buf) { +static int bfs_stat_explicit(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flags flags, struct bfs_stat *buf) { #if HAVE_BFS_STATX static bool has_statx = true; @@ -295,7 +295,7 @@ static int bfs_stat_explicit(int at_fd, const char *at_path, int at_flags, enum return bfs_stat_impl(at_fd, at_path, at_flags, flags, buf); } -int bfs_stat(int at_fd, const char *at_path, enum bfs_stat_flag flags, struct bfs_stat *buf) { +int bfs_stat(int at_fd, const char *at_path, enum bfs_stat_flags flags, struct bfs_stat *buf) { int at_flags = 0; if (flags & BFS_STAT_NOFOLLOW) { at_flags |= AT_SYMLINK_NOFOLLOW; diff --git a/stat.h b/stat.h index 369ac4a..a32967b 100644 --- a/stat.h +++ b/stat.h @@ -62,7 +62,7 @@ const char *bfs_stat_field_name(enum bfs_stat_field field); /** * bfs_stat() flags. */ -enum bfs_stat_flag { +enum bfs_stat_flags { /** Follow symlinks (the default). */ BFS_STAT_FOLLOW = 0, /** Never follow symlinks. */ @@ -132,7 +132,7 @@ struct bfs_stat { * @return * 0 on success, -1 on error. */ -int bfs_stat(int at_fd, const char *at_path, enum bfs_stat_flag flags, struct bfs_stat *buf); +int bfs_stat(int at_fd, const char *at_path, enum bfs_stat_flags flags, struct bfs_stat *buf); /** * Get a particular time field from a bfs_stat() buffer. -- cgit v1.2.3