From patchwork Mon Apr 20 22:34:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mitchell Horne X-Patchwork-Id: 238134 List-Id: U-Boot discussion From: mhorne at FreeBSD.org (mhorne at FreeBSD.org) Date: Mon, 20 Apr 2020 18:34:15 -0400 Subject: [PATCH 4/7] examples: fix the type of search_hint In-Reply-To: <20200420223418.117186-1-mhorne@FreeBSD.org> References: <20200420223418.117186-1-mhorne@FreeBSD.org> Message-ID: <20200420223418.117186-5-mhorne@FreeBSD.org> 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 Reviewed-by: Bin Meng --- 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 & ~0x000fffff; + search_start = search_hint & ~0xffffful; 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; int syscall(int, int *, ...); int api_search_sig(struct api_signature **sig);