From a032a481d7406c5a0ae188eeaae709805d1c6e02 Mon Sep 17 00:00:00 2001 From: Chaitanya Kulkarni Date: Thu, 23 Apr 2020 18:14:53 -0700 Subject: [PATCH] nvme: fix compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch fixes the following errors :- nvme-topology.c: In function ‘verify_legacy_ns’: nvme-topology.c:361:32: error: format not a string literal and no format arguments [-Werror=format-security] 361 | asprintf(&n->ctrl->address, tmp_address); | ^~~~~~~~~~~ nvme-topology.c:360:4: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 360 | asprintf(&n->ctrl->transport, "pcie"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nvme-topology.c:361:4: error: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Werror=unused-result] 361 | asprintf(&n->ctrl->address, tmp_address); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:96: nvme-topology.o] Error 1 This can be easily re produced on the gcc version :- (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008 Signed-off-by: Chaitanya Kulkarni --- nvme-topology.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nvme-topology.c b/nvme-topology.c index 55ad8c1..e938f23 100644 --- a/nvme-topology.c +++ b/nvme-topology.c @@ -357,8 +357,10 @@ static int verify_legacy_ns(struct nvme_namespace *n) char tmp_address[64] = ""; legacy_get_pci_bdf(path, tmp_address); if (tmp_address[0]) { - asprintf(&n->ctrl->transport, "pcie"); - asprintf(&n->ctrl->address, tmp_address); + if (asprintf(&n->ctrl->transport, "pcie") != 1) + return -1; + if (asprintf(&n->ctrl->address, "%s", tmp_address) != 1) + return -1; } } -- 2.49.0