libmultipath/foreign(coverity): retval check in snprint_nvme_path
authorMartin Wilck <mwilck@suse.com>
Tue, 8 Jan 2019 22:54:08 +0000 (23:54 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sat, 19 Jan 2019 10:52:02 +0000 (11:52 +0100)
Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/foreign/nvme.c

index f0e8293..7e654ec 100644 (file)
@@ -249,8 +249,10 @@ static int snprint_nvme_path(const struct gen_path *gp,
                devt = udev_device_get_devnum(np->udev);
                return snprintf(buff, len, "%u:%u", major(devt), minor(devt));
        case 'o':
-               sysfs_attr_get_value(np->ctl, "state", fld, sizeof(fld));
-               return snprintf(buff, len, "%s", fld);
+               if (sysfs_attr_get_value(np->ctl, "state",
+                                        fld, sizeof(fld)) > 0)
+                       return snprintf(buff, len, "%s", fld);
+               break;
        case 'T':
                if (sysfs_attr_get_value(np->udev, "ana_state", fld,
                                         sizeof(fld)) > 0)