Skip to contentSkip to conversation

selftests: txring_overwrite: fix incorrect test of mmap() return value

PATCH In review Frank de Brabander 3 participants 3 messages Jul 5, 2019 – Jul 8, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: txring_overwrite: fix incorrect test of mmap() return value

If mmap() fails it returns MAP_FAILED, which is defined as ((void *) -1). The current if-statement incorrectly tests if *ring is NULL.

---
 tools/testing/selftests/net/txring_overwrite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/txring_overwrite.c +1 -1
index fd8b1c6..7d9ea03 100644
@@ -113,7 +113,7 @@ static int setup_tx(char **ring)
 
 	*ring = mmap(0, req.tp_block_size * req.tp_block_nr,
 		     PROT_READ | PROT_WRITE, MAP_SHARED, fdt, 0);
-	if (!*ring)
+	if (*ring == MAP_FAILED)
 		error(1, errno, "mmap");
 
 	return fdt;
Signature · 1 line
2.7.4