From 478f36aafac249a507d972103186d88ca5ac73f4 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 14 Oct 2021 13:06:03 -0400 Subject: [PATCH] fix some compiler warnings --- src/jlapi.c | 22 ++++++++++++---------- src/signals-mach.c | 2 +- src/sys.c | 3 +-- src/threading.c | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/jlapi.c b/src/jlapi.c index 65d1feab6b4e3..a47af5360520a 100644 --- a/src/jlapi.c +++ b/src/jlapi.c @@ -618,8 +618,7 @@ static NOINLINE int true_main(int argc, char *argv[]) static void lock_low32(void) { #if defined(_OS_WINDOWS_) && defined(_P64) && defined(JL_DEBUG_BUILD) - // Wine currently has a that causes it to answer VirtualQuery incorrectly. - // block usage of the 32-bit address space on win64, to catch pointer cast errors + // Prevent usage of the 32-bit address space on Win64, to catch pointer cast errors. char *const max32addr = (char*)0xffffffffL; SYSTEM_INFO info; MEMORY_BASIC_INFORMATION meminfo; @@ -643,11 +642,12 @@ static void lock_low32(void) if ((char*)p != first) // Wine and Windows10 seem to have issues with reporting memory access information correctly // so we sometimes end up with unexpected results - this is just ignore those and continue - // this is just a debugging aid to help find accidental pointer truncation anyways, so it's not critical + // this is just a debugging aid to help find accidental pointer truncation anyways, + // so it is not critical VirtualFree(p, 0, MEM_RELEASE); } } - meminfo.BaseAddress += meminfo.RegionSize; + meminfo.BaseAddress = (void*)((char*)meminfo.BaseAddress + meminfo.RegionSize); } #endif return; @@ -656,16 +656,16 @@ static void lock_low32(void) // Actual definition in `ast.c` void jl_lisp_prompt(void); -static void rr_detach_teleport(void) { #ifdef _OS_LINUX_ +static void rr_detach_teleport(void) { #define RR_CALL_BASE 1000 #define SYS_rrcall_detach_teleport (RR_CALL_BASE + 9) int err = syscall(SYS_rrcall_detach_teleport, 0, 0, 0, 0, 0, 0); if (err < 0 || jl_running_under_rr(1)) { jl_error("Failed to detach from rr session"); } -#endif } +#endif JL_DLLEXPORT int jl_repl_entrypoint(int argc, char *argv[]) { @@ -682,16 +682,18 @@ JL_DLLEXPORT int jl_repl_entrypoint(int argc, char *argv[]) memmove(&argv[1], &argv[2], (argc-2)*sizeof(void*)); argc--; } - char **orig_argv = argv; - jl_parse_opts(&argc, (char***)&argv); + char **new_argv = argv; + jl_parse_opts(&argc, (char***)&new_argv); // The parent process requested that we detach from the rr session. // N.B.: In a perfect world, we would only do this for the portion of // the execution where we actually need to exclude rr (e.g. because we're // testing for the absence of a memory-model-dependent bug). if (jl_options.rr_detach && jl_running_under_rr(0)) { +#ifdef _OS_LINUX_ rr_detach_teleport(); - execv("/proc/self/exe", orig_argv); + execv("/proc/self/exe", argv); +#endif jl_error("Failed to self-execute"); } @@ -701,7 +703,7 @@ JL_DLLEXPORT int jl_repl_entrypoint(int argc, char *argv[]) jl_lisp_prompt(); return 0; } - int ret = true_main(argc, (char**)argv); + int ret = true_main(argc, (char**)new_argv); jl_atexit_hook(ret); return ret; } diff --git a/src/signals-mach.c b/src/signals-mach.c index 04ce636d4fdd7..179f45f187e26 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -594,7 +594,7 @@ void *mach_profile_listener(void *arg) bt_data_prof[bt_size_cur++].uintptr = ptls->tid + 1; // store task id - bt_data_prof[bt_size_cur++].uintptr = (uintptr_t)jl_atomic_load_relaxed(&ptls->current_task); + bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task); // store cpu cycle clock bt_data_prof[bt_size_cur++].uintptr = cycleclock(); diff --git a/src/sys.c b/src/sys.c index 4a61b40da7193..0dff9825a7cf0 100644 --- a/src/sys.c +++ b/src/sys.c @@ -865,12 +865,11 @@ JL_DLLEXPORT int jl_dllist(jl_array_t *list) } while (cb < cbNeeded); for (i = 0; i < cbNeeded / sizeof(HMODULE); i++) { const char *path = jl_pathname_for_handle(hMods[i]); - // XXX: change to jl_arrayset if array storage allocation for Array{String,1} changes: if (path == NULL) continue; jl_array_grow_end((jl_array_t*)list, 1); jl_value_t *v = jl_cstr_to_string(path); - free(path); + free((char*)path); jl_array_ptr_set(list, jl_array_dim0(list) - 1, v); } free(hMods); diff --git a/src/threading.c b/src/threading.c index 18cc032e5dbcd..8fd0fb525206e 100644 --- a/src/threading.c +++ b/src/threading.c @@ -88,7 +88,7 @@ __attribute__((constructor)) void jl_init_tls(void) JL_CONST_FUNC jl_gcframe_t **jl_get_pgcstack(void) JL_NOTSAFEPOINT { - return pthread_getspecific(jl_pgcstack_key); + return (jl_gcframe_t**)pthread_getspecific(jl_pgcstack_key); } void jl_set_pgcstack(jl_gcframe_t **pgcstack) JL_NOTSAFEPOINT @@ -176,7 +176,7 @@ JL_DLLEXPORT void jl_set_safe_restore(jl_jmp_buf *sr) JL_CONST_FUNC jl_gcframe_t **jl_get_pgcstack(void) JL_NOTSAFEPOINT { SAVE_ERRNO; - jl_gcframe_t **pgcstack = (jl_ptls_t)TlsGetValue(jl_pgcstack_key); + jl_gcframe_t **pgcstack = (jl_gcframe_t**)TlsGetValue(jl_pgcstack_key); LOAD_ERRNO; return pgcstack; }