aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2024-05-07 20:45:51 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-05-07 20:54:00 +0000
commitc8703409edb782b953b89d517a1757756788ce18 (patch)
treebf3f27160ce07213f4bf8d95ed3c8a6ce3a239d4
parent766c4ad385ccf96f8cf10129363a6bfa58b3e92f (diff)
downloadsrc-c8703409edb782b953b89d517a1757756788ce18.tar.gz
src-c8703409edb782b953b89d517a1757756788ce18.zip
nvmecontrol: Fix a sign compare mismatch
Even though mqes (uint16_t) and queue_size (u_int) are both unsigned, the expression 'mqes + 1' gets promoted to int which is signed. Keep the value unsigned by explicitly promoting mqes to u_int before incrementing the value. Reported by: GCC
-rw-r--r--sbin/nvmecontrol/fabrics.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/nvmecontrol/fabrics.c b/sbin/nvmecontrol/fabrics.c
index 6470e4062b39..c9aca088c47e 100644
--- a/sbin/nvmecontrol/fabrics.c
+++ b/sbin/nvmecontrol/fabrics.c
@@ -452,8 +452,8 @@ connect_nvm_queues(const struct nvmf_association_params *aparams,
/* Validate I/O queue size. */
if (queue_size == 0)
- queue_size = mqes + 1;
- else if (queue_size > mqes + 1) {
+ queue_size = (u_int)mqes + 1;
+ else if (queue_size > (u_int)mqes + 1) {
shutdown_controller(*admin);
nvmf_free_association(na);
warn("I/O queue size exceeds controller maximum (%u)",