From: Sagi Grimberg Date: Wed, 12 Feb 2020 20:01:57 +0000 (-0800) Subject: fabrics: ignore hostnqn file if its empty X-Git-Tag: v1.11~38 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=84c7e3c7b0d48cd74e8795a0d344afe7a2afe92f;p=users%2Fhch%2Fnvme-cli.git fabrics: ignore hostnqn file if its empty If we read an empty string from /etc/nvme/hostnqn we should ignore it instead of passing an empty string to the driver resulting in the error: nvme_fabrics: unknown parameter or missing value 'hostnqn=' in ctrl creation request Signed-off-by: Sagi Grimberg Signed-off-by: Keith Busch --- diff --git a/fabrics.c b/fabrics.c index 57625cd..98a4278 100644 --- a/fabrics.c +++ b/fabrics.c @@ -672,7 +672,8 @@ static char *hostnqn_read_file(void) if (f == NULL) return false; - if (fgets(hostnqn, sizeof(hostnqn), f) == NULL) + if (fgets(hostnqn, sizeof(hostnqn), f) == NULL || + !strlen(hostnqn)) goto out; ret = strndup(hostnqn, strcspn(hostnqn, "\n"));