diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-02-17 16:46:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-17 17:34:52 -0500 |
commit | f157853e407c0611cd6acbc400fa6c7be420b1bd (patch) | |
tree | c8ee0adacfd4b798228d0ccd65de3f3ec0ce24d5 /fs/affs | |
parent | eeb36f8e938d151fc5e12e96ae13d0e283be357e (diff) |
fs/affs: define AFFSNAMEMAX to replace constant use
30 was used all over the place to compare name length against
AFFS maximum name length.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/affs')
-rw-r--r-- | fs/affs/affs.h | 2 | ||||
-rw-r--r-- | fs/affs/amigaffs.c | 6 | ||||
-rw-r--r-- | fs/affs/dir.c | 3 | ||||
-rw-r--r-- | fs/affs/namei.c | 16 | ||||
-rw-r--r-- | fs/affs/super.c | 2 |
5 files changed, 16 insertions, 13 deletions
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index ff44ff3ff015..c8764bd7497d 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -30,6 +30,8 @@ | |||
30 | #define AFFS_AC_SIZE (AFFS_CACHE_SIZE/sizeof(struct affs_ext_key)/2) | 30 | #define AFFS_AC_SIZE (AFFS_CACHE_SIZE/sizeof(struct affs_ext_key)/2) |
31 | #define AFFS_AC_MASK (AFFS_AC_SIZE-1) | 31 | #define AFFS_AC_MASK (AFFS_AC_SIZE-1) |
32 | 32 | ||
33 | #define AFFSNAMEMAX 30U | ||
34 | |||
33 | struct affs_ext_key { | 35 | struct affs_ext_key { |
34 | u32 ext; /* idx of the extended block */ | 36 | u32 ext; /* idx of the extended block */ |
35 | u32 key; /* block number */ | 37 | u32 key; /* block number */ |
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 0836f6fff641..118d782b041f 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c | |||
@@ -483,11 +483,11 @@ affs_check_name(const unsigned char *name, int len, bool notruncate) | |||
483 | { | 483 | { |
484 | int i; | 484 | int i; |
485 | 485 | ||
486 | if (len > 30) { | 486 | if (len > AFFSNAMEMAX) { |
487 | if (notruncate) | 487 | if (notruncate) |
488 | return -ENAMETOOLONG; | 488 | return -ENAMETOOLONG; |
489 | else | 489 | else |
490 | len = 30; | 490 | len = AFFSNAMEMAX; |
491 | } | 491 | } |
492 | for (i = 0; i < len; i++) { | 492 | for (i = 0; i < len; i++) { |
493 | if (name[i] < ' ' || name[i] == ':' | 493 | if (name[i] < ' ' || name[i] == ':' |
@@ -508,7 +508,7 @@ affs_check_name(const unsigned char *name, int len, bool notruncate) | |||
508 | int | 508 | int |
509 | affs_copy_name(unsigned char *bstr, struct dentry *dentry) | 509 | affs_copy_name(unsigned char *bstr, struct dentry *dentry) |
510 | { | 510 | { |
511 | u32 len = min(dentry->d_name.len, 30u); | 511 | u32 len = min(dentry->d_name.len, AFFSNAMEMAX); |
512 | 512 | ||
513 | *bstr++ = len; | 513 | *bstr++ = len; |
514 | memcpy(bstr, dentry->d_name.name, len); | 514 | memcpy(bstr, dentry->d_name.name, len); |
diff --git a/fs/affs/dir.c b/fs/affs/dir.c index a682892878a8..ac4f318aafba 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c | |||
@@ -114,7 +114,8 @@ inside: | |||
114 | break; | 114 | break; |
115 | } | 115 | } |
116 | 116 | ||
117 | namelen = min(AFFS_TAIL(sb, fh_bh)->name[0], (u8)30); | 117 | namelen = min(AFFS_TAIL(sb, fh_bh)->name[0], |
118 | (u8)AFFSNAMEMAX); | ||
118 | name = AFFS_TAIL(sb, fh_bh)->name + 1; | 119 | name = AFFS_TAIL(sb, fh_bh)->name + 1; |
119 | pr_debug("readdir(): dir_emit(\"%.*s\", ino=%u), hash=%d, f_pos=%llx\n", | 120 | pr_debug("readdir(): dir_emit(\"%.*s\", ino=%u), hash=%d, f_pos=%llx\n", |
120 | namelen, name, ino, hash_pos, ctx->pos); | 121 | namelen, name, ino, hash_pos, ctx->pos); |
diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 66c6cb349bf6..ffb7bd82c2a5 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c | |||
@@ -72,7 +72,7 @@ __affs_hash_dentry(struct qstr *qstr, toupper_t toupper, bool notruncate) | |||
72 | return retval; | 72 | return retval; |
73 | 73 | ||
74 | hash = init_name_hash(); | 74 | hash = init_name_hash(); |
75 | len = min(qstr->len, 30u); | 75 | len = min(qstr->len, AFFSNAMEMAX); |
76 | for (; len > 0; name++, len--) | 76 | for (; len > 0; name++, len--) |
77 | hash = partial_name_hash(toupper(*name), hash); | 77 | hash = partial_name_hash(toupper(*name), hash); |
78 | qstr->hash = end_name_hash(hash); | 78 | qstr->hash = end_name_hash(hash); |
@@ -115,10 +115,10 @@ static inline int __affs_compare_dentry(unsigned int len, | |||
115 | * If the names are longer than the allowed 30 chars, | 115 | * If the names are longer than the allowed 30 chars, |
116 | * the excess is ignored, so their length may differ. | 116 | * the excess is ignored, so their length may differ. |
117 | */ | 117 | */ |
118 | if (len >= 30) { | 118 | if (len >= AFFSNAMEMAX) { |
119 | if (name->len < 30) | 119 | if (name->len < AFFSNAMEMAX) |
120 | return 1; | 120 | return 1; |
121 | len = 30; | 121 | len = AFFSNAMEMAX; |
122 | } else if (len != name->len) | 122 | } else if (len != name->len) |
123 | return 1; | 123 | return 1; |
124 | 124 | ||
@@ -157,10 +157,10 @@ affs_match(struct dentry *dentry, const u8 *name2, toupper_t toupper) | |||
157 | const u8 *name = dentry->d_name.name; | 157 | const u8 *name = dentry->d_name.name; |
158 | int len = dentry->d_name.len; | 158 | int len = dentry->d_name.len; |
159 | 159 | ||
160 | if (len >= 30) { | 160 | if (len >= AFFSNAMEMAX) { |
161 | if (*name2 < 30) | 161 | if (*name2 < AFFSNAMEMAX) |
162 | return 0; | 162 | return 0; |
163 | len = 30; | 163 | len = AFFSNAMEMAX; |
164 | } else if (len != *name2) | 164 | } else if (len != *name2) |
165 | return 0; | 165 | return 0; |
166 | 166 | ||
@@ -176,7 +176,7 @@ affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len) | |||
176 | toupper_t toupper = affs_get_toupper(sb); | 176 | toupper_t toupper = affs_get_toupper(sb); |
177 | u32 hash; | 177 | u32 hash; |
178 | 178 | ||
179 | hash = len = min(len, 30u); | 179 | hash = len = min(len, AFFSNAMEMAX); |
180 | for (; len > 0; len--) | 180 | for (; len > 0; len--) |
181 | hash = (hash * 13 + toupper(*name++)) & 0x7ff; | 181 | hash = (hash * 13 + toupper(*name++)) & 0x7ff; |
182 | 182 | ||
diff --git a/fs/affs/super.c b/fs/affs/super.c index ee8eca7add0e..c3524bfdfe04 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -584,7 +584,7 @@ affs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
584 | buf->f_bavail = free; | 584 | buf->f_bavail = free; |
585 | buf->f_fsid.val[0] = (u32)id; | 585 | buf->f_fsid.val[0] = (u32)id; |
586 | buf->f_fsid.val[1] = (u32)(id >> 32); | 586 | buf->f_fsid.val[1] = (u32)(id >> 32); |
587 | buf->f_namelen = 30; | 587 | buf->f_namelen = AFFSNAMEMAX; |
588 | return 0; | 588 | return 0; |
589 | } | 589 | } |
590 | 590 | ||