Skip to contentSkip to conversation

unshare03: use sizeof(long long) to fix for 32bit

PATCH In review Avinesh Kumar 2 participants 3 messages Apr 24, 2025 – Apr 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unshare03: use sizeof(long long) to fix for 32bit

when executing on 32bit compat layer
"nr_open = sizeof(long) * 8" does not evaluate to a large enough value for /proc/sys/fs/nr_open.
unshare03.c:38: TBROK: Failed to close FILE '/proc/sys/fs/nr_open': EINVAL (22) Use (long long) instead.

Fixes fc8be6ed4 ("unshare03: Simplify EMFILE test by using fixed fd limit (sizeof(long) * 8)")
---
 testcases/kernel/syscalls/unshare/unshare03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/unshare/unshare03.c +1 -1
index c3b98930d..7128b3b97 100644
@@ -27,7 +27,7 @@ static void run(void)
 		.exit_signal = SIGCHLD,
 	};
 
-	int nr_open = sizeof(long) * 8;
+	int nr_open = sizeof(long long) * 8;
 
 	SAFE_DUP2(2, nr_open + 1);
 
Signature · 5 lines
2.43.0


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

Hi Avinesh,

Quoted 18 lines

when executing on 32bit compat layer
"nr_open = sizeof(long) * 8" does not evaluate to a large enough value for /proc/sys/fs/nr_open.
unshare03.c:38: TBROK: Failed to close FILE '/proc/sys/fs/nr_open': EINVAL (22) Use (long long) instead.

Fixes fc8be6ed4 ("unshare03: Simplify EMFILE test by using fixed fd limit (sizeof(long) * 8)")
---
 testcases/kernel/syscalls/unshare/unshare03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/unshare/unshare03.c +0 -0
index c3b98930d..7128b3b97 100644

testcases/kernel/syscalls/unshare/unshare03.c static void run(void) · line 30

Quoted 5 lines
testcases/kernel/syscalls/unshare/unshare03.c +1 -1
@@ -27,7 +27,7 @@ static void run(void)
 		.exit_signal = SIGCHLD,
 	};
 
-	int nr_open = sizeof(long) * 8;
+	int nr_open = sizeof(long long) * 8;

Thank you!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Avinesh Kumar

Hi Avinesh, all,

merged, thank you!

Quoted 25 lines

when executing on 32bit compat layer
"nr_open = sizeof(long) * 8" does not evaluate to a large enough value for /proc/sys/fs/nr_open.
unshare03.c:38: TBROK: Failed to close FILE '/proc/sys/fs/nr_open': EINVAL (22) Use (long long) instead.

Fixes fc8be6ed4 ("unshare03: Simplify EMFILE test by using fixed fd limit (sizeof(long) * 8)")
---
 testcases/kernel/syscalls/unshare/unshare03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/unshare/unshare03.c +1 -1
index c3b98930d..7128b3b97 100644
@@ -27,7 +27,7 @@ static void run(void)
 		.exit_signal = SIGCHLD,
 	};
 
-	int nr_open = sizeof(long) * 8;
+	int nr_open = sizeof(long long) * 8;
 
 	SAFE_DUP2(2, nr_open + 1);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp