diff options
author | Leon Romanovsky <leon@leon.nu> | 2012-12-27 12:55:46 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2012-12-27 21:27:53 -0500 |
commit | 9836b8b9499cb25ea32cad9fff640eef874c5431 (patch) | |
tree | b7d05ce46e6b1f86aea3794ba7b0eddf9db8c9bd /fs/f2fs | |
parent | 2b50638decdb9a8585654a5acf1c8ce5962f1951 (diff) |
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: Leon Romanovsky <leon@leon.nu>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/dir.c | 10 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 2 | ||||
-rw-r--r-- | fs/f2fs/hash.c | 10 | ||||
-rw-r--r-- | fs/f2fs/namei.c | 6 | ||||
-rw-r--r-- | fs/f2fs/xattr.c | 5 |
5 files changed, 18 insertions, 15 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 4a78d6c4f3a7..951ed52748f6 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -75,7 +75,7 @@ static unsigned long dir_block_index(unsigned int level, unsigned int idx) | |||
75 | return bidx; | 75 | return bidx; |
76 | } | 76 | } |
77 | 77 | ||
78 | static bool early_match_name(const char *name, int namelen, | 78 | static bool early_match_name(const char *name, size_t namelen, |
79 | f2fs_hash_t namehash, struct f2fs_dir_entry *de) | 79 | f2fs_hash_t namehash, struct f2fs_dir_entry *de) |
80 | { | 80 | { |
81 | if (le16_to_cpu(de->name_len) != namelen) | 81 | if (le16_to_cpu(de->name_len) != namelen) |
@@ -88,7 +88,7 @@ static bool early_match_name(const char *name, int namelen, | |||
88 | } | 88 | } |
89 | 89 | ||
90 | static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, | 90 | static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, |
91 | const char *name, int namelen, int *max_slots, | 91 | const char *name, size_t namelen, int *max_slots, |
92 | f2fs_hash_t namehash, struct page **res_page) | 92 | f2fs_hash_t namehash, struct page **res_page) |
93 | { | 93 | { |
94 | struct f2fs_dir_entry *de; | 94 | struct f2fs_dir_entry *de; |
@@ -127,7 +127,7 @@ found: | |||
127 | } | 127 | } |
128 | 128 | ||
129 | static struct f2fs_dir_entry *find_in_level(struct inode *dir, | 129 | static struct f2fs_dir_entry *find_in_level(struct inode *dir, |
130 | unsigned int level, const char *name, int namelen, | 130 | unsigned int level, const char *name, size_t namelen, |
131 | f2fs_hash_t namehash, struct page **res_page) | 131 | f2fs_hash_t namehash, struct page **res_page) |
132 | { | 132 | { |
133 | int s = GET_DENTRY_SLOTS(namelen); | 133 | int s = GET_DENTRY_SLOTS(namelen); |
@@ -182,7 +182,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, | |||
182 | struct qstr *child, struct page **res_page) | 182 | struct qstr *child, struct page **res_page) |
183 | { | 183 | { |
184 | const char *name = child->name; | 184 | const char *name = child->name; |
185 | int namelen = child->len; | 185 | size_t namelen = child->len; |
186 | unsigned long npages = dir_blocks(dir); | 186 | unsigned long npages = dir_blocks(dir); |
187 | struct f2fs_dir_entry *de = NULL; | 187 | struct f2fs_dir_entry *de = NULL; |
188 | f2fs_hash_t name_hash; | 188 | f2fs_hash_t name_hash; |
@@ -383,7 +383,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode) | |||
383 | struct inode *dir = dentry->d_parent->d_inode; | 383 | struct inode *dir = dentry->d_parent->d_inode; |
384 | struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); | 384 | struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
385 | const char *name = dentry->d_name.name; | 385 | const char *name = dentry->d_name.name; |
386 | int namelen = dentry->d_name.len; | 386 | size_t namelen = dentry->d_name.len; |
387 | struct page *dentry_page = NULL; | 387 | struct page *dentry_page = NULL; |
388 | struct f2fs_dentry_block *dentry_blk = NULL; | 388 | struct f2fs_dentry_block *dentry_blk = NULL; |
389 | int slots = GET_DENTRY_SLOTS(namelen); | 389 | int slots = GET_DENTRY_SLOTS(namelen); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index a18d63db2fb6..13c6dfbb7183 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -881,7 +881,7 @@ int f2fs_sync_fs(struct super_block *, int); | |||
881 | /* | 881 | /* |
882 | * hash.c | 882 | * hash.c |
883 | */ | 883 | */ |
884 | f2fs_hash_t f2fs_dentry_hash(const char *, int); | 884 | f2fs_hash_t f2fs_dentry_hash(const char *, size_t); |
885 | 885 | ||
886 | /* | 886 | /* |
887 | * node.c | 887 | * node.c |
diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c index 6977415c52fc..6eb8d269b53b 100644 --- a/fs/f2fs/hash.c +++ b/fs/f2fs/hash.c | |||
@@ -42,7 +42,7 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[]) | |||
42 | buf[1] += b1; | 42 | buf[1] += b1; |
43 | } | 43 | } |
44 | 44 | ||
45 | static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) | 45 | static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num) |
46 | { | 46 | { |
47 | unsigned pad, val; | 47 | unsigned pad, val; |
48 | int i; | 48 | int i; |
@@ -69,7 +69,7 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num) | |||
69 | *buf++ = pad; | 69 | *buf++ = pad; |
70 | } | 70 | } |
71 | 71 | ||
72 | f2fs_hash_t f2fs_dentry_hash(const char *name, int len) | 72 | f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len) |
73 | { | 73 | { |
74 | __u32 hash; | 74 | __u32 hash; |
75 | f2fs_hash_t f2fs_hash; | 75 | f2fs_hash_t f2fs_hash; |
@@ -87,11 +87,13 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len) | |||
87 | buf[3] = 0x10325476; | 87 | buf[3] = 0x10325476; |
88 | 88 | ||
89 | p = name; | 89 | p = name; |
90 | while (len > 0) { | 90 | while (1) { |
91 | str2hashbuf(p, len, in, 4); | 91 | str2hashbuf(p, len, in, 4); |
92 | TEA_transform(buf, in); | 92 | TEA_transform(buf, in); |
93 | len -= 16; | ||
94 | p += 16; | 93 | p += 16; |
94 | if (len <= 16) | ||
95 | break; | ||
96 | len -= 16; | ||
95 | } | 97 | } |
96 | hash = buf[0]; | 98 | hash = buf[0]; |
97 | f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); | 99 | f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); |
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index b42389f80011..1a49b881bac0 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -77,8 +77,8 @@ fail: | |||
77 | 77 | ||
78 | static int is_multimedia_file(const unsigned char *s, const char *sub) | 78 | static int is_multimedia_file(const unsigned char *s, const char *sub) |
79 | { | 79 | { |
80 | int slen = strlen(s); | 80 | size_t slen = strlen(s); |
81 | int sublen = strlen(sub); | 81 | size_t sublen = strlen(sub); |
82 | int ret; | 82 | int ret; |
83 | 83 | ||
84 | if (sublen > slen) | 84 | if (sublen > slen) |
@@ -250,7 +250,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, | |||
250 | struct super_block *sb = dir->i_sb; | 250 | struct super_block *sb = dir->i_sb; |
251 | struct f2fs_sb_info *sbi = F2FS_SB(sb); | 251 | struct f2fs_sb_info *sbi = F2FS_SB(sb); |
252 | struct inode *inode; | 252 | struct inode *inode; |
253 | unsigned symlen = strlen(symname) + 1; | 253 | size_t symlen = strlen(symname) + 1; |
254 | int err; | 254 | int err; |
255 | 255 | ||
256 | f2fs_balance_fs(sbi); | 256 | f2fs_balance_fs(sbi); |
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 7d52e8dc0c59..940136a3d3a6 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -208,7 +208,7 @@ int f2fs_getxattr(struct inode *inode, int name_index, const char *name, | |||
208 | struct page *page; | 208 | struct page *page; |
209 | void *base_addr; | 209 | void *base_addr; |
210 | int error = 0, found = 0; | 210 | int error = 0, found = 0; |
211 | int value_len, name_len; | 211 | size_t value_len, name_len; |
212 | 212 | ||
213 | if (name == NULL) | 213 | if (name == NULL) |
214 | return -EINVAL; | 214 | return -EINVAL; |
@@ -304,7 +304,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
304 | struct f2fs_xattr_entry *here, *last; | 304 | struct f2fs_xattr_entry *here, *last; |
305 | struct page *page; | 305 | struct page *page; |
306 | void *base_addr; | 306 | void *base_addr; |
307 | int error, found, free, name_len, newsize; | 307 | int error, found, free, newsize; |
308 | size_t name_len; | ||
308 | char *pval; | 309 | char *pval; |
309 | 310 | ||
310 | if (name == NULL) | 311 | if (name == NULL) |