File 0015-Log-error-incase-of-failure-in-get_nvme_subsystem_in.patch of Package nvme-cli.12152

From: Vijay Kumar <vijay.ac.kumar@oracle.com>
Date: Tue, 6 Mar 2018 18:24:12 -0700
Subject: [PATCH] Log error incase of failure in get_nvme_subsystem_info()

Git-commit: e3ea60b9390d84fc6a4ef15a4ae89675374faad8
References: bsc#1099018

Currently get_nvme_subsystem_info() silently fails in case
of error. This patch logs relevant error message incase of
failure in get_nvme_subsystem_info().

Signed-off-by: Vijay Kumar <vijay.ac.kumar@oracle.com>
---
 nvme.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/nvme.c b/nvme.c
index edcdf2d..5018f57 100644
--- a/nvme.c
+++ b/nvme.c
@@ -1100,18 +1100,24 @@ int get_nvme_subsystem_info(char *name, char *path,
 	int n, i, ret = 1;
 
 	item->subsysnqn = get_nvme_subsnqn(path);
-	if (!item->subsysnqn)
+	if (!item->subsysnqn) {
+		fprintf(stderr, "failed to get subsystem nqn.\n");
 		return ret;
+	}
 
 	item->name = strdup(name);
 
 	n = scandir(path, &ctrls, scan_ctrls_filter, alphasort);
-	if (n < 0)
+	if (n < 0) {
+		fprintf(stderr, "failed to scan controller(s).\n");
 		return ret;
+	}
 
 	item->ctrls = calloc(n, sizeof(struct ctrl_list_item));
-	if (!item->ctrls)
+	if (!item->ctrls) {
+		fprintf(stderr, "failed to allocate subsystem controller(s)\n");
 		goto free_ctrls;
+	}
 
 	item->nctrls = n;
 
@@ -1122,12 +1128,16 @@ int get_nvme_subsystem_info(char *name, char *path,
 			 item->ctrls[i].name);
 
 		item->ctrls[i].address = get_nvme_ctrl_address(ctrl_path);
-		if (!item->ctrls[i].address)
+		if (!item->ctrls[i].address) {
+			fprintf(stderr, "failed to get controller[%d] address.\n", i);
 			goto free_ctrls;
+		}
 
 		item->ctrls[i].transport = get_nvme_ctrl_transport(ctrl_path);
-		if (!item->ctrls[i].transport)
+		if (!item->ctrls[i].transport) {
+			fprintf(stderr, "failed to get controller[%d] transport.\n", i);
 			goto free_ctrls;
+		}
 	}
 
 	ret = 0;
-- 
2.13.7
openSUSE Build Service is sponsored by