Skip to contentSkip to conversation

libdaxctl: Add accurate check for daxctl_memory_op(MEM_GET_ZONE)

PATCH In review Xiao Yang 2 participants 2 messages Oct 9, 2023 – Oct 13, 2023 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 libdaxctl: Add accurate check for daxctl_memory_op(MEM_GET_ZONE)

The return number of daxctl_memory_op(MEM_GET_ZONE) indicates how many memory blocks have the same memory zone. So It's wrong to compare mem->zone and zone only when zero is returned.

---
 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/lib/libdaxctl.c +1 -1
index b27a8af..4f9aba0 100644
@@ -1616,7 +1616,7 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
 	 */
 	mem->zone = 0;
 	rc = daxctl_memory_op(mem, MEM_GET_ZONE);
-	if (rc)
+	if (rc < 0)
 		return rc;
 	if (mem->zone != zone) {
 		err(ctx,
Signature · 1 line
2.40.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Xiao Yang

The return number of daxctl_memory_op(MEM_GET_ZONE) indicates how many memory blocks have the same memory zone. So It's wrong to compare mem->zone and zone only when zero is returned.

You are correct. Thanks.

Quoted 17 lines
---
 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/lib/libdaxctl.c +1 -1
index b27a8af..4f9aba0 100644
@@ -1616,7 +1616,7 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
 	 */
 	mem->zone = 0;
 	rc = daxctl_memory_op(mem, MEM_GET_ZONE);
-	if (rc)
+	if (rc < 0)
 		return rc;
 	if (mem->zone != zone) {
 		err(ctx,