linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, Kev Dorman <kdorman036@gmail.com>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH nvme-cli] nvme: fix asprintf return value check
Date: Fri, 24 Apr 2020 22:58:52 -0700	[thread overview]
Message-ID: <20200425055852.2921-1-chaitanya.kulkarni@wdc.com> (raw)

The asprintf(3) function resturns -1 on error not 1. Fix that.

Fixes a032a481d74 ("nvme: fix compiler warnings")

Suggested-by: Kev Dorman <kdorman036@gmail.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 nvme-topology.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nvme-topology.c b/nvme-topology.c
index e938f23..4dbadce 100644
--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -357,9 +357,9 @@ static int verify_legacy_ns(struct nvme_namespace *n)
 		char tmp_address[64] = "";
 		legacy_get_pci_bdf(path, tmp_address);
 		if (tmp_address[0]) {
-			if (asprintf(&n->ctrl->transport, "pcie") != 1)
+			if (asprintf(&n->ctrl->transport, "pcie") == -1)
 				return -1;
-			if (asprintf(&n->ctrl->address, "%s", tmp_address) != 1)
+			if (asprintf(&n->ctrl->address, "%s", tmp_address) == -1)
 				return -1;
 		}
 	}
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

             reply	other threads:[~2020-04-25  5:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25  5:58 Chaitanya Kulkarni [this message]
2020-04-25 17:34 ` [PATCH nvme-cli] nvme: fix asprintf return value check Bart Van Assche
2020-04-25 18:09   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200425055852.2921-1-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=kbusch@kernel.org \
    --cc=kdorman036@gmail.com \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).