[PATCH 1/8] test-initstate: Check for negative value on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Documentation says kmod_module_new_from_lookup() returns < 0 on error
and 0 otherwise. There are bugs in libkmod however making it return
a positive value in some situations, that need to be fixed. However
it's best to check for the error explicitly like is done in the rest
of the library to avoid this kind of issues.
---
 testsuite/test-initstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testsuite/test-initstate.c b/testsuite/test-initstate.c
index da2303a..9332e8f 100644
--- a/testsuite/test-initstate.c
+++ b/testsuite/test-initstate.c
@@ -45,7 +45,7 @@ static noreturn int test_initstate_from_lookup(const struct test *t)
 		exit(EXIT_FAILURE);
 
 	err = kmod_module_new_from_lookup(ctx, "fake-builtin", &list);
-	if (err != 0) {
+	if (err < 0) {
 		ERR("could not create module from lookup: %s\n", strerror(-err));
 		exit(EXIT_FAILURE);
 	}
-- 
2.35.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux