identify: fix set-but-not-used error

Fixes: 5ef79a17ec (add an option to dump the full zns zone report)

max_zones_per_buf was only used in an assert.  Per-patch
testing doesn't do a release build, so this wasn't found
until running nightly tests.

So rework the code a bit to print error message and exit
instead of this unexpected condition occurs.

While here, change another error message to use stderr
instead of stdout.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I2c2893089cc82f76d7dd6b569952dd4a9f907ebc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5949
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Jim Harris 2021-01-15 21:07:45 +00:00
parent a9a0761bcc
commit a27756993c

View File

@ -736,7 +736,6 @@ get_and_print_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q
outstanding_commands = 0;
report_bufsize = spdk_nvme_ns_get_max_io_xfer_size(ns);
max_zones_per_buf = (report_bufsize - sizeof(*report_buf)) / sizeof(report_buf->descs[0]);
report_buf = malloc(report_bufsize);
if (!report_buf) {
printf("Zone report allocation failed!\n");
@ -759,7 +758,7 @@ get_and_print_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q
if (spdk_nvme_zns_report_zones(ns, qpair, report_buf, report_bufsize,
slba, SPDK_NVME_ZRA_LIST_ALL, true,
get_zns_zone_report_completion, NULL)) {
printf("spdk_nvme_zns_report_zones() failed\n");
fprintf(stderr, "spdk_nvme_zns_report_zones() failed\n");
exit(1);
} else {
outstanding_commands++;
@ -769,7 +768,11 @@ get_and_print_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q
spdk_nvme_qpair_process_completions(qpair, 0);
}
assert(report_buf->nr_zones <= max_zones_per_buf);
max_zones_per_buf = (report_bufsize - sizeof(*report_buf)) / sizeof(report_buf->descs[0]);
if (report_buf->nr_zones > max_zones_per_buf) {
fprintf(stderr, "nr_zones too big\n");
exit(1);
}
if (!report_buf->nr_zones) {
break;