From c028633b507830ca1114e042f215cdfc854a51f6 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 22 Sep 2015 16:28:23 -0700 Subject: [PATCH] nvme: assert valid nvme_qpair_construct parameters Document the assumptions made by qpair_construct using asserts. These values can't actually be 0 in practice due to the way they are derived, but scan-build can't see that. It is also useful to have these asserts in case of future modifications. Change-Id: I546c057f5cbe7ccc62acd90b595e423cd450d86a Signed-off-by: Daniel Verkamp --- lib/nvme/nvme_qpair.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index 2c0cd12db..597704a1a 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -488,6 +488,9 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint16_t id, volatile uint32_t *doorbell_base; uint64_t phys_addr = 0; + nvme_assert(num_entries != 0, ("invalid num_entries\n")); + nvme_assert(num_trackers != 0, ("invalid num_trackers\n")); + qpair->id = id; qpair->num_entries = num_entries;