|
Kmods SIG |
d83023 |
From 6e3331ee34461be37f50912295a2e924a673dbc6 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
d83023 |
From: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
d83023 |
Date: Tue, 7 Sep 2021 17:28:42 +0300
|
|
Kmods SIG |
d83023 |
Subject: [Backport 6e3331ee3446] src: Use min/max macros instated of
|
|
Kmods SIG |
d83023 |
ternary operators
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
We can make code little bit more readable by using min/max macros.
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
These were found with Coccinelle.
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
d83023 |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
d83023 |
---
|
|
Kmods SIG |
d83023 |
src/attrib.c | 3 ++-
|
|
Kmods SIG |
d83023 |
src/bitmap.c | 11 ++++++-----
|
|
Kmods SIG |
d83023 |
src/fsntfs.c | 6 +++---
|
|
Kmods SIG |
d83023 |
3 files changed, 11 insertions(+), 9 deletions(-)
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
diff --git a/src/attrib.c b/src/attrib.c
|
|
Kmods SIG |
d83023 |
index 12cff28f3e7155231e56864792dd764487297f37..c15cc17e3cd92864f30fd0d3fbb8f20b98437cde 100644
|
|
Kmods SIG |
d83023 |
--- a/src/attrib.c
|
|
Kmods SIG |
d83023 |
+++ b/src/attrib.c
|
|
Kmods SIG |
d83023 |
@@ -8,6 +8,7 @@
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
#include <linux/fs.h>
|
|
Kmods SIG |
d83023 |
#include <linux/slab.h>
|
|
Kmods SIG |
d83023 |
+#include <linux/kernel.h>
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
#include "debug.h"
|
|
Kmods SIG |
d83023 |
#include "ntfs.h"
|
|
Kmods SIG |
d83023 |
@@ -1961,7 +1962,7 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
|
|
Kmods SIG |
d83023 |
return 0;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
from = vbo;
|
|
Kmods SIG |
d83023 |
- to = (vbo + bytes) < data_size ? (vbo + bytes) : data_size;
|
|
Kmods SIG |
d83023 |
+ to = min_t(u64, vbo + bytes, data_size);
|
|
Kmods SIG |
d83023 |
memset(Add2Ptr(resident_data(attr_b), from), 0, to - from);
|
|
Kmods SIG |
d83023 |
return 0;
|
|
Kmods SIG |
d83023 |
}
|
|
Kmods SIG |
d83023 |
diff --git a/src/bitmap.c b/src/bitmap.c
|
|
Kmods SIG |
d83023 |
index a03584674fea13c818f341f8f2a5147957507709..aa184407520f0263844839e03d2f1edde3c6628f 100644
|
|
Kmods SIG |
d83023 |
--- a/src/bitmap.c
|
|
Kmods SIG |
d83023 |
+++ b/src/bitmap.c
|
|
Kmods SIG |
d83023 |
@@ -12,6 +12,7 @@
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
#include <linux/buffer_head.h>
|
|
Kmods SIG |
d83023 |
#include <linux/fs.h>
|
|
Kmods SIG |
d83023 |
+#include <linux/kernel.h>
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
#include "ntfs.h"
|
|
Kmods SIG |
d83023 |
#include "ntfs_fs.h"
|
|
Kmods SIG |
d83023 |
@@ -432,7 +433,7 @@ static void wnd_remove_free_ext(struct wnd_bitmap *wnd, size_t bit, size_t len)
|
|
Kmods SIG |
d83023 |
;
|
|
Kmods SIG |
d83023 |
} else {
|
|
Kmods SIG |
d83023 |
n3 = rb_next(&e->count.node);
|
|
Kmods SIG |
d83023 |
- max_new_len = len > new_len ? len : new_len;
|
|
Kmods SIG |
d83023 |
+ max_new_len = max(len, new_len);
|
|
Kmods SIG |
d83023 |
if (!n3) {
|
|
Kmods SIG |
d83023 |
wnd->extent_max = max_new_len;
|
|
Kmods SIG |
d83023 |
} else {
|
|
Kmods SIG |
d83023 |
@@ -728,7 +729,7 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|
Kmods SIG |
d83023 |
wbits = wnd->bits_last;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
tail = wbits - wbit;
|
|
Kmods SIG |
d83023 |
- op = tail < bits ? tail : bits;
|
|
Kmods SIG |
d83023 |
+ op = min_t(u32, tail, bits);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
bh = wnd_map(wnd, iw);
|
|
Kmods SIG |
d83023 |
if (IS_ERR(bh)) {
|
|
Kmods SIG |
d83023 |
@@ -781,7 +782,7 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|
Kmods SIG |
d83023 |
wbits = wnd->bits_last;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
tail = wbits - wbit;
|
|
Kmods SIG |
d83023 |
- op = tail < bits ? tail : bits;
|
|
Kmods SIG |
d83023 |
+ op = min_t(u32, tail, bits);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
bh = wnd_map(wnd, iw);
|
|
Kmods SIG |
d83023 |
if (IS_ERR(bh)) {
|
|
Kmods SIG |
d83023 |
@@ -831,7 +832,7 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|
Kmods SIG |
d83023 |
wbits = wnd->bits_last;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
tail = wbits - wbit;
|
|
Kmods SIG |
d83023 |
- op = tail < bits ? tail : bits;
|
|
Kmods SIG |
d83023 |
+ op = min_t(u32, tail, bits);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
if (wbits != wnd->free_bits[iw]) {
|
|
Kmods SIG |
d83023 |
bool ret;
|
|
Kmods SIG |
d83023 |
@@ -923,7 +924,7 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|
Kmods SIG |
d83023 |
wbits = wnd->bits_last;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
tail = wbits - wbit;
|
|
Kmods SIG |
d83023 |
- op = tail < bits ? tail : bits;
|
|
Kmods SIG |
d83023 |
+ op = min_t(u32, tail, bits);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
if (wnd->free_bits[iw]) {
|
|
Kmods SIG |
d83023 |
bool ret;
|
|
Kmods SIG |
d83023 |
diff --git a/src/fsntfs.c b/src/fsntfs.c
|
|
Kmods SIG |
d83023 |
index c964d3996aab1dff3923337acaa00e40869a70f5..77d2e56d5b4f34a693765d3230cf032122a04239 100644
|
|
Kmods SIG |
d83023 |
--- a/src/fsntfs.c
|
|
Kmods SIG |
d83023 |
+++ b/src/fsntfs.c
|
|
Kmods SIG |
d83023 |
@@ -382,7 +382,7 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
|
|
Kmods SIG |
d83023 |
}
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
lcn = wnd_zone_bit(wnd);
|
|
Kmods SIG |
d83023 |
- alen = zlen > len ? len : zlen;
|
|
Kmods SIG |
d83023 |
+ alen = min_t(CLST, len, zlen);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
wnd_zone_set(wnd, lcn + alen, zlen - alen);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
@@ -1096,7 +1096,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
|
|
Kmods SIG |
d83023 |
len = ((u64)clen << cluster_bits) - off;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
for (;;) {
|
|
Kmods SIG |
d83023 |
- u32 op = len < bytes ? len : bytes;
|
|
Kmods SIG |
d83023 |
+ u32 op = min_t(u64, len, bytes);
|
|
Kmods SIG |
d83023 |
int err = ntfs_sb_write(sb, lbo, op, buf, 0);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
if (err)
|
|
Kmods SIG |
d83023 |
@@ -1297,7 +1297,7 @@ int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
|
|
Kmods SIG |
d83023 |
nb->off = off = lbo & (blocksize - 1);
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
for (;;) {
|
|
Kmods SIG |
d83023 |
- u32 len32 = len < bytes ? len : bytes;
|
|
Kmods SIG |
d83023 |
+ u32 len32 = min_t(u64, len, bytes);
|
|
Kmods SIG |
d83023 |
sector_t block = lbo >> sb->s_blocksize_bits;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
do {
|
|
Kmods SIG |
d83023 |
--
|
|
Kmods SIG |
d83023 |
2.31.1
|
|
Kmods SIG |
d83023 |
|