[LTP] [PATCH] fcntl: fix lock type interpretation

Murphy Zhou jencce.kernel@gmail.com
Tue Jun 6 08:51:00 CEST 2023


The lock type switching from an integer to a string in those
testcases are wrong because of typo I believe. As part of a
batch porting, fcntl17.c did it right.

In /usr/include/asm-generic/fcntl.h:166 defines the posix file
lock type value:

Those testcases mistook them as 1, 2, 3 respectively.

This does not affect the test verdict, but is printing wrong
message when the type is really not match, for example when
testing on CIFS.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
 testcases/kernel/syscalls/fcntl/fcntl11.c | 6 +++---
 testcases/kernel/syscalls/fcntl/fcntl19.c | 6 +++---
 testcases/kernel/syscalls/fcntl/fcntl20.c | 6 +++---
 testcases/kernel/syscalls/fcntl/fcntl21.c | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/testcases/kernel/syscalls/fcntl/fcntl11.c b/testcases/kernel/syscalls/fcntl/fcntl11.c
index b66fa8421..d042c6b9b 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl11.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl11.c
@@ -189,11 +189,11 @@ char *str_type(int type)
 	static char buf[20];
 
 	switch (type) {
-	case 0:
+	case F_RDLCK:
 		return ("F_RDLCK");
-	case 1:
+	case F_WRLCK:
 		return ("F_WRLCK");
-	case 2:
+	case F_UNLCK:
 		return ("F_UNLCK");
 	default:
 		sprintf(buf, "BAD VALUE: %d", type);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl19.c b/testcases/kernel/syscalls/fcntl/fcntl19.c
index 88c91d6ea..f929aff99 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl19.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl19.c
@@ -215,11 +215,11 @@ char *str_type(int type)
 	static char buf[20];
 
 	switch (type) {
-	case 1:
+	case F_RDLCK:
 		return ("F_RDLCK");
-	case 2:
+	case F_WRLCK:
 		return ("F_WRLCK");
-	case 3:
+	case F_UNLCK:
 		return ("F_UNLCK");
 	default:
 		sprintf(buf, "BAD VALUE: %d", type);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl20.c b/testcases/kernel/syscalls/fcntl/fcntl20.c
index b671af8a9..4aa773451 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl20.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl20.c
@@ -214,11 +214,11 @@ char *str_type(int type)
 	static char buf[20];
 
 	switch (type) {
-	case 1:
+	case F_RDLCK:
 		return ("F_RDLCK");
-	case 2:
+	case F_WRLCK:
 		return ("F_WRLCK");
-	case 3:
+	case F_UNLCK:
 		return ("F_UNLCK");
 	default:
 		sprintf(buf, "BAD VALUE: %d", type);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl21.c b/testcases/kernel/syscalls/fcntl/fcntl21.c
index 8f1a67cf6..824b8c059 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl21.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl21.c
@@ -222,11 +222,11 @@ char *str_type(int type)
 	static char buf[20];
 
 	switch (type) {
-	case 1:
+	case F_RDLCK:
 		return ("F_RDLCK");
-	case 2:
+	case F_WRLCK:
 		return ("F_WRLCK");
-	case 3:
+	case F_UNLCK:
 		return ("F_UNLCK");
 	default:
 		sprintf(buf, "BAD VALUE: %d", type);
-- 
2.31.1



More information about the ltp mailing list