Blame SOURCES/0061-fs-ntfs3-Use-clamp-max-macros-instead-of-comparisons.patch

Kmods SIG 8b815c
From b5322eb1ae94572f5a52e804857e641b846059f4 Mon Sep 17 00:00:00 2001
Kmods SIG 8b815c
From: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 8b815c
Date: Tue, 7 Sep 2021 17:28:41 +0300
Kmods SIG 8b815c
Subject: [Backport b5322eb1ae94] src: Use clamp/max macros instead of
Kmods SIG 8b815c
 comparisons
Kmods SIG 8b815c
Kmods SIG 8b815c
We can make code little more readable by using kernel macros clamp/max.
Kmods SIG 8b815c
Kmods SIG 8b815c
This were found with kernel included Coccinelle minmax script.
Kmods SIG 8b815c
Kmods SIG 8b815c
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 8b815c
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Kmods SIG 8b815c
---
Kmods SIG 8b815c
 src/fsntfs.c | 8 +++-----
Kmods SIG 8b815c
 1 file changed, 3 insertions(+), 5 deletions(-)
Kmods SIG 8b815c
Kmods SIG 8b815c
diff --git a/src/fsntfs.c b/src/fsntfs.c
Kmods SIG 8b815c
index 4cd24e4e58ff26b3ddce5f891783a36cca6170a7..c964d3996aab1dff3923337acaa00e40869a70f5 100644
Kmods SIG 8b815c
--- a/src/fsntfs.c
Kmods SIG 8b815c
+++ b/src/fsntfs.c
Kmods SIG 8b815c
@@ -8,6 +8,7 @@
Kmods SIG 8b815c
 #include <linux/blkdev.h>
Kmods SIG 8b815c
 #include <linux/buffer_head.h>
Kmods SIG 8b815c
 #include <linux/fs.h>
Kmods SIG 8b815c
+#include <linux/kernel.h>
Kmods SIG 8b815c
 
Kmods SIG 8b815c
 #include "debug.h"
Kmods SIG 8b815c
 #include "ntfs.h"
Kmods SIG 8b815c
@@ -419,11 +420,8 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
Kmods SIG 8b815c
 	/* How many clusters to cat from zone. */
Kmods SIG 8b815c
 	zlcn = wnd_zone_bit(wnd);
Kmods SIG 8b815c
 	zlen2 = zlen >> 1;
Kmods SIG 8b815c
-	ztrim = len > zlen ? zlen : (len > zlen2 ? len : zlen2);
Kmods SIG 8b815c
-	new_zlen = zlen - ztrim;
Kmods SIG 8b815c
-
Kmods SIG 8b815c
-	if (new_zlen < NTFS_MIN_MFT_ZONE)
Kmods SIG 8b815c
-		new_zlen = NTFS_MIN_MFT_ZONE;
Kmods SIG 8b815c
+	ztrim = clamp_val(len, zlen2, zlen);
Kmods SIG 8b815c
+	new_zlen = max_t(size_t, zlen - ztrim, NTFS_MIN_MFT_ZONE);
Kmods SIG 8b815c
 
Kmods SIG 8b815c
 	wnd_zone_set(wnd, zlcn, new_zlen);
Kmods SIG 8b815c
 
Kmods SIG 8b815c
-- 
Kmods SIG 8b815c
2.31.1
Kmods SIG 8b815c