scoutfs: fix lock name comparison

The lock name comparison had a typo where it didn't compare the second
fields between the two names.  Only inode index items used the second
field.  This bug could cause lock matching when the names don't match
and trigger lock coverage warnings.

While we're in there don't rely so heavily on readers knowing the
relative precedence of subtraction and (magical gcc empty) ternary
operators.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-10-09 15:31:29 -07:00
committed by Mark Fasheh
parent 950436461a
commit 47f5946c90
+4 -4
View File
@@ -242,11 +242,11 @@ static struct scoutfs_lock *alloc_scoutfs_lock(struct super_block *sb,
static int cmp_lock_names(struct scoutfs_lock_name *a,
struct scoutfs_lock_name *b)
{
return (int)a->scope - (int)b->scope ?:
(int)a->zone - (int)b->zone ?:
(int)a->type - (int)b->type ?:
return ((int)a->scope - (int)b->scope) ?:
((int)a->zone - (int)b->zone) ?:
((int)a->type - (int)b->type) ?:
scoutfs_cmp_u64s(le64_to_cpu(a->first), le64_to_cpu(b->first)) ?:
scoutfs_cmp_u64s(le64_to_cpu(b->second), le64_to_cpu(b->second));
scoutfs_cmp_u64s(le64_to_cpu(a->second), le64_to_cpu(b->second));
}
static struct scoutfs_lock *find_alloc_scoutfs_lock(struct super_block *sb,