From: Minwoo Im Date: Wed, 3 Apr 2019 14:53:33 +0000 (+0900) Subject: fabrics: Return negative errno when asprintf() fails X-Git-Tag: v1.8~10^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=115e3ce205b718e6ebc06f0ab8b9ae5d55cb92d0;p=users%2Fsagi%2Fnvme-cli.git fabrics: Return negative errno when asprintf() fails 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 --- diff --git a/fabrics.c b/fabrics.c index f5cd2127..96f740b6 100644 --- 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);