Fix a variety of warnings (#811)
authorВиктор Чернякин <56512186+LocalSpook@users.noreply.github.com>
Fri, 22 Dec 2023 10:30:50 +0000 (03:30 -0700)
committerGitHub <noreply@github.com>
Fri, 22 Dec 2023 10:30:50 +0000 (05:30 -0500)
include/ffi_common.h
src/closures.c
src/debug.c
src/dlmalloc.c
src/tramp.c
src/x86/ffiw64.c

index c53a7949348a1139fa5fa71ff82f609720725e9f..a9839b344d5fd1b60a840c12276c8e10cd660c35 100644 (file)
@@ -49,8 +49,10 @@ extern "C" {
 #  endif
 # endif
 # define MAYBE_UNUSED __attribute__((__unused__))
+# define NORETURN __attribute__((__noreturn__))
 #else
 # define MAYBE_UNUSED
+# define NORETURN
 # if HAVE_ALLOCA_H
 #  include <alloca.h>
 # else
@@ -82,9 +84,9 @@ char *alloca ();
 #endif
 
 #ifdef FFI_DEBUG
-void ffi_assert(char *expr, char *file, int line);
+NORETURN void ffi_assert(const char *expr, const char *file, int line);
 void ffi_stop_here(void);
-void ffi_type_test(ffi_type *a, char *file, int line);
+void ffi_type_test(ffi_type *a, const char *file, int line);
 
 #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
 #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
index 0f2d6197e7faf6cc8f973aafc1829d3c16f73f8a..67a94a822ca0cbe34ae0890833209edd96290039 100644 (file)
@@ -599,7 +599,7 @@ open_temp_exec_file_memfd (const char *name)
 
 /* Open a temporary file name, and immediately unlink it.  */
 static int
-open_temp_exec_file_name (char *name, int flags)
+open_temp_exec_file_name (char *name, int flags MAYBE_UNUSED)
 {
   int fd;
 
@@ -795,7 +795,7 @@ open_temp_exec_file (void)
    Failure to allocate the space will cause SIGBUS to be thrown when
    the mapping is subsequently written to.  */
 static int
-allocate_space (int fd, off_t offset, off_t len)
+allocate_space (int fd, off_t len)
 {
   static long page_size;
 
@@ -838,7 +838,7 @@ dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
 
   offset = execsize;
 
-  if (allocate_space (execfd, offset, length))
+  if (allocate_space (execfd, length))
     return MFAIL;
 
   flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
index f3172b1ef6c9a9f04870cc76815984091de95da9..63321dc013cc276d80e4ce425fa359eccb90b7b5 100644 (file)
@@ -38,7 +38,7 @@ void ffi_stop_here(void)
 
 /* This function should only be called via the FFI_ASSERT() macro */
 
-void ffi_assert(char *expr, char *file, int line)
+NORETURN void ffi_assert(const char *expr, const char *file, int line)
 {
   fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
   ffi_stop_here();
@@ -47,7 +47,7 @@ void ffi_assert(char *expr, char *file, int line)
 
 /* Perform a sanity check on an ffi_type structure */
 
-void ffi_type_test(ffi_type *a, char *file, int line)
+void ffi_type_test(ffi_type *a, const char *file, int line)
 {
   FFI_ASSERT_AT(a != NULL, file, line);
 
index 6f4a5f6c464361d4a57e508390478e8d288c50ef..c61ef9240abf33bb9e72ad3f9017fa28bc7cc88e 100644 (file)
@@ -4452,7 +4452,7 @@ struct mallinfo dlmallinfo(void) {
 }
 #endif /* NO_MALLINFO */
 
-void dlmalloc_stats() {
+void dlmalloc_stats(void) {
   internal_malloc_stats(gm);
 }
 
index 5f19b557f934647de7288049c3737f99a4c048d3..8ec08486875702e9f50fe6ec7a0e6184a2f84e17 100644 (file)
@@ -307,7 +307,7 @@ ffi_tramp_lock(void)
 }
 
 static void
-ffi_tramp_unlock()
+ffi_tramp_unlock(void)
 {
   pthread_mutex_unlock (&tramp_globals_mutex);
 }
index 827165868f15225d51f42233fc5d0a862dbea169..2be8b99279ab8e92fb1197b4cd04e8609acb848c 100644 (file)
@@ -227,7 +227,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
                      ffi_cif* cif,
                      void (*fun)(ffi_cif*, void*, void**, void*),
                      void *user_data,
-                     void *codeloc)
+                     void *codeloc MAYBE_UNUSED)
 {
   static const unsigned char trampoline[FFI_TRAMPOLINE_SIZE - 8] = {
     /* endbr64 */