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

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