Commit 9836b8b9 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jaegeuk Kim

f2fs: unify string length declarations and usage

This patch is intended to unify string length declarations and usage.
There are number of calls to strlen which return size_t object.
The size of this object depends on compiler if it will be bigger,
equal or even smaller than an unsigned int
Signed-off-by: default avatarLeon Romanovsky <leon@leon.nu>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent 2b50638d
...@@ -75,7 +75,7 @@ static unsigned long dir_block_index(unsigned int level, unsigned int idx) ...@@ -75,7 +75,7 @@ static unsigned long dir_block_index(unsigned int level, unsigned int idx)
return bidx; return bidx;
} }
static bool early_match_name(const char *name, int namelen, static bool early_match_name(const char *name, size_t namelen,
f2fs_hash_t namehash, struct f2fs_dir_entry *de) f2fs_hash_t namehash, struct f2fs_dir_entry *de)
{ {
if (le16_to_cpu(de->name_len) != namelen) if (le16_to_cpu(de->name_len) != namelen)
...@@ -88,7 +88,7 @@ static bool early_match_name(const char *name, int namelen, ...@@ -88,7 +88,7 @@ static bool early_match_name(const char *name, int namelen,
} }
static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
const char *name, int namelen, int *max_slots, const char *name, size_t namelen, int *max_slots,
f2fs_hash_t namehash, struct page **res_page) f2fs_hash_t namehash, struct page **res_page)
{ {
struct f2fs_dir_entry *de; struct f2fs_dir_entry *de;
...@@ -127,7 +127,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, ...@@ -127,7 +127,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
} }
static struct f2fs_dir_entry *find_in_level(struct inode *dir, static struct f2fs_dir_entry *find_in_level(struct inode *dir,
unsigned int level, const char *name, int namelen, unsigned int level, const char *name, size_t namelen,
f2fs_hash_t namehash, struct page **res_page) f2fs_hash_t namehash, struct page **res_page)
{ {
int s = GET_DENTRY_SLOTS(namelen); int s = GET_DENTRY_SLOTS(namelen);
...@@ -182,7 +182,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, ...@@ -182,7 +182,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
struct qstr *child, struct page **res_page) struct qstr *child, struct page **res_page)
{ {
const char *name = child->name; const char *name = child->name;
int namelen = child->len; size_t namelen = child->len;
unsigned long npages = dir_blocks(dir); unsigned long npages = dir_blocks(dir);
struct f2fs_dir_entry *de = NULL; struct f2fs_dir_entry *de = NULL;
f2fs_hash_t name_hash; f2fs_hash_t name_hash;
...@@ -383,7 +383,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -383,7 +383,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
struct inode *dir = dentry->d_parent->d_inode; struct inode *dir = dentry->d_parent->d_inode;
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
const char *name = dentry->d_name.name; const char *name = dentry->d_name.name;
int namelen = dentry->d_name.len; size_t namelen = dentry->d_name.len;
struct page *dentry_page = NULL; struct page *dentry_page = NULL;
struct f2fs_dentry_block *dentry_blk = NULL; struct f2fs_dentry_block *dentry_blk = NULL;
int slots = GET_DENTRY_SLOTS(namelen); int slots = GET_DENTRY_SLOTS(namelen);
......
...@@ -881,7 +881,7 @@ int f2fs_sync_fs(struct super_block *, int); ...@@ -881,7 +881,7 @@ int f2fs_sync_fs(struct super_block *, int);
/* /*
* hash.c * hash.c
*/ */
f2fs_hash_t f2fs_dentry_hash(const char *, int); f2fs_hash_t f2fs_dentry_hash(const char *, size_t);
/* /*
* node.c * node.c
......
...@@ -42,7 +42,7 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[]) ...@@ -42,7 +42,7 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[])
buf[1] += b1; buf[1] += b1;
} }
static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num)
{ {
unsigned pad, val; unsigned pad, val;
int i; int i;
...@@ -69,7 +69,7 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) ...@@ -69,7 +69,7 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num)
*buf++ = pad; *buf++ = pad;
} }
f2fs_hash_t f2fs_dentry_hash(const char *name, int len) f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len)
{ {
__u32 hash; __u32 hash;
f2fs_hash_t f2fs_hash; f2fs_hash_t f2fs_hash;
...@@ -87,11 +87,13 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len) ...@@ -87,11 +87,13 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
buf[3] = 0x10325476; buf[3] = 0x10325476;
p = name; p = name;
while (len > 0) { while (1) {
str2hashbuf(p, len, in, 4); str2hashbuf(p, len, in, 4);
TEA_transform(buf, in); TEA_transform(buf, in);
len -= 16;
p += 16; p += 16;
if (len <= 16)
break;
len -= 16;
} }
hash = buf[0]; hash = buf[0];
f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT);
......
...@@ -77,8 +77,8 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -77,8 +77,8 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
static int is_multimedia_file(const unsigned char *s, const char *sub) static int is_multimedia_file(const unsigned char *s, const char *sub)
{ {
int slen = strlen(s); size_t slen = strlen(s);
int sublen = strlen(sub); size_t sublen = strlen(sub);
int ret; int ret;
if (sublen > slen) if (sublen > slen)
...@@ -250,7 +250,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -250,7 +250,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;
struct f2fs_sb_info *sbi = F2FS_SB(sb); struct f2fs_sb_info *sbi = F2FS_SB(sb);
struct inode *inode; struct inode *inode;
unsigned symlen = strlen(symname) + 1; size_t symlen = strlen(symname) + 1;
int err; int err;
f2fs_balance_fs(sbi); f2fs_balance_fs(sbi);
......
...@@ -208,7 +208,7 @@ int f2fs_getxattr(struct inode *inode, int name_index, const char *name, ...@@ -208,7 +208,7 @@ int f2fs_getxattr(struct inode *inode, int name_index, const char *name,
struct page *page; struct page *page;
void *base_addr; void *base_addr;
int error = 0, found = 0; int error = 0, found = 0;
int value_len, name_len; size_t value_len, name_len;
if (name == NULL) if (name == NULL)
return -EINVAL; return -EINVAL;
...@@ -304,7 +304,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, ...@@ -304,7 +304,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
struct f2fs_xattr_entry *here, *last; struct f2fs_xattr_entry *here, *last;
struct page *page; struct page *page;
void *base_addr; void *base_addr;
int error, found, free, name_len, newsize; int error, found, free, newsize;
size_t name_len;
char *pval; char *pval;
if (name == NULL) if (name == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment