Commit a2775699 authored by Jim Harris's avatar Jim Harris
Browse files

identify: fix set-but-not-used error



Fixes: 5ef79a17 (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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I2c2893089cc82f76d7dd6b569952dd4a9f907ebc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5949


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
parent a9a0761b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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;