From 9fab17734c84423ff6ac223968665d31d34ed95a Mon Sep 17 00:00:00 2001 From: CismonX Date: Fri, 7 Mar 2025 14:35:45 +0800 Subject: [PATCH] chore: misc cleanup --- configure.ac | 8 +++----- doc/bookmarkfs.texi | 6 ------ m4/bookmarkfs_ac.m4 | 2 +- src/backend_util.h | 6 +----- src/defs.h | 15 ++++++--------- src/fs_ops.c | 2 +- src/lib.h | 2 -- tests/Makefile.am | 3 --- tests/check_sandbox.c | 36 ++++++++++++++++++------------------ tests/check_watcher.c | 36 ++++++++++++++++++------------------ 10 files changed, 48 insertions(+), 68 deletions(-) diff --git a/configure.ac b/configure.ac index c1e469f..4772b8b 100644 --- a/configure.ac +++ b/configure.ac @@ -28,9 +28,7 @@ AS_CASE(["${host_os}"], [linux*], [ ], [freebsd*], [ AS_VAR_SET([host_os_is_freebsd], [yes]) ], [ - AC_MSG_WARN(m4_normalize([ - Unsupported platform "${host_os}". - ])) + AC_MSG_WARN(m4_normalize([Unsupported platform "${host_os}".])) ]) # -- Checks for programs -- @@ -176,6 +174,7 @@ AX_GCC_FUNC_ATTRIBUTE([cold]) AX_GCC_FUNC_ATTRIBUTE([destructor]) AX_GCC_FUNC_ATTRIBUTE([malloc]) AX_GCC_FUNC_ATTRIBUTE([noreturn]) +AX_GCC_FUNC_ATTRIBUTE([pure]) AX_GCC_FUNC_ATTRIBUTE([returns_nonnull]) AX_GCC_FUNC_ATTRIBUTE([visibility]) AX_GCC_VAR_ATTRIBUTE([unused]) @@ -209,8 +208,7 @@ m4_version_prereq([2.72], [ AC_SYS_YEAR2038 AS_VAR_IF([ac_have_year2038], [no], [ AC_MSG_ERROR(m4_normalize([ - 64-bit time_t (required by some backends) is unsupported on - this platform. + 64-bit time_t is unsupported on this platform. ])) ]) ], [ diff --git a/doc/bookmarkfs.texi b/doc/bookmarkfs.texi index 68a5724..5c0f96d 100644 --- a/doc/bookmarkfs.texi +++ b/doc/bookmarkfs.texi @@ -3648,7 +3648,6 @@ If this function is never called, the hash function bahaves as if it is seeded with all bits zero. @item hash_digest - Calculates the digest of the given input. @example c @@ -3660,7 +3659,6 @@ hash_digest ( @end example @item hash_digestv - Like @code{hash_digest()}, but takes input from multiple buffers. @example c @@ -3675,7 +3673,6 @@ The function is guaranteed not to modify the buffer data of each @code{struct iovec} object. @item hash_digestcb - Like @code{hash_digestv()}, but takes input buffers from a callback function. @example c @@ -3690,7 +3687,6 @@ Function arguments: @table @code @item callback - The function to provide input buffers. It must not be @code{NULL}. @@ -3981,7 +3977,6 @@ Functions: @table @code @item prng_seed - Updates the seed used by the PRNG. @example c @@ -4225,7 +4220,6 @@ watcher_destroy ( @end example @item watcher_poll - Checks whether the file being watched has changed. This function never blocks. diff --git a/m4/bookmarkfs_ac.m4 b/m4/bookmarkfs_ac.m4 index de7d369..dab537f 100644 --- a/m4/bookmarkfs_ac.m4 +++ b/m4/bookmarkfs_ac.m4 @@ -88,7 +88,7 @@ AC_DEFUN([BOOKMARKFS_AMCOND], [ ]) dnl -dnl BOOKMARKFS_FEAT_OUT([features]...) +dnl BOOKMARKFS_FEAT_EXPORT([features]...) dnl dnl Export feature flags to Autoconf output variables, dnl similar to the ones set by AM_CONTITIONAL() (`xxx_TRUE` only). diff --git a/src/backend_util.h b/src/backend_util.h index add8e99..72cbabb 100644 --- a/src/backend_util.h +++ b/src/backend_util.h @@ -51,7 +51,7 @@ #define BACKEND_OPT_BAD_VAL() BACKEND_OPT_ERR_(BAD_VAL) #define BACKEND_OPT_NO_VAL \ if (val_ != NULL) return BACKEND_OPT_ERR_(HAS_VAL); -#define BACKEND_OPT_VAL_STR val_ +#define BACKEND_OPT_VAL_STR (val_) #define FILENAME_BADCHAR -1 #define FILENAME_BADLEN -2 @@ -67,14 +67,12 @@ * Returns the directory file descriptor if successful. * On error, -1 is returned, and errno is set. */ -BOOKMARKFS_INTERNAL int basename_opendir ( char *path, char **basename_ptr ); -BOOKMARKFS_INTERNAL FUNCATTR_COLD int print_backend_opt_err_ ( @@ -91,7 +89,6 @@ print_backend_opt_err_ ( * If returning FILENAME_BADCHAR, stores the pointer to the first * bad character to `end_ptr` unless it is NULL. */ -BOOKMARKFS_INTERNAL int validate_filename ( char const *str, @@ -99,7 +96,6 @@ validate_filename ( char const **end_ptr ); -BOOKMARKFS_INTERNAL int validate_filename_fsck ( char const *str, diff --git a/src/defs.h b/src/defs.h index 983bb7b..dbb2020 100644 --- a/src/defs.h +++ b/src/defs.h @@ -61,6 +61,12 @@ # endif /* defined(HAVE_FUNC_ATTRIBUTE_NORETURN) */ #endif +#ifdef HAVE_FUNC_ATTRIBUTE_PURE +# define FUNCATTR_PURE __attribute__((pure)) +#else +# define FUNCATTR_PURE +#endif /* defined(HAVE_FUNC_ATTRIBUTE_PURE) */ + #ifdef HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL # define FUNCATTR_RETURNS_NONNULL __attribute__((returns_nonnull)) #else @@ -86,15 +92,6 @@ # define UNUSED_VAR(name) name##_unused_ VARATTR_UNUSED_ #endif /* defined(HAVE_STDC_23) */ -#if defined(HAVE_STDC_23) -# define BOOKMARKFS_TLS thread_local -#elif defined(HAVE_STDC_11) -# define BOOKMARKFS_TLS _Thread_local -// Incomprehensive list. Add more if needed. -#elif defined(__GNUC__) || defined(__clang__) -# define BOOKMARKFS_TLS __thread -#endif - #if defined(__FreeBSD__) || (defined(__linux__) && defined(_GNU_SOURCE)) # define HAVE_PIPE2 1 #endif diff --git a/src/fs_ops.c b/src/fs_ops.c index ee6e110..d901678 100644 --- a/src/fs_ops.c +++ b/src/fs_ops.c @@ -197,7 +197,7 @@ static int bm_create (uint64_t, char const *, int, struct stat *); static int bm_delete (uint64_t, char const *, uint32_t); static int bm_do_write (uint64_t, struct fs_file_handle *); static void bm_fh_free (struct fs_file_handle *, long); -static struct fs_file_handle * +static struct fs_file_handle * FUNCATTR_PURE bm_fh_get (uint64_t, unsigned long *, unsigned long *); static struct fs_file_handle * bm_fh_new (uint64_t); diff --git a/src/lib.h b/src/lib.h index cf00f2a..2df30cd 100644 --- a/src/lib.h +++ b/src/lib.h @@ -25,11 +25,9 @@ #include "defs.h" -BOOKMARKFS_INTERNAL int bookmarkfs_lib_init (void); -BOOKMARKFS_INTERNAL FUNCATTR_COLD void bookmarkfs_print_lib_version ( diff --git a/tests/Makefile.am b/tests/Makefile.am index 3f1bdf4..5bcb987 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,8 +45,5 @@ $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 $(TESTS_) check-local: atconfig atlocal $(TESTSUITE) $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) -installcheck-local: atconfig atlocal $(TESTSUITE) - $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) AUTOTEST_PATH='$(bindir)' - clean-local: test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean diff --git a/tests/check_sandbox.c b/tests/check_sandbox.c index 023a27b..adf95f0 100644 --- a/tests/check_sandbox.c +++ b/tests/check_sandbox.c @@ -1,22 +1,22 @@ /** -* bookmarkfs/tests/check_sandbox.c -* ---- -* -* Copyright (C) 2025 CismonX -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * bookmarkfs/tests/check_sandbox.c + * ---- + * + * Copyright (C) 2025 CismonX + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/tests/check_watcher.c b/tests/check_watcher.c index a246b43..1be1c1e 100644 --- a/tests/check_watcher.c +++ b/tests/check_watcher.c @@ -1,22 +1,22 @@ /** -* bookmarkfs/tests/check_watcher.c -* ---- -* -* Copyright (C) 2025 CismonX -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * bookmarkfs/tests/check_watcher.c + * ---- + * + * Copyright (C) 2025 CismonX + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifdef HAVE_CONFIG_H # include "config.h"