summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-11-29 18:04:08 -0500
committerJeff Layton <jlayton@kernel.org>2018-12-07 06:49:24 -0500
commitc0e15908979d269a8263b0c0a222b894b9f403e9 (patch)
tree07dd4976b69a6e4c98a83f0adf6fca2140474df4 /fs
parent16306a61d3b7c433c7a127ec6224867b88ece687 (diff)
fs/locks: change all *_conflict() functions to return bool.
posix_locks_conflict() and flock_locks_conflict() both return int. leases_conflict() returns bool. This inconsistency will cause problems for the next patch if not fixed. So change posix_locks_conflict() and flock_locks_conflict() to return bool. Also change the locks_conflict() helper. And convert some return (foo); to return foo; Signed-off-by: NeilBrown <neilb@suse.com> Reviewed-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/fs/locks.c b/fs/locks.c
index f2fa1465046b..c5f35910c57a 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -816,47 +816,50 @@ locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose)
816/* Determine if lock sys_fl blocks lock caller_fl. Common functionality 816/* Determine if lock sys_fl blocks lock caller_fl. Common functionality
817 * checks for shared/exclusive status of overlapping locks. 817 * checks for shared/exclusive status of overlapping locks.
818 */ 818 */
819static int locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) 819static bool locks_conflict(struct file_lock *caller_fl,
820 struct file_lock *sys_fl)
820{ 821{
821 if (sys_fl->fl_type == F_WRLCK) 822 if (sys_fl->fl_type == F_WRLCK)
822 return 1; 823 return true;
823 if (caller_fl->fl_type == F_WRLCK) 824 if (caller_fl->fl_type == F_WRLCK)
824 return 1; 825 return true;
825 return 0; 826 return false;
826} 827}
827 828
828/* Determine if lock sys_fl blocks lock caller_fl. POSIX specific 829/* Determine if lock sys_fl blocks lock caller_fl. POSIX specific
829 * checking before calling the locks_conflict(). 830 * checking before calling the locks_conflict().
830 */ 831 */
831static int posix_locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) 832static bool posix_locks_conflict(struct file_lock *caller_fl,
833 struct file_lock *sys_fl)
832{ 834{
833 /* POSIX locks owned by the same process do not conflict with 835 /* POSIX locks owned by the same process do not conflict with
834 * each other. 836 * each other.
835 */ 837 */
836 if (posix_same_owner(caller_fl, sys_fl)) 838 if (posix_same_owner(caller_fl, sys_fl))
837 return (0); 839 return false;
838 840
839 /* Check whether they overlap */ 841 /* Check whether they overlap */
840 if (!locks_overlap(caller_fl, sys_fl)) 842 if (!locks_overlap(caller_fl, sys_fl))
841 return 0; 843 return false;
842 844
843 return (locks_conflict(caller_fl, sys_fl)); 845 return locks_conflict(caller_fl, sys_fl);
844} 846}
845 847
846/* Determine if lock sys_fl blocks lock caller_fl. FLOCK specific 848/* Determine if lock sys_fl blocks lock caller_fl. FLOCK specific
847 * checking before calling the locks_conflict(). 849 * checking before calling the locks_conflict().
848 */ 850 */
849static int flock_locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) 851static bool flock_locks_conflict(struct file_lock *caller_fl,
852 struct file_lock *sys_fl)
850{ 853{
851 /* FLOCK locks referring to the same filp do not conflict with 854 /* FLOCK locks referring to the same filp do not conflict with
852 * each other. 855 * each other.
853 */ 856 */
854 if (caller_fl->fl_file == sys_fl->fl_file) 857 if (caller_fl->fl_file == sys_fl->fl_file)
855 return (0); 858 return false;
856 if ((caller_fl->fl_type & LOCK_MAND) || (sys_fl->fl_type & LOCK_MAND)) 859 if ((caller_fl->fl_type & LOCK_MAND) || (sys_fl->fl_type & LOCK_MAND))
857 return 0; 860 return false;
858 861
859 return (locks_conflict(caller_fl, sys_fl)); 862 return locks_conflict(caller_fl, sys_fl);
860} 863}
861 864
862void 865void