syscalls/shmat01: Fix test on 32bit
PATCH 1/2 syscalls/shmat01: Fix test on 32bit
The problem there is that the address casted to intptr_t yields negative number which when divided then multiplied by SHMLBA aligns the value up instead of down.
The fix is simple, we cast the pointer to uintptr_t instead of intptr_t and also include stdint.h explicitly.
--- testcases/kernel/syscalls/ipc/shmat/shmat01.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ipc/shmat/shmat01.c +2 -1
@@ -35,12 +35,13 @@#include <sys/shm.h> #include <sys/wait.h> #include <stdlib.h> +#include <stdint.h> #include "tst_test.h" #include "tst_safe_sysv_ipc.h" #include "libnewipc.h" -#define ALIGN_DOWN (in_addr) ((void *)(((intptr_t)in_addr / SHMLBA) * SHMLBA)) +#define ALIGN_DOWN (in_addr) ((void *)(((uintptr_t)in_addr / SHMLBA) * SHMLBA))static int shm_id =-1 ;static key_t shm_key;
Signature · 1 line
2.13.0
PATCH 2/2 syscalls/shmat: Print expected and actual address on failure
--- testcases/kernel/syscalls/ipc/shmat/shmat01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ipc/shmat/shmat01.c +3 -1
@@ -129,7 +129,9 @@ static void verify_shmat(unsigned int n) }if (expected_addr (*tc->shmaddr, addr) != addr) { -tst_res (TFAIL ,"shared memory address was not correct" ); +tst_res (TFAIL , +"shared memory address %p is not correct, expected %p" , + addr,expected_addr (*tc->shmaddr, addr)); goto end; }
Signature · 1 line
2.13.0
PATCH 1/2 syscalls/shmat01: Fix test on 32bit
In reply to Cyril Hrubis----- Original Message -----
Quoted 8 lines
The problem there is that the address casted to
intptr_tyields negative number which when divided then multiplied by SHMLBA aligns the value up instead of down.The fix is simple, we cast the pointer to
uintptr_tinstead ofintptr_tand also includestdint.hexplicitly.Signed-off-by Cyril Hrubis <[email protected]>
You have beat me by ~3 minutes. I was just going to push, did final 'git pull --rebase' and my commit disappeared :-).
Regards,
Jan