From 93c803c363a7962386bf794d0b78fbd59173e63a Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 12 Sep 2017 10:45:24 -0700 Subject: [PATCH] nvme/identify: print error if no controllers found Change-Id: I5b0411484290bbdf9077e55674ae368312fb01ab Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/378185 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Paul Luse --- examples/nvme/identify/identify.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index af883fce6..9d31fe310 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -72,6 +72,8 @@ static char g_core_mask[16] = "0x1"; static struct spdk_nvme_transport_id g_trid; +static int g_controllers_found = 0; + static void hex_dump(const void *data, size_t size) { @@ -1059,6 +1061,7 @@ static void attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts) { + g_controllers_found++; print_controller(ctrlr, trid); spdk_nvme_detach(ctrlr); } @@ -1085,11 +1088,14 @@ int main(int argc, char **argv) } spdk_env_init(&opts); - rc = 0; if (spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL) != 0) { fprintf(stderr, "spdk_nvme_probe() failed\n"); - rc = 1; + return 1; } - return rc; + if (g_controllers_found == 0) { + fprintf(stderr, "No NVMe controllers found.\n"); + } + + return 0; }