]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: Return negative errno when asprintf() fails
authorMinwoo Im <minwoo.im.dev@gmail.com>
Wed, 3 Apr 2019 14:53:33 +0000 (23:53 +0900)
committerMinwoo Im <minwoo.im.dev@gmail.com>
Wed, 3 Apr 2019 14:53:33 +0000 (23:53 +0900)
asprintf() will return -1 when it fails to allocate memory for the
string given with setting errno to ENOMEM.  For the uniformity, we can
return errno with negative value.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
fabrics.c

index f5cd2127db05c80cf403ba86bb1d2d71220ce4a7..96f740b61de8fc61de63c1cc9ee532a006cfedb8 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -852,7 +852,7 @@ static int do_discover(char *argstr, bool connect)
                return instance;
 
        if (asprintf(&dev_name, "/dev/nvme%d", instance) < 0)
-               return errno;
+               return -errno;
        ret = nvmf_get_log_page_discovery(dev_name, &log, &numrec);
        free(dev_name);
        remove_ctrl(instance);