Skip to content

Commit 64ea88e

Browse files
Li Haorankeithbusch
authored andcommitted
nvmet: replace max(a, min(b, c)) by clamp(val, lo, hi)
This patch replaces max(a, min(b, c)) by clamp(val, lo, hi) in the nvme driver. The clamp() macro explicitly expresses the intent of constraining a value within bounds, improving code readability. Signed-off-by: Li Haoran <[email protected]> Signed-off-by: Shao Mingyin <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 1be5216 commit 64ea88e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ static inline u8 nvmet_cc_iocqes(u32 cc)
828828
/* Convert a 32-bit number to a 16-bit 0's based number */
829829
static inline __le16 to0based(u32 a)
830830
{
831-
return cpu_to_le16(max(1U, min(1U << 16, a)) - 1);
831+
return cpu_to_le16(clamp(a, 1U, 1U << 16) - 1);
832832
}
833833

834834
static inline bool nvmet_ns_has_pi(struct nvmet_ns *ns)

0 commit comments

Comments
 (0)