* [PATCH] nvme: fix compiler warnings
@ 2020-04-24 1:14 Chaitanya Kulkarni
2020-04-24 14:44 ` Keith Busch
[not found] ` <CAN4XXPDjXcEhR9AuPXf1hv9hoe67om9BAN72EbfFGWzLt_Sgrw@mail.gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2020-04-24 1:14 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, Chaitanya Kulkarni
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 <chaitanya.kulkarni@wdc.com>
---
Hi,
I've not tested this patch on the legacy-ns as I don't have the
setup, but it is needed to compile the code for now, will be keeping
an eye for any bugs releated to this.
-Chaitanya
---
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.24.0
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: fix compiler warnings
2020-04-24 1:14 [PATCH] nvme: fix compiler warnings Chaitanya Kulkarni
@ 2020-04-24 14:44 ` Keith Busch
[not found] ` <CAN4XXPDjXcEhR9AuPXf1hv9hoe67om9BAN72EbfFGWzLt_Sgrw@mail.gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2020-04-24 14:44 UTC (permalink / raw)
To: Chaitanya Kulkarni; +Cc: linux-nvme
Applied, thank you for the quick fix.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: fix compiler warnings
[not found] ` <CAN4XXPDjXcEhR9AuPXf1hv9hoe67om9BAN72EbfFGWzLt_Sgrw@mail.gmail.com>
@ 2020-04-25 5:52 ` Chaitanya Kulkarni
0 siblings, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2020-04-25 5:52 UTC (permalink / raw)
To: Kev Dorman; +Cc: kbusch, linux-nvme
>
> asprintf() returns the number of bytes "printed", or -1 for error, so
> it'd be better to check for -1.
>
> Kev
Thanks for looking into this. I'll send a fix.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-25 5:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 1:14 [PATCH] nvme: fix compiler warnings Chaitanya Kulkarni
2020-04-24 14:44 ` Keith Busch
[not found] ` <CAN4XXPDjXcEhR9AuPXf1hv9hoe67om9BAN72EbfFGWzLt_Sgrw@mail.gmail.com>
2020-04-25 5:52 ` Chaitanya Kulkarni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).