From 47f5946c904989016aa79262de4a9d50e43080ff Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 5 Oct 2017 11:26:04 -0700 Subject: [PATCH] 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 --- kmod/src/lock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kmod/src/lock.c b/kmod/src/lock.c index 875ac62b..60efede4 100644 --- a/kmod/src/lock.c +++ b/kmod/src/lock.c @@ -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,