Re: [PATCH 4/7] examples: fix the type of search_hint

2020-04-23 Thread Bin Meng
On Tue, Apr 21, 2020 at 7:28 AM  wrote:
>
> From: Mitchell Horne 
>
> search_hint is defined in assembly as a .long, and is intended to hold
> the initial stack pointer as a hint to the api_search_sig() routine.
> Convert this to a uintptr_t, to avoid possible truncation on 64-bit
> systems.
>
> Signed-off-by: Mitchell Horne 
> ---
>  examples/api/glue.c | 6 +++---
>  examples/api/glue.h | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>

Reviewed-by: Bin Meng 


[PATCH 4/7] examples: fix the type of search_hint

2020-04-20 Thread mhorne
From: Mitchell Horne 

search_hint is defined in assembly as a .long, and is intended to hold
the initial stack pointer as a hint to the api_search_sig() routine.
Convert this to a uintptr_t, to avoid possible truncation on 64-bit
systems.

Signed-off-by: Mitchell Horne 
---
 examples/api/glue.c | 6 +++---
 examples/api/glue.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/api/glue.c b/examples/api/glue.c
index 91d13157a1..c223306319 100644
--- a/examples/api/glue.c
+++ b/examples/api/glue.c
@@ -42,8 +42,8 @@ static int valid_sig(struct api_signature *sig)
 int api_search_sig(struct api_signature **sig)
 {
unsigned char *sp;
-   uint32_t search_start = 0;
-   uint32_t search_end = 0;
+   uintptr_t search_start = 0;
+   uintptr_t search_end = 0;
 
if (sig == NULL)
return 0;
@@ -51,7 +51,7 @@ int api_search_sig(struct api_signature **sig)
if (search_hint == 0)
search_hint = 255 * 1024 * 1024;
 
-   search_start = search_hint & ~0x000f;
+   search_start = search_hint & ~0xful;
search_end = search_start + API_SEARCH_LEN - API_SIG_MAGLEN;
 
sp = (unsigned char *)search_start;
diff --git a/examples/api/glue.h b/examples/api/glue.h
index f9745604b6..dd662fc872 100644
--- a/examples/api/glue.h
+++ b/examples/api/glue.h
@@ -18,7 +18,7 @@
 #define UB_MAX_DEV 6   /* max devices number */
 
 extern void *syscall_ptr;
-extern uint32_t search_hint;
+extern unsigned long search_hint;
 
 intsyscall(int, int *, ...);
 intapi_search_sig(struct api_signature **sig);
-- 
2.26.1