public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit
@ 2017-09-12 15:18 Cyril Hrubis
  2017-09-12 15:18 ` [LTP] [PATCH 2/2] [COMMITTED] syscalls/shmat: Print expected and actual address on failure Cyril Hrubis
  2017-09-12 15:24 ` [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Jan Stancek
  0 siblings, 2 replies; 3+ messages in thread
From: Cyril Hrubis @ 2017-09-12 15:18 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/ipc/shmat/shmat01.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat01.c b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
index 4f5c4e725..4c6ce58d3 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat01.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
@@ -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;
-- 
2.13.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 2/2] [COMMITTED] syscalls/shmat: Print expected and actual address on failure
  2017-09-12 15:18 [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Cyril Hrubis
@ 2017-09-12 15:18 ` Cyril Hrubis
  2017-09-12 15:24 ` [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Jan Stancek
  1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2017-09-12 15:18 UTC (permalink / raw)
  To: ltp

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/ipc/shmat/shmat01.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat01.c b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
index 4c6ce58d3..b46ba6831 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat01.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
@@ -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;
 	}
 
-- 
2.13.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit
  2017-09-12 15:18 [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Cyril Hrubis
  2017-09-12 15:18 ` [LTP] [PATCH 2/2] [COMMITTED] syscalls/shmat: Print expected and actual address on failure Cyril Hrubis
@ 2017-09-12 15:24 ` Jan Stancek
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2017-09-12 15:24 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> 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.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>

You have beat me by ~3 minutes. I was just going to push,
did final 'git pull --rebase' and my commit disappeared :-).

Regards,
Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-12 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 15:18 [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Cyril Hrubis
2017-09-12 15:18 ` [LTP] [PATCH 2/2] [COMMITTED] syscalls/shmat: Print expected and actual address on failure Cyril Hrubis
2017-09-12 15:24 ` [LTP] [PATCH 1/2] [COMMITTED] syscalls/shmat01: Fix test on 32bit Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox