Commit 6e3331ee authored by Kari Argillander's avatar Kari Argillander Committed by Konstantin Komarov

fs/ntfs3: Use min/max macros instated of ternary operators

We can make code little bit more readable by using min/max macros.

These were found with Coccinelle.
Signed-off-by: default avatarKari Argillander <kari.argillander@gmail.com>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent b5322eb1
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kernel.h>
#include "debug.h" #include "debug.h"
#include "ntfs.h" #include "ntfs.h"
...@@ -1961,7 +1962,7 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size) ...@@ -1961,7 +1962,7 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
return 0; return 0;
from = vbo; from = vbo;
to = (vbo + bytes) < data_size ? (vbo + bytes) : data_size; to = min_t(u64, vbo + bytes, data_size);
memset(Add2Ptr(resident_data(attr_b), from), 0, to - from); memset(Add2Ptr(resident_data(attr_b), from), 0, to - from);
return 0; return 0;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h>
#include "ntfs.h" #include "ntfs.h"
#include "ntfs_fs.h" #include "ntfs_fs.h"
...@@ -432,7 +433,7 @@ static void wnd_remove_free_ext(struct wnd_bitmap *wnd, size_t bit, size_t len) ...@@ -432,7 +433,7 @@ static void wnd_remove_free_ext(struct wnd_bitmap *wnd, size_t bit, size_t len)
; ;
} else { } else {
n3 = rb_next(&e->count.node); n3 = rb_next(&e->count.node);
max_new_len = len > new_len ? len : new_len; max_new_len = max(len, new_len);
if (!n3) { if (!n3) {
wnd->extent_max = max_new_len; wnd->extent_max = max_new_len;
} else { } else {
...@@ -728,7 +729,7 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits) ...@@ -728,7 +729,7 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits)
wbits = wnd->bits_last; wbits = wnd->bits_last;
tail = wbits - wbit; tail = wbits - wbit;
op = tail < bits ? tail : bits; op = min_t(u32, tail, bits);
bh = wnd_map(wnd, iw); bh = wnd_map(wnd, iw);
if (IS_ERR(bh)) { if (IS_ERR(bh)) {
...@@ -781,7 +782,7 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits) ...@@ -781,7 +782,7 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
wbits = wnd->bits_last; wbits = wnd->bits_last;
tail = wbits - wbit; tail = wbits - wbit;
op = tail < bits ? tail : bits; op = min_t(u32, tail, bits);
bh = wnd_map(wnd, iw); bh = wnd_map(wnd, iw);
if (IS_ERR(bh)) { if (IS_ERR(bh)) {
...@@ -831,7 +832,7 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits) ...@@ -831,7 +832,7 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits)
wbits = wnd->bits_last; wbits = wnd->bits_last;
tail = wbits - wbit; tail = wbits - wbit;
op = tail < bits ? tail : bits; op = min_t(u32, tail, bits);
if (wbits != wnd->free_bits[iw]) { if (wbits != wnd->free_bits[iw]) {
bool ret; bool ret;
...@@ -923,7 +924,7 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits) ...@@ -923,7 +924,7 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
wbits = wnd->bits_last; wbits = wnd->bits_last;
tail = wbits - wbit; tail = wbits - wbit;
op = tail < bits ? tail : bits; op = min_t(u32, tail, bits);
if (wnd->free_bits[iw]) { if (wnd->free_bits[iw]) {
bool ret; bool ret;
......
...@@ -382,7 +382,7 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len, ...@@ -382,7 +382,7 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
} }
lcn = wnd_zone_bit(wnd); lcn = wnd_zone_bit(wnd);
alen = zlen > len ? len : zlen; alen = min_t(CLST, len, zlen);
wnd_zone_set(wnd, lcn + alen, zlen - alen); wnd_zone_set(wnd, lcn + alen, zlen - alen);
...@@ -1096,7 +1096,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run, ...@@ -1096,7 +1096,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
len = ((u64)clen << cluster_bits) - off; len = ((u64)clen << cluster_bits) - off;
for (;;) { for (;;) {
u32 op = len < bytes ? len : bytes; u32 op = min_t(u64, len, bytes);
int err = ntfs_sb_write(sb, lbo, op, buf, 0); int err = ntfs_sb_write(sb, lbo, op, buf, 0);
if (err) if (err)
...@@ -1297,7 +1297,7 @@ int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo, ...@@ -1297,7 +1297,7 @@ int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
nb->off = off = lbo & (blocksize - 1); nb->off = off = lbo & (blocksize - 1);
for (;;) { for (;;) {
u32 len32 = len < bytes ? len : bytes; u32 len32 = min_t(u64, len, bytes);
sector_t block = lbo >> sb->s_blocksize_bits; sector_t block = lbo >> sb->s_blocksize_bits;
do { do {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment