fix some warnings
authorkub <derkub@gmail.com>
Thu, 5 Sep 2024 20:00:30 +0000 (22:00 +0200)
committerkub <derkub@gmail.com>
Thu, 5 Sep 2024 20:00:30 +0000 (22:00 +0200)
linux/host_dasm.c
linux/plat.c
menu.c
plat_sdl.c
posix.h

index a5e66c9..a46a073 100644 (file)
@@ -24,17 +24,17 @@ static struct disassemble_info di;
 static disassembler_ftype print_insn_func;
 
 #if defined __arm__
-#define print_insn_func print_insn_little_arm
+//#define print_insn_func print_insn_little_arm
 #define BFD_ARCH bfd_arch_arm
 #define BFD_MACH bfd_mach_arm_unknown
 #define DASM_OPTS "reg-names-std"
 #elif defined __aarch64__
-#define print_insn_func print_insn_aarch64
+//#define print_insn_func print_insn_aarch64
 #define BFD_ARCH bfd_arch_aarch64
 #define BFD_MACH bfd_mach_aarch64
 #define DASM_OPTS NULL
 #elif defined __mips__
-#define print_insn_func print_insn_little_mips
+//#define print_insn_func print_insn_little_mips
 #define BFD_ARCH bfd_arch_mips
 #define BFD_MACH bfd_mach_mipsisa64r2
 #define DASM_OPTS NULL
@@ -44,12 +44,12 @@ static disassembler_ftype print_insn_func;
 #define BFD_MACH bfd_mach_riscv64
 #define DASM_OPTS NULL
 #elif defined __powerpc__
-#define print_insn_func print_insn_little_powerpc
+//#define print_insn_func print_insn_little_powerpc
 #define BFD_ARCH bfd_arch_powerpc
 #define BFD_MACH bfd_mach_ppc64
 #define DASM_OPTS NULL
 #elif defined(__x86_64__) || defined(__i386__)
-#define print_insn_func print_insn_i386_intel
+//#define print_insn_func print_insn_i386_intel
 #define BFD_ARCH bfd_arch_i386
 #ifdef __x86_64__
 #define BFD_MACH bfd_mach_x86_64_intel_syntax
@@ -205,13 +205,31 @@ static int print_insn_hex(bfd_vma addr, struct disassemble_info *info)
   return 4;
 }
 
+#ifdef BFD_COMPRESS_ZSTD
+static int insn_printf_styled(void *f, enum disassembler_style style, const char* format, ...)
+{
+  va_list args;
+  size_t n;
+
+  va_start(args, format);
+  n = vprintf(format, args);
+  va_end(args);
+
+  return n;
+}
+#endif
+
 static void host_dasm_init(void)
 {
   bfd_init();
   if (g_argv && g_argv[0])
     slurp_symtab(g_argv[0]);
 
+#ifdef BFD_COMPRESS_ZSTD
+  init_disassemble_info(&di, NULL, insn_printf, insn_printf_styled);
+#else
   init_disassemble_info(&di, NULL, insn_printf);
+#endif
   di.flavour = bfd_target_unknown_flavour;
   di.memory_error_func = dis_asm_memory_error; 
   di.print_address_func = dis_asm_print_address;
index 9ed3637..c4ce811 100644 (file)
 #include <sys/time.h>
 #include <time.h>
 #include <unistd.h>
-#include <sys/mman.h>
 #include <errno.h>
 #include <sys/stat.h>
+#ifndef __MINGW32__
+#include <sys/mman.h>
+#endif
 
 #include "../plat.h"
+#include "../posix.h"
 
 /* XXX: maybe unhardcode pagesize? */
 #define HUGETLB_PAGESIZE (2 * 1024 * 1024)
diff --git a/menu.c b/menu.c
index 5eb48b9..72c913b 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1161,7 +1161,7 @@ rescan:
                                } else {\r
                                        strcpy(newdir, curr_path);\r
                                        p = newdir + strlen(newdir) - 1;\r
-                                       while (*p == '/' && p >= newdir) *p-- = 0;\r
+                                       while (p >= newdir && *p == '/') *p-- = 0;\r
                                        strcat(newdir, "/");\r
                                        strcat(newdir, namelist[sel]->d_name);\r
                                }\r
index 2d537f0..ff92c6a 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <stdio.h>
+#include <stdint.h>
 #include <SDL.h>
 #include <SDL_syswm.h>
 
@@ -107,7 +108,7 @@ int plat_sdl_change_video_mode(int w, int h, int force)
     int W = plat_target.vout_method == vout_mode_overlay2x && w < 640 ? 2*w : w;
     plat_sdl_overlay = SDL_CreateYUVOverlay(W, h, SDL_UYVY_OVERLAY, plat_sdl_screen);
     if (plat_sdl_overlay != NULL && SDL_LockYUVOverlay(plat_sdl_overlay) == 0) {
-      if ((long)plat_sdl_overlay->pixels[0] & 3)
+      if ((uintptr_t)plat_sdl_overlay->pixels[0] & 3)
         fprintf(stderr, "warning: overlay pointer is unaligned\n");
 
       plat_sdl_overlay_clear();
diff --git a/posix.h b/posix.h
index 15d217f..003bb7a 100644 (file)
--- a/posix.h
+++ b/posix.h
 #define mkdir(pathname,mode) mkdir(pathname)
 #define d_type d_ino
 #define DT_REG 0
-#define DT_DIR 0
+#define DT_DIR 1
+#define DT_LNK 2
+#define DT_UNKNOWN -1
+#define readlink(p,d,s)                -1
 #endif
 
 #else