aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfs/bfind.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2008-02-06 04:37:10 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:05 -0500
commit55581d018ed3493d226e7a4d645d9c8a5af6c36b (patch)
treed687d90390073aeb0bda273b7b9f051a36f5d892 /fs/hfs/bfind.c
parent7c28cbaed6811260efc0134b984b924cd0ed46f5 (diff)
address hfs on-disk corruption robustness review comments
Address Roman's review comments for the previously sent on-disk corruption hfs robustness patch. - use 0 as a failure value, rather than making a new macro HFS_BAD_KEYLEN, and use a switch statement instead of if's. - Add new fail: target to __hfs_brec_find to skip assignments using bad values when exiting with a failure. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hfs/bfind.c')
-rw-r--r--fs/hfs/bfind.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index f8452a0eab56..4129cdb3f0d8 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -52,9 +52,9 @@ int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd)
52 rec = (e + b) / 2; 52 rec = (e + b) / 2;
53 len = hfs_brec_lenoff(bnode, rec, &off); 53 len = hfs_brec_lenoff(bnode, rec, &off);
54 keylen = hfs_brec_keylen(bnode, rec); 54 keylen = hfs_brec_keylen(bnode, rec);
55 if (keylen == HFS_BAD_KEYLEN) { 55 if (keylen == 0) {
56 res = -EINVAL; 56 res = -EINVAL;
57 goto done; 57 goto fail;
58 } 58 }
59 hfs_bnode_read(bnode, fd->key, off, keylen); 59 hfs_bnode_read(bnode, fd->key, off, keylen);
60 cmpval = bnode->tree->keycmp(fd->key, fd->search_key); 60 cmpval = bnode->tree->keycmp(fd->key, fd->search_key);
@@ -71,9 +71,9 @@ int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd)
71 if (rec != e && e >= 0) { 71 if (rec != e && e >= 0) {
72 len = hfs_brec_lenoff(bnode, e, &off); 72 len = hfs_brec_lenoff(bnode, e, &off);
73 keylen = hfs_brec_keylen(bnode, e); 73 keylen = hfs_brec_keylen(bnode, e);
74 if (keylen == HFS_BAD_KEYLEN) { 74 if (keylen == 0) {
75 res = -EINVAL; 75 res = -EINVAL;
76 goto done; 76 goto fail;
77 } 77 }
78 hfs_bnode_read(bnode, fd->key, off, keylen); 78 hfs_bnode_read(bnode, fd->key, off, keylen);
79 } 79 }
@@ -83,6 +83,7 @@ done:
83 fd->keylength = keylen; 83 fd->keylength = keylen;
84 fd->entryoffset = off + keylen; 84 fd->entryoffset = off + keylen;
85 fd->entrylength = len - keylen; 85 fd->entrylength = len - keylen;
86fail:
86 return res; 87 return res;
87} 88}
88 89
@@ -206,7 +207,7 @@ int hfs_brec_goto(struct hfs_find_data *fd, int cnt)
206 207
207 len = hfs_brec_lenoff(bnode, fd->record, &off); 208 len = hfs_brec_lenoff(bnode, fd->record, &off);
208 keylen = hfs_brec_keylen(bnode, fd->record); 209 keylen = hfs_brec_keylen(bnode, fd->record);
209 if (keylen == HFS_BAD_KEYLEN) { 210 if (keylen == 0) {
210 res = -EINVAL; 211 res = -EINVAL;
211 goto out; 212 goto out;
212 } 213 }