The key values are unsigned, so comparing them using the difference
doesn't always work.
(Problem reported by [EMAIL PROTECTED])
Signed-off-by: Roman Zippel <[EMAIL PROTECTED]>
---
extent.c | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
Index: linux-2.6.11/fs/hfs/extent.c
===================================================================
--- linux-2.6.11.orig/fs/hfs/extent.c 2005-03-19 00:38:07.267382483 +0100
+++ linux-2.6.11/fs/hfs/extent.c 2005-03-19 00:38:19.796232389 +0100
@@ -49,22 +49,21 @@ static void hfs_ext_build_key(hfs_btree_
* This function has no side-effects */
int hfs_ext_keycmp(const btree_key *key1, const btree_key *key2)
{
- unsigned int tmp;
- int retval;
+ __be32 fnum1, fnum2;
+ __be16 block1, block2;
- tmp = be32_to_cpu(key1->ext.FNum) - be32_to_cpu(key2->ext.FNum);
- if (tmp != 0) {
- retval = (int)tmp;
- } else {
- tmp = (unsigned char)key1->ext.FkType - (unsigned
char)key2->ext.FkType;
- if (tmp != 0) {
- retval = (int)tmp;
- } else {
- retval = (int)(be16_to_cpu(key1->ext.FABN)
- - be16_to_cpu(key2->ext.FABN));
- }
- }
- return retval;
+ fnum1 = key1->ext.FNum;
+ fnum2 = key2->ext.FNum;
+ if (fnum1 != fnum2)
+ return be32_to_cpu(fnum1) < be32_to_cpu(fnum2) ? -1 : 1;
+ if (key1->ext.FkType != key2->ext.FkType)
+ return key1->ext.FkType < key2->ext.FkType ? -1 : 1;
+
+ block1 = key1->ext.FABN;
+ block2 = key2->ext.FABN;
+ if (block1 == block2)
+ return 0;
+ return be16_to_cpu(block1) < be16_to_cpu(block2) ? -1 : 1;
}
/*
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html