diff mbox

[ndctl,1/8] libndctl: fix error returns for unsigned apis

Message ID 147689567402.11015.8666074208286654272.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams Oct. 19, 2016, 4:47 p.m. UTC
For unsigned attributes the library inconsistently returns ULLONG_MAX /
ULONG_MAX as an error return.  Fix up ndctl_region_get_available_size()
and ndctl_dimm_get_available_labels() to indicate errors following this
scheme.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 02524501db16..7d870b082cd4 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1707,11 +1707,11 @@  NDCTL_EXPORT unsigned long long ndctl_region_get_available_size(
 	if (snprintf(path, len, "%s/available_size", region->region_path) >= len) {
 		err(ctx, "%s: buffer too small!\n",
 				ndctl_region_get_devname(region));
-		return -ENOMEM;
+		return ULLONG_MAX;
 	}
 
 	if (sysfs_read_attr(ctx, path, buf) < 0)
-		return -ENXIO;
+		return ULLONG_MAX;
 
 	return strtoull(buf, NULL, 0);
 }
@@ -2519,11 +2519,11 @@  NDCTL_EXPORT unsigned long ndctl_dimm_get_available_labels(
 	if (snprintf(path, len, "%s/available_slots", dimm->dimm_path) >= len) {
 		err(ctx, "%s: buffer too small!\n",
 				ndctl_dimm_get_devname(dimm));
-		return -ENOMEM;
+		return ULONG_MAX;
 	}
 
 	if (sysfs_read_attr(ctx, path, buf) < 0)
-		return 0;
+		return ULONG_MAX;
 
 	return strtoul(buf, NULL, 0);
 }