@@ -20,7 +20,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
-#include <limits.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
@@ -20,11 +20,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <inttypes.h>
#include <string.h>
#include <limits.h>
#include <byteswap.h>
-#include "crypto/crc32c.h"
#include "kernel-shared/disk-io.h"
#define BLOCKSIZE (4096)
@@ -28,7 +28,6 @@
#include "common/utils.h"
#include "common/string-utils.h"
#include "common/help.h"
-#include "common/box.h"
#include "common/messages.h"
#include "cmds/commands.h"
@@ -26,7 +26,6 @@
#include <dirent.h>
#include <stdbool.h>
#include "kernel-shared/zoned.h"
-#include "kernel-shared/volumes.h"
#include "common/string-table.h"
#include "common/utils.h"
#include "common/help.h"
@@ -27,7 +27,6 @@
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
-#include <limits.h>
#include <stdbool.h>
#include <unistd.h>
#include "kernel-lib/rbtree.h"
@@ -26,7 +26,6 @@
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
-#include <limits.h>
#include <uuid/uuid.h>
#include "kernel-lib/sizes.h"
#include "kernel-shared/ctree.h"
@@ -26,7 +26,6 @@
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
-#include <limits.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
@@ -45,8 +44,6 @@
#include "common/open-utils.h"
#include "common/units.h"
#include "common/string-utils.h"
-#include "common/string-table.h"
-#include "common/sort-utils.h"
#include "common/tree-search.h"
#include "cmds/commands.h"
@@ -16,7 +16,6 @@
* Boston, MA 021110-1307, USA.
*/
-#include "kerncompat.h"
#include <sys/ioctl.h>
#include <dirent.h>
#include <errno.h>
@@ -17,7 +17,6 @@
*/
#include "kerncompat.h"
-#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <errno.h>
@@ -28,7 +28,6 @@
#include <stdint.h>
#include <fcntl.h>
#include <getopt.h>
-#include <limits.h>
#include <errno.h>
#include <endian.h>
#include <stdbool.h>
@@ -23,8 +23,6 @@
#include <unistd.h>
#include "kernel-lib/list.h"
#include "common/messages.h"
-#include "common/open-utils.h"
-#include "common/parse-utils.h"
#include "common/string-utils.h"
#include "common/help.h"
#include "cmds/commands.h"
@@ -28,7 +28,6 @@
#include <regex.h>
#include <getopt.h>
#include <errno.h>
-#include <limits.h>
#include <stddef.h>
#include <string.h>
#if COMPRESSION_LZO
@@ -31,7 +31,6 @@
#include <ctype.h>
#include <signal.h>
#include <stdarg.h>
-#include <limits.h>
#include <dirent.h>
#include <getopt.h>
#include <errno.h>
@@ -50,11 +49,9 @@
#include "common/open-utils.h"
#include "common/units.h"
#include "common/device-utils.h"
-#include "common/parse-utils.h"
#include "common/sysfs-utils.h"
#include "common/string-table.h"
#include "common/string-utils.h"
-#include "common/parse-utils.h"
#include "common/help.h"
#include "cmds/commands.h"
@@ -28,7 +28,6 @@
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
-#include <limits.h>
#include <stdbool.h>
#include <blkid/blkid.h>
#include <uuid/uuid.h>
@@ -22,7 +22,6 @@
#include <fcntl.h>
#include <mntent.h>
#include <errno.h>
-#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "kernel-lib/list.h"
@@ -29,7 +29,6 @@
#include <errno.h>
#include <ctype.h>
#include <libgen.h>
-#include <limits.h>
#include "common/path-utils.h"
/*
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "kernel-shared/accessors.h"
#include "kernel-shared/uapi/btrfs_tree.h"
#include "kernel-shared/uapi/btrfs.h"
#include "kernel-shared/send.h"
@@ -20,7 +20,6 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
-#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -16,8 +16,6 @@
#include "kerncompat.h"
#include <stdlib.h>
-#include <stdio.h>
-#include <limits.h>
#include "common/string-utils.h"
#include "common/messages.h"
#include "common/parse-utils.h"
@@ -43,7 +43,12 @@
const char *pretty_size_mode(u64 size, unsigned mode);
int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mode);
-#define pretty_size(size) pretty_size_mode(size, UNITS_DEFAULT)
+
+static inline const char *pretty_size(u64 size)
+{
+ return pretty_size_mode(size, UNITS_DEFAULT);
+}
+
void units_set_mode(unsigned *units, unsigned mode);
void units_set_base(unsigned *units, unsigned base);
unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode);
@@ -32,7 +32,6 @@
#include <unistd.h>
#include <mntent.h>
#include <ctype.h>
-#include <limits.h>
#include <strings.h>
#include "kernel-lib/list.h"
#include "kernel-shared/accessors.h"
@@ -91,7 +91,6 @@
#include <pthread.h>
#include <stdbool.h>
#include <errno.h>
-#include <limits.h>
#include <string.h>
#include <uuid/uuid.h>
#include "kernel-lib/sizes.h"
@@ -21,7 +21,6 @@
#include <linux/limits.h>
#include <errno.h>
#include <pthread.h>
-#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -17,15 +17,12 @@
/*
* Btrfs-progs port, with following minor fixes:
- * 1) Use "kerncompat.h"
+ * 1) Use "kerncompat.h" header for generated tables.c
* 2) Get rid of __KERNEL__ related macros
*/
#include <stdio.h>
-#include <string.h>
#include <inttypes.h>
-#include <stdlib.h>
-#include <time.h>
static uint8_t gfmul(uint8_t a, uint8_t b)
{
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/disk-io.h"
#include "kernel-shared/accessors.h"
@@ -22,7 +22,6 @@
#include <stdbool.h>
#include <errno.h>
#include <string.h>
-#include "kernel-lib/bitops.h"
#include "kernel-lib/list.h"
#include "kernel-lib/rbtree.h"
#include "kernel-lib/rbtree_types.h"
@@ -24,7 +24,6 @@
#include "kernel-shared/transaction.h"
#include "kernel-shared/file-item.h"
#include "kernel-shared/extent_io.h"
-#include "kernel-shared/uapi/btrfs.h"
#include "common/internal.h"
#define MAX_CSUM_ITEMS(r, size) ((((BTRFS_LEAF_DATA_SIZE(r->fs_info) - \
@@ -19,10 +19,8 @@
#include "kerncompat.h"
#include <errno.h>
#include <string.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/accessors.h"
#include "kernel-shared/extent_io.h"
-#include "kernel-shared/uapi/btrfs.h"
#include "kernel-shared/uapi/btrfs_tree.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/compression.h"
@@ -19,10 +19,8 @@
#include "kerncompat.h"
#include <errno.h>
#include <stddef.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/accessors.h"
#include "kernel-shared/extent_io.h"
-#include "kernel-shared/uapi/btrfs.h"
#include "kernel-shared/uapi/btrfs_tree.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/disk-io.h"
@@ -3,7 +3,6 @@
#include "kerncompat.h"
#include <errno.h>
#include <stdarg.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/messages.h"
@@ -19,7 +19,6 @@
#include "kerncompat.h"
#include <errno.h>
#include <string.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/accessors.h"
#include "kernel-shared/messages.h"
#include "kernel-shared/extent_io.h"
@@ -19,7 +19,6 @@
#include <sys/stat.h>
#include <linux/limits.h>
#include <errno.h>
-#include <limits.h>
#include <stdarg.h>
#include "kernel-lib/overflow.h"
#include "kernel-lib/bitops.h"
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
-#include "kernel-lib/bitops.h"
#include "kernel-shared/accessors.h"
#include "kernel-shared/extent_io.h"
#include "kernel-shared/uapi/btrfs.h"
@@ -29,8 +28,6 @@
#include "kernel-shared/ctree.h"
#include "kernel-shared/messages.h"
#include "kernel-shared/transaction.h"
-#include "common/messages.h"
-#include "common/utils.h"
void btrfs_uuid_to_key(const u8 *uuid, u8 type, struct btrfs_key *key)
{
@@ -28,7 +28,6 @@
#include "kernel-shared/accessors.h"
#include "kernel-shared/ctree.h"
#include "kernel-shared/extent_io.h"
-#include "kernel-shared/uapi/btrfs.h"
#include "kernel-shared/uapi/btrfs_tree.h"
#include "common/utils.h"
#include "common/device-utils.h"
@@ -8,7 +8,6 @@
*
*/
-#include <inttypes.h>
#include "libbtrfs/crc32c.h"
uint32_t __crc32c_le(uint32_t crc, unsigned char const *data, uint32_t length);
@@ -53,7 +52,7 @@ static uint32_t crc32c_intel_le_hw_byte(uint32_t crc, unsigned char const *data,
}
/*
- * Steps through buffer one byte at at time, calculates reflected
+ * Steps through buffer one byte at at time, calculates reflected
* crc using table.
*/
static uint32_t crc32c_intel(uint32_t crc, unsigned char const *data, uint32_t length)
@@ -198,7 +197,7 @@ static const uint32_t crc32c_table[256] = {
};
/*
- * Steps through buffer one byte at at time, calculates reflected
+ * Steps through buffer one byte at at time, calculates reflected
* crc using table.
*/
@@ -17,7 +17,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
-#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -24,7 +24,6 @@
#include <fcntl.h>
#include <ftw.h>
#include <errno.h>
-#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "kernel-lib/sizes.h"
@@ -32,7 +32,6 @@
#include <fcntl.h>
#include <assert.h>
#include <getopt.h>
-#include "common/internal.h"
#define AIO
#define URING
@@ -1434,7 +1433,7 @@ fent_to_name(pathname_t *name, fent_t *fep)
if (pfep == NULL) {
fprintf(stderr, "%d: fent-id = %d: can't find parent id: %d\n",
procid, fep->id, fep->parent);
- }
+ }
#endif
if (pfep == NULL)
return 0;
@@ -1545,7 +1544,7 @@ int generate_xattr_name(int xattr_num, char *buffer, int buflen)
}
/*
- * Get file
+ * Get file
* Input: "which" to choose the file-types eg. non-directory
* Input: "r" to choose which file
* Output: file-list, file-entry, name for the chosen file.
@@ -1585,7 +1584,7 @@ get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
* Now we have possible matches between 0..totalsum-1.
* And we use r to help us choose which one we want,
* which when bounded by totalsum becomes x.
- */
+ */
x = (int)(r % totalsum);
for (i = 0, flp = flist; i < FT_nft; i++, flp++) {
if (which & (1U << i)) {
@@ -1600,7 +1599,7 @@ get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
#ifdef DEBUG
if (!e) {
fprintf(stderr, "%d: failed to get path for entry:"
- " id=%d,parent=%d\n",
+ " id=%d,parent=%d\n",
procid, fep->id, fep->parent);
}
#endif
@@ -2007,7 +2006,7 @@ show_ops(int flag, char *lead_str)
if (flag<0) {
/* print in list form */
int x = WIDTH;
-
+
for (p = ops; p < ops_end; p++) {
if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
x=printf("%s%s", (p==ops)?"":"\n", lead_str);
@@ -2069,7 +2068,7 @@ symlink_path(const char *name1, pathname_t *name)
char buf[NAME_MAX + 1];
pathname_t newname;
int rval;
-
+
if (!strcmp(name1, name->path)) {
printf("yikes! %s %s\n", name1, name->path);
return 0;
@@ -2647,7 +2646,7 @@ bulkstat_f(opnum_t opno, long r)
bsr.icount=nent;
bsr.ubuffer=t;
bsr.ocount=&count;
-
+
while (xfsctl(".", fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
total += count;
free(t);
@@ -2680,8 +2679,8 @@ bulkstat1_f(opnum_t opno, long r)
check_cwd();
free_pathname(&f);
} else {
- /*
- * pick a random inode
+ /*
+ * pick a random inode
*
* note this can generate kernel warning messages
* since bulkstat_one will read the disk block that
@@ -2698,7 +2697,7 @@ bulkstat1_f(opnum_t opno, long r)
v = verbose;
}
fd = open(".", O_RDONLY);
-
+
bsr.lastip=&ino;
bsr.icount=1;
bsr.ubuffer=&t;
@@ -3797,7 +3796,7 @@ dread_f(opnum_t opno, long r)
len -= (len % align);
if (len <= 0)
len = align;
- else if (len > diob.d_maxiosz)
+ else if (len > diob.d_maxiosz)
len = diob.d_maxiosz;
buf = memalign(diob.d_mem, len);
e = read(fd, buf, len) < 0 ? errno : 0;
@@ -3874,7 +3873,7 @@ dwrite_f(opnum_t opno, long r)
len -= (len % align);
if (len <= 0)
len = align;
- else if (len > diob.d_maxiosz)
+ else if (len > diob.d_maxiosz)
len = diob.d_maxiosz;
buf = memalign(diob.d_mem, len);
off %= maxfsize;
@@ -19,7 +19,6 @@
#include <stdlib.h>
#include "kernel-shared/uapi/btrfs.h"
-#include "kernel-shared/ctree.h"
#define LIST_32_COMPAT \
ONE(BTRFS_IOC_SET_RECEIVED_SUBVOL_32)
There are quite some headers included but not utilized, clangd would report those headers for cleanup. However clangd (17.0.6 at the time of writing) has a bug that, the file is only utilizing a C macro in the header, clangd would still report the header as unused. This involves the following exceptions: - pretty_size() There is not much need to declare it as a macro. Redefine it as a static inline function to workaround the clangd bug. - kernel-lib/mktables.c False alert on inittype.h, as some types are defined as macros. - libbtrfs/send-utils.c False alert on limits.h, as some types are defined as macros. - tests/array-tests.c - tests/string-table-test.c False alert on common/utils.h for ARRAY_SIZE() macro. Some parts are not touched yet: - crypto/* This involves quite some optimization code for different instructions, making it pretty hard to comprehensively tested. - tests/library-tests As I'll do a more comprehensive cleanup involving BTRFS_FLAT_INCLUDES. Signed-off-by: Qu Wenruo <wqu@suse.com> --- btrfs-corrupt-block.c | 1 - btrfs-sb-mod.c | 2 -- btrfs.c | 1 - cmds/device.c | 1 - cmds/filesystem-du.c | 1 - cmds/filesystem-usage.c | 1 - cmds/inspect.c | 3 --- cmds/quota.c | 1 - cmds/receive-dump.c | 1 - cmds/receive.c | 1 - cmds/reflink.c | 2 -- cmds/restore.c | 1 - cmds/scrub.c | 3 --- common/device-scan.c | 1 - common/open-utils.c | 1 - common/path-utils.c | 1 - common/send-stream.c | 1 - common/send-utils.c | 1 - common/string-utils.c | 2 -- common/units.h | 7 ++++++- common/utils.c | 1 - convert/main.c | 1 - convert/source-ext2.c | 1 - kernel-lib/mktables.c | 5 +---- kernel-shared/dir-item.c | 1 - kernel-shared/extent-tree.c | 1 - kernel-shared/file-item.c | 1 - kernel-shared/file.c | 2 -- kernel-shared/inode-item.c | 2 -- kernel-shared/messages.c | 1 - kernel-shared/root-tree.c | 1 - kernel-shared/tree-checker.c | 1 - kernel-shared/uuid-tree.c | 3 --- kernel-shared/zoned.c | 1 - libbtrfs/crc32c.c | 5 ++--- mkfs/common.c | 1 - mkfs/rootdir.c | 1 - tests/fsstress.c | 25 ++++++++++++------------- tests/ioctl-test.c | 1 - 39 files changed, 21 insertions(+), 67 deletions(-)