Skip to contentSkip to conversation

fcntl: fix lock type interpretation

PATCH In review Murphy Zhou 2 participants 2 messages Jun 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fcntl: fix lock type interpretation

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.

---
 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(-)
testcases/kernel/syscalls/fcntl/fcntl11.c +3 -3
index b66fa8421..d042c6b9b 100644
@@ -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);
testcases/kernel/syscalls/fcntl/fcntl19.c +3 -3
index 88c91d6ea..f929aff99 100644
@@ -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);
testcases/kernel/syscalls/fcntl/fcntl20.c +3 -3
index b671af8a9..4aa773451 100644
@@ -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);
testcases/kernel/syscalls/fcntl/fcntl21.c +3 -3
index 8f1a67cf6..824b8c059 100644
@@ -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);
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Thanks for fixing this, pushed.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp