Skip to content

Commit 981b696

Browse files
Xichao Zhaotytso
authored andcommitted
ext4: replace min/max nesting with clamp()
The clamp() macro explicitly expresses the intent of constraining a value within bounds.Therefore, replacing max(min(a,b),c) with clamp(val, lo, hi) can improve code readability. Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 1534f72 commit 981b696

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/ext4/mmp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ static int kmmpd(void *data)
231231
* Adjust the mmp_check_interval depending on how much time
232232
* it took for the MMP block to be written.
233233
*/
234-
mmp_check_interval = max(min(EXT4_MMP_CHECK_MULT * diff / HZ,
235-
EXT4_MMP_MAX_CHECK_INTERVAL),
236-
EXT4_MMP_MIN_CHECK_INTERVAL);
234+
mmp_check_interval = clamp(EXT4_MMP_CHECK_MULT * diff / HZ,
235+
EXT4_MMP_MIN_CHECK_INTERVAL,
236+
EXT4_MMP_MAX_CHECK_INTERVAL);
237237
mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
238238
}
239239

0 commit comments

Comments
 (0)