linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 3/3] lib: use u8/u32/u64 for bit operations
Date: Tue, 15 Dec 2015 13:19:34 -0800	[thread overview]
Message-ID: <1450214374-65696-3-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1450214374-65696-1-git-send-email-jaegeuk@kernel.org>

This cleans up the bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c       |  6 ++----
 include/f2fs_fs.h | 12 +++++-------
 lib/libf2fs.c     | 19 ++++++++-----------
 3 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 38391a9..3e67ffc 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -869,8 +869,7 @@ static void convert_encrypted_name(unsigned char *name, int len,
 }
 
 static void print_dentry(__u32 depth, __u8 *name,
-		unsigned char *bitmap,
-		struct f2fs_dir_entry *dentry,
+		u8 *bitmap, struct f2fs_dir_entry *dentry,
 		int max, int idx, int last_blk, int encrypted)
 {
 	int last_de = 0;
@@ -937,8 +936,7 @@ static int f2fs_check_hash_code(struct f2fs_dir_entry *dentry,
 }
 
 static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
-			unsigned char *bitmap,
-			struct f2fs_dir_entry *dentry,
+			u8 *bitmap, struct f2fs_dir_entry *dentry,
 			__u8 (*filenames)[F2FS_SLOT_LEN],
 			int max, int last_blk, int encrypted)
 {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index decc7f4..f9060f2 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -855,16 +855,14 @@ extern int log_base_2(u_int32_t);
 extern unsigned int addrs_per_inode(struct f2fs_inode *);
 
 extern int get_bits_in_byte(unsigned char n);
-extern int test_and_set_bit_le(unsigned int, unsigned char *);
-extern int test_and_clear_bit_le(unsigned int, unsigned char*);
-extern int test_bit_le(unsigned int, const unsigned char *);
+extern int test_and_set_bit_le(u32, u8 *);
+extern int test_and_clear_bit_le(u32, u8 *);
+extern int test_bit_le(u32, const u8 *);
 extern int f2fs_test_bit(unsigned int, const char *);
 extern int f2fs_set_bit(unsigned int, char *);
 extern int f2fs_clear_bit(unsigned int, char *);
-extern unsigned long find_next_bit_le(const unsigned char *, unsigned long,
-		unsigned long);
-extern unsigned long find_next_zero_bit_le(const unsigned char *, unsigned long,
-		unsigned long);
+extern unsigned long find_next_bit_le(const u8 *, u64, u64);
+extern unsigned long find_next_zero_bit_le(const u8 *, u64, u64);
 
 extern u_int32_t f2fs_cal_crc32(u_int32_t, void *, int);
 extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len);
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index ab98a11..e9a1606 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -234,7 +234,7 @@ int get_bits_in_byte(unsigned char n)
 	return bits_in_byte[n];
 }
 
-int test_and_set_bit_le(unsigned int nr, unsigned char *addr)
+int test_and_set_bit_le(u32 nr, u8 *addr)
 {
 	int mask, retval;
 
@@ -245,7 +245,7 @@ int test_and_set_bit_le(unsigned int nr, unsigned char *addr)
 	return retval;
 }
 
-int test_and_clear_bit_le(unsigned int nr, unsigned char *addr)
+int test_and_clear_bit_le(u32 nr, u8 *addr)
 {
 	int mask, retval;
 
@@ -256,7 +256,7 @@ int test_and_clear_bit_le(unsigned int nr, unsigned char *addr)
 	return retval;
 }
 
-int test_bit_le(unsigned int nr, const unsigned char *addr)
+int test_bit_le(u32 nr, const u8 *addr)
 {
 	return ((1 << (nr & 7)) & (addr[nr >> 3]));
 }
@@ -295,7 +295,7 @@ int f2fs_clear_bit(unsigned int nr, char *addr)
 	return ret;
 }
 
-static inline unsigned long __ffs(unsigned char word)
+static inline u64 __ffs(u8 word)
 {
 	int num = 0;
 
@@ -315,10 +315,9 @@ static inline unsigned long __ffs(unsigned char word)
 /* Copied from linux/lib/find_bit.c */
 #define BITMAP_FIRST_BYTE_MASK(start) (0xff << ((start) & (BITS_PER_BYTE - 1)))
 
-static unsigned long _find_next_bit_le(const unsigned char *addr,
-		unsigned long nbits, unsigned long start, char invert)
+static u64 _find_next_bit_le(const u8 *addr, u64 nbits, u64 start, char invert)
 {
-	unsigned char tmp;
+	u8 tmp;
 
 	if (!nbits || start >= nbits)
 		return nbits;
@@ -340,15 +339,13 @@ static unsigned long _find_next_bit_le(const unsigned char *addr,
 	return min(start + __ffs(tmp), nbits);
 }
 
-unsigned long find_next_bit_le(const unsigned char *addr, unsigned long size,
-		unsigned long offset)
+u64 find_next_bit_le(const u8 *addr, u64 size, u64 offset)
 {
 	return _find_next_bit_le(addr, size, offset, 0);
 }
 
 
-unsigned long find_next_zero_bit_le(const unsigned char *addr,
-		unsigned long size, unsigned long offset)
+u64 find_next_zero_bit_le(const u8 *addr, u64 size, u64 offset)
 {
 	return _find_next_bit_le(addr, size, offset, 0xff);
 }
-- 
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------

      parent reply	other threads:[~2015-12-15 21:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 21:19 [PATCH 1/3] mkfs.f2fs: remove extent_cache entry for parent directory Jaegeuk Kim
2015-12-15 21:19 ` [PATCH 2/3] lib: fix test_bit_le functions Jaegeuk Kim
2015-12-15 21:19 ` Jaegeuk Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450214374-65696-3-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).