Skip to contentSkip to conversation

ndctl: Fix the NDCTL_TIMEOUT environment variable parsing

PATCH New Shivaprasad G Bhat 1 participant 1 message Nov 4, 2022 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ndctl: Fix the NDCTL_TIMEOUT environment variable parsing

The strtoul(x, y, size) returns empty string on y when the x is "only" number with no other suffix strings. The code is checking if !null instead of comparing with empty string.

---
Changelog:
Since v1:

* Avoid using strcmp

 ndctl/lib/libndctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/lib/libndctl.c +1 -1
index ad54f06..77c31ab 100644
@@ -334,7 +334,7 @@ NDCTL_EXPORT int ndctl_new(struct ndctl_ctx **ctx)
 		char *end;
 
 		tmo = strtoul(env, &end, 0);
-		if (tmo < ULONG_MAX && !end)
+		if (tmo < ULONG_MAX && !*end)
 			c->timeout = tmo;
 		dbg(c, "timeout = %ld\n", tmo);
 	}