[PATCH] erofs-utils: fix some style problems

Huang Jianan huangjianan at oppo.com
Fri Feb 18 14:11:37 AEDT 2022


Fix some minor issues, including:
  - Align with the left parenthesis;
  - Spelling mistakes;
  - Remove redundant spaces and parenthesis;
  - clean up file headers;
  - Match parameters with format parameters.

Signed-off-by: Huang Jianan <huangjianan at oppo.com>
---
 dump/main.c                | 53 +++++++++++++++++++-------------------
 fsck/main.c                |  4 +--
 fuse/main.c                |  1 -
 include/erofs/block_list.h |  4 +--
 include/erofs/defs.h       |  1 -
 include/erofs/dir.h        |  2 +-
 include/erofs/internal.h   |  2 +-
 include/erofs/list.h       |  1 -
 lib/blobchunk.c            |  2 +-
 lib/cache.c                |  1 -
 lib/compress.c             |  2 +-
 lib/compress_hints.c       |  2 +-
 lib/compressor_liblzma.c   |  5 ++--
 lib/data.c                 |  2 +-
 lib/dir.c                  |  2 +-
 lib/exclude.c              |  2 +-
 lib/inode.c                |  2 +-
 lib/io.c                   |  2 +-
 lib/liberofs_private.h     |  2 +-
 lib/namei.c                |  1 -
 lib/super.c                |  4 +--
 lib/xattr.c                |  4 +--
 mkfs/main.c                |  2 +-
 23 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index e6198a0..3f8c2f2 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -179,7 +179,7 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
 }
 
 static int erofsdump_get_occupied_size(struct erofs_inode *inode,
-		erofs_off_t *size)
+				       erofs_off_t *size)
 {
 	*size = 0;
 	switch (inode->datalayout) {
@@ -218,7 +218,7 @@ static void inc_file_extension_count(const char *dname, unsigned int len)
 }
 
 static void update_file_size_statatics(erofs_off_t occupied_size,
-		erofs_off_t original_size)
+				       erofs_off_t original_size)
 {
 	int occupied_size_mark, original_size_mark;
 
@@ -300,7 +300,7 @@ static int erofsdump_readdir(struct erofs_dir_context *ctx)
 }
 
 static int erofsdump_map_blocks(struct erofs_inode *inode,
-		struct erofs_map_blocks *map, int flags)
+				struct erofs_map_blocks *map, int flags)
 {
 	if (erofs_inode_is_data_compressed(inode->datalayout))
 		return z_erofs_map_blocks_iter(inode, map, flags);
@@ -383,7 +383,7 @@ static void erofsdump_show_fileinfo(bool show_extent)
 		struct erofs_map_dev mdev;
 
 		err = erofsdump_map_blocks(&inode, &map,
-				EROFS_GET_BLOCKS_FIEMAP);
+					   EROFS_GET_BLOCKS_FIEMAP);
 		if (err) {
 			erofs_err("failed to get file blocks range");
 			return;
@@ -409,7 +409,8 @@ static void erofsdump_show_fileinfo(bool show_extent)
 }
 
 static void erofsdump_filesize_distribution(const char *title,
-		unsigned int *file_counts, unsigned int len)
+					    unsigned int *file_counts,
+					    unsigned int len)
 {
 	char col1[30];
 	unsigned int col2, i, lowerbound, upperbound;
@@ -419,8 +420,7 @@ static void erofsdump_filesize_distribution(const char *title,
 	lowerbound = 0;
 	upperbound = 1;
 	fprintf(stdout, "\n%s file size distribution:\n", title);
-	fprintf(stdout, header_format, ">=(KB) .. <(KB) ", "count",
-			"ratio", "distribution");
+	fprintf(stdout, header_format, ">=(KB) .. <(KB) ", "count", "ratio", "distribution");
 	for (i = 0; i < len; i++) {
 		memset(col1, 0, sizeof(col1));
 		memset(col4, 0, sizeof(col4));
@@ -452,8 +452,7 @@ static void erofsdump_filetype_distribution(char **file_types, unsigned int len)
 	char col4[401];
 
 	fprintf(stdout, "\nFile type distribution:\n");
-	fprintf(stdout, header_format, "type", "count", "ratio",
-			"distribution");
+	fprintf(stdout, header_format, "type", "count", "ratio", "distribution");
 	for (i = 0; i < len; i++) {
 		memset(col1, 0, sizeof(col1));
 		memset(col4, 0, sizeof(col4));
@@ -480,17 +479,17 @@ static void erofsdump_file_statistic(void)
 			file_category_types[i], stats.file_category_stat[i]);
 
 	stats.compress_rate = (double)(100 * stats.files_total_size) /
-		(double)(stats.files_total_origin_size);
+			      (double)(stats.files_total_origin_size);
 	fprintf(stdout, "Filesystem compressed files:            %lu\n",
-			stats.compressed_files);
+		stats.compressed_files);
 	fprintf(stdout, "Filesystem uncompressed files:          %lu\n",
-			stats.uncompressed_files);
+		stats.uncompressed_files);
 	fprintf(stdout, "Filesystem total original file size:    %lu Bytes\n",
-			stats.files_total_origin_size);
+		stats.files_total_origin_size);
 	fprintf(stdout, "Filesystem total file size:             %lu Bytes\n",
-			stats.files_total_size);
+		stats.files_total_size);
 	fprintf(stdout, "Filesystem compress rate:               %.2f%%\n",
-			stats.compress_rate);
+		stats.compress_rate);
 }
 
 static void erofsdump_print_statistic(void)
@@ -513,11 +512,11 @@ static void erofsdump_print_statistic(void)
 	}
 	erofsdump_file_statistic();
 	erofsdump_filesize_distribution("Original",
-			stats.file_original_size,
-			ARRAY_SIZE(stats.file_original_size));
+					stats.file_original_size,
+					ARRAY_SIZE(stats.file_original_size));
 	erofsdump_filesize_distribution("On-disk",
-			stats.file_comp_size,
-			ARRAY_SIZE(stats.file_comp_size));
+					stats.file_comp_size,
+					ARRAY_SIZE(stats.file_comp_size));
 	erofsdump_filetype_distribution(file_types, OTHERFILETYPE);
 }
 
@@ -528,19 +527,19 @@ static void erofsdump_show_superblock(void)
 	int i = 0;
 
 	fprintf(stdout, "Filesystem magic number:                      0x%04X\n",
-			EROFS_SUPER_MAGIC_V1);
+		EROFS_SUPER_MAGIC_V1);
 	fprintf(stdout, "Filesystem blocks:                            %llu\n",
-			sbi.total_blocks | 0ULL);
+		sbi.total_blocks | 0ULL);
 	fprintf(stdout, "Filesystem inode metadata start block:        %u\n",
-			sbi.meta_blkaddr);
+		sbi.meta_blkaddr);
 	fprintf(stdout, "Filesystem shared xattr metadata start block: %u\n",
-			sbi.xattr_blkaddr);
+		sbi.xattr_blkaddr);
 	fprintf(stdout, "Filesystem root nid:                          %llu\n",
-			sbi.root_nid | 0ULL);
+		sbi.root_nid | 0ULL);
 	fprintf(stdout, "Filesystem inode count:                       %llu\n",
-			sbi.inos | 0ULL);
+		sbi.inos | 0ULL);
 	fprintf(stdout, "Filesystem created:                           %s",
-			ctime(&time));
+		ctime(&time));
 	fprintf(stdout, "Filesystem features:                          ");
 	for (; i < ARRAY_SIZE(feature_lists); i++) {
 		u32 feat = le32_to_cpu(feature_lists[i].compat ?
@@ -553,7 +552,7 @@ static void erofsdump_show_superblock(void)
 	uuid_unparse_lower(sbi.uuid, uuid_str);
 #endif
 	fprintf(stdout, "\nFilesystem UUID:                              %s\n",
-			uuid_str);
+		uuid_str);
 }
 
 int main(int argc, char **argv)
diff --git a/fsck/main.c b/fsck/main.c
index 56595e3..8fd23eb 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -396,10 +396,10 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
 		map.m_la = pos;
 		if (compressed)
 			ret = z_erofs_map_blocks_iter(inode, &map,
-					EROFS_GET_BLOCKS_FIEMAP);
+						      EROFS_GET_BLOCKS_FIEMAP);
 		else
 			ret = erofs_map_blocks(inode, &map,
-					EROFS_GET_BLOCKS_FIEMAP);
+					       EROFS_GET_BLOCKS_FIEMAP);
 		if (ret)
 			goto out;
 
diff --git a/fuse/main.c b/fuse/main.c
index b869a00..90ed611 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -61,7 +61,6 @@ int erofsfuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 #else
 	return erofs_iterate_dir(&ctx.ctx, true);
 #endif
-
 }
 
 static void *erofsfuse_init(struct fuse_conn_info *info)
diff --git a/include/erofs/block_list.h b/include/erofs/block_list.h
index 78fab44..9f195c8 100644
--- a/include/erofs/block_list.h
+++ b/include/erofs/block_list.h
@@ -25,10 +25,10 @@ void erofs_droid_blocklist_write_extent(struct erofs_inode *inode,
 					bool first_extent, bool last_extent);
 #else
 static inline void erofs_droid_blocklist_write(struct erofs_inode *inode,
-				 erofs_blk_t blk_start, erofs_blk_t nblocks) {}
+					       erofs_blk_t blk_start, erofs_blk_t nblocks) {}
 static inline void
 erofs_droid_blocklist_write_tail_end(struct erofs_inode *inode,
-					  erofs_blk_t blkaddr) {}
+				     erofs_blk_t blkaddr) {}
 static inline void
 erofs_droid_blocklist_write_extent(struct erofs_inode *inode,
 				   erofs_blk_t blk_start, erofs_blk_t nblocks,
diff --git a/include/erofs/defs.h b/include/erofs/defs.h
index e745bc0..e5aa23c 100644
--- a/include/erofs/defs.h
+++ b/include/erofs/defs.h
@@ -61,7 +61,6 @@ typedef int16_t         s16;
 typedef int32_t         s32;
 typedef int64_t         s64;
 
-
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 /*
  * The host byte order is the same as network byte order,
diff --git a/include/erofs/dir.h b/include/erofs/dir.h
index 1627d3d..74bffb5 100644
--- a/include/erofs/dir.h
+++ b/include/erofs/dir.h
@@ -42,7 +42,7 @@ struct erofs_dir_context {
 	/*
 	 * During execution of |erofs_iterate_dir|, the function needs to
 	 * read the values inside |erofs_inode* dir|. So it is important
-	 * that the callback function does not modify stuct pointed by
+	 * that the callback function does not modify struct pointed by
 	 * |dir|. It is OK to repoint |dir| to other objects.
 	 * Unfortunately, it's not possible to enforce this restriction
 	 * with const keyword, as |erofs_iterate_dir| needs to modify
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index d4efc18..4b22895 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -328,7 +328,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi);
 int erofs_pread(struct erofs_inode *inode, char *buf,
 		erofs_off_t count, erofs_off_t offset);
 int erofs_map_blocks(struct erofs_inode *inode,
-		struct erofs_map_blocks *map, int flags);
+		     struct erofs_map_blocks *map, int flags);
 int erofs_map_dev(struct erofs_sb_info *sbi, struct erofs_map_dev *map);
 
 static inline int erofs_get_occupied_size(const struct erofs_inode *inode,
diff --git a/include/erofs/list.h b/include/erofs/list.h
index 2a0e961..3f5da1a 100644
--- a/include/erofs/list.h
+++ b/include/erofs/list.h
@@ -110,7 +110,6 @@ static inline int list_empty(struct list_head *head)
 	     &pos->member != (head);                                           \
 	     pos = n, n = list_next_entry(n, member))
 
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index a145be9..4a440d6 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -29,7 +29,7 @@ static bool multidev;
 static struct erofs_buffer_head *bh_devt;
 
 static struct erofs_blobchunk *erofs_blob_getchunk(int fd,
-		unsigned int chunksize)
+						   unsigned int chunksize)
 {
 	static u8 zeroed[EROFS_BLKSIZ];
 	u8 *chunkdata, sha256[32];
diff --git a/lib/cache.c b/lib/cache.c
index f820c0b..c735363 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -331,7 +331,6 @@ struct erofs_buffer_head *erofs_battach(struct erofs_buffer_head *bh,
 		return ERR_PTR(ret);
 	}
 	return nbh;
-
 }
 
 static erofs_blk_t __erofs_mapbh(struct erofs_buffer_block *bb)
diff --git a/lib/compress.c b/lib/compress.c
index e050df0..df6411c 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -114,7 +114,7 @@ static void vle_write_indexes(struct z_erofs_vle_compress_ctx *ctx,
 			 */
 			if (d0 >= Z_EROFS_VLE_DI_D0_CBLKCNT)
 				di.di_u.delta[0] = cpu_to_le16(
-						Z_EROFS_VLE_DI_D0_CBLKCNT - 1);
+						   Z_EROFS_VLE_DI_D0_CBLKCNT - 1);
 			else
 				di.di_u.delta[0] = cpu_to_le16(d0);
 			di.di_u.delta[1] = cpu_to_le16(d1);
diff --git a/lib/compress_hints.c b/lib/compress_hints.c
index 25adf35..c3f3d48 100644
--- a/lib/compress_hints.c
+++ b/lib/compress_hints.c
@@ -29,7 +29,7 @@ static int erofs_insert_compress_hints(const char *s, unsigned int blks)
 	if (!r)
 		return -ENOMEM;
 
-	ret = regcomp(&r->reg, s, REG_EXTENDED|REG_NOSUB);
+	ret = regcomp(&r->reg, s, REG_EXTENDED | REG_NOSUB);
 	if (ret) {
 		dump_regerror(ret, s, &r->reg);
 		goto err_out;
diff --git a/lib/compressor_liblzma.c b/lib/compressor_liblzma.c
index acf442f..e0b5b44 100644
--- a/lib/compressor_liblzma.c
+++ b/lib/compressor_liblzma.c
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0
 /*
- * erofs-utils/lib/compressor_liblzma.c
- *
  * Copyright (C) 2021 Gao Xiang <xiang at kernel.org>
  */
 #include <stdlib.h>
@@ -24,8 +22,9 @@ static int erofs_liblzma_compress_destsize(const struct erofs_compress *c,
 {
 	struct erofs_liblzma_context *ctx = c->private_data;
 	lzma_stream *strm = &ctx->strm;
+	lzma_ret ret;
 
-	lzma_ret ret = lzma_microlzma_encoder(strm, &ctx->opt);
+	ret = lzma_microlzma_encoder(strm, &ctx->opt);
 	if (ret != LZMA_OK)
 		return -EFAULT;
 
diff --git a/lib/data.c b/lib/data.c
index e57707e..b338846 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -62,7 +62,7 @@ err_out:
 }
 
 int erofs_map_blocks(struct erofs_inode *inode,
-		struct erofs_map_blocks *map, int flags)
+		     struct erofs_map_blocks *map, int flags)
 {
 	struct erofs_inode *vi = inode;
 	struct erofs_inode_chunk_index *idx;
diff --git a/lib/dir.c b/lib/dir.c
index 8955931..7fefa6a 100644
--- a/lib/dir.c
+++ b/lib/dir.c
@@ -42,7 +42,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 		}
 
 		if (nameoff + de_namelen > maxsize ||
-				de_namelen > EROFS_NAME_LEN) {
+			de_namelen > EROFS_NAME_LEN) {
 			errmsg = "bogus dirent namelen";
 			break;
 		}
diff --git a/lib/exclude.c b/lib/exclude.c
index e3c4ed5..808d0c8 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -42,7 +42,7 @@ static struct erofs_exclude_rule *erofs_insert_exclude(const char *s,
 	}
 
 	if (is_regex) {
-		ret = regcomp(&r->reg, s, REG_EXTENDED|REG_NOSUB);
+		ret = regcomp(&r->reg, s, REG_EXTENDED | REG_NOSUB);
 		if (ret) {
 			dump_regerror(ret, s, &r->reg);
 			goto err_rule;
diff --git a/lib/inode.c b/lib/inode.c
index e680b23..5db4691 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1108,7 +1108,7 @@ fail:
 		d->type = ftype;
 
 		erofs_d_invalidate(d);
-		erofs_info("add file %s/%s (nid %llu, type %d)",
+		erofs_info("add file %s/%s (nid %llu, type %u)",
 			   dir->i_srcpath, d->name, (unsigned long long)d->nid,
 			   d->type);
 	}
diff --git a/lib/io.c b/lib/io.c
index 5bc3432..9c663c5 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -370,7 +370,7 @@ ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
 	ssize_t ret;
 
 	ret = copy_file_range(fd_in, &off64_in, fd_out, &off64_out,
-                              length, 0);
+			      length, 0);
 	if (ret >= 0)
 		goto out;
 	if (errno != ENOSYS) {
diff --git a/lib/liberofs_private.h b/lib/liberofs_private.h
index 0eeca3c..36f8ad4 100644
--- a/lib/liberofs_private.h
+++ b/lib/liberofs_private.h
@@ -19,7 +19,7 @@ static inline void *memrchr(const void *s, int c, size_t n)
 
 	for (p += n; n > 0; n--)
 		if (*--p == c)
-			return (void*)p;
+			return (void *)p;
 	return NULL;
 }
 #endif
diff --git a/lib/namei.c b/lib/namei.c
index 97f0f80..6163238 100644
--- a/lib/namei.c
+++ b/lib/namei.c
@@ -144,7 +144,6 @@ bogusimode:
 	return -EFSCORRUPTED;
 }
 
-
 struct erofs_dirent *find_target_dirent(erofs_nid_t pnid,
 					void *dentry_blk,
 					const char *name, unsigned int len,
diff --git a/lib/super.c b/lib/super.c
index 69522bd..f486eb7 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -15,7 +15,7 @@ static bool check_layout_compatibility(struct erofs_sb_info *sbi,
 	sbi->feature_incompat = feature;
 
 	/* check if current kernel meets all mandatory requirements */
-	if (feature & (~EROFS_ALL_FEATURE_INCOMPAT)) {
+	if (feature & ~EROFS_ALL_FEATURE_INCOMPAT) {
 		erofs_err("unidentified incompatible feature %x, please upgrade kernel version",
 			  feature & ~EROFS_ALL_FEATURE_INCOMPAT);
 		return false;
@@ -87,7 +87,7 @@ int erofs_read_superblock(void)
 	blkszbits = dsb->blkszbits;
 	/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
 	if (blkszbits != LOG_BLOCK_SIZE) {
-		erofs_err("blksize %u isn't supported on this platform",
+		erofs_err("blksize %d isn't supported on this platform",
 			  1 << blkszbits);
 		return ret;
 	}
diff --git a/lib/xattr.c b/lib/xattr.c
index 71ffe3e..49970e4 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -405,9 +405,9 @@ static int erofs_droid_xattr_set_caps(struct erofs_inode *inode)
 
 	memcpy(kvbuf, "capability", len[0]);
 	caps.magic_etc = VFS_CAP_REVISION_2 | VFS_CAP_FLAGS_EFFECTIVE;
-	caps.data[0].permitted = (u32) capabilities;
+	caps.data[0].permitted = (u32)capabilities;
 	caps.data[0].inheritable = 0;
-	caps.data[1].permitted = (u32) (capabilities >> 32);
+	caps.data[1].permitted = (u32)(capabilities >> 32);
 	caps.data[1].inheritable = 0;
 	memcpy(kvbuf + len[0], &caps, len[1]);
 
diff --git a/mkfs/main.c b/mkfs/main.c
index 282126a..0724212 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -204,7 +204,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 	bool quiet = false;
 
 	while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
-				 long_options, NULL)) != -1) {
+				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
 			if (!optarg) {
-- 
2.25.1



More information about the Linux-erofs mailing list