Fix some compiler warnings for mingw32: * fix data types for win32 api (block-raw-win32.c, tap-win32.c) * add missing include (bt-host.c) * fix symbol redefinition (hw/bt-sdp.c, hw/openpic.c) * add casts where needed (nbd.c) * add forward declaration (slirp/socket.h) * remove some includes which are also included in qemu-common.h and include qemu-common.h before other include files (exec.c, kqemu.c, slirp/tftp.c) * remove unsupported daemonize option for windows and add missing static for host_alarm_handler (vl.c) Signed-off-by: Stefan Weil Index: trunk/block-raw-win32.c =================================================================== --- trunk.orig/block-raw-win32.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/block-raw-win32.c 2009-03-01 11:04:10.000000000 +0100 @@ -279,7 +279,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) { BDRVRawState *s = bs->opaque; - DWORD low, high; + LONG low, high; low = offset; high = offset >> 32; @@ -301,7 +301,8 @@ switch(s->type) { case FTYPE_FILE: - l.LowPart = GetFileSize(s->hfile, &l.HighPart); + l.LowPart = GetFileSize(s->hfile, &count); + l.HighPart = count; if (l.LowPart == 0xffffffffUL && GetLastError() != NO_ERROR) return -EIO; break; Index: trunk/bt-host.c =================================================================== --- trunk.orig/bt-host.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/bt-host.c 2009-03-01 11:04:10.000000000 +0100 @@ -197,6 +197,7 @@ return &s->hci; } #else +# include "hw/bt.h" struct HCIInfo *bt_host_hci(const char *id) { fprintf(stderr, "qemu: bluetooth passthrough not supported (yet)\n"); Index: trunk/hw/bt-sdp.c =================================================================== --- trunk.orig/hw/bt-sdp.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/hw/bt-sdp.c 2009-03-01 11:22:13.000000000 +0100 @@ -21,6 +21,9 @@ #include "qemu-common.h" #include "bt.h" +#undef TRUE +#undef FALSE + struct bt_l2cap_sdp_state_s { struct bt_l2cap_conn_params_s *channel; Index: trunk/nbd.c =================================================================== --- trunk.orig/nbd.c 2009-03-01 11:04:02.000000000 +0100 +++ trunk/nbd.c 2009-03-01 11:04:10.000000000 +0100 @@ -169,7 +169,7 @@ memcpy(&addr.sin_addr.s_addr, &in, sizeof(in)); opt = 1; - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1) { + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt)) == -1) { goto error; } @@ -579,7 +579,7 @@ if ((request.from + request.len) > size) { LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64 ", Offset: %" PRIu64 "\n", - request.from, request.len, size, dev_offset); + request.from, request.len, (uint64_t)size, dev_offset); LOG("requested operation past EOF--bad client?"); errno = EINVAL; return -1; Index: trunk/slirp/socket.h =================================================================== --- trunk.orig/slirp/socket.h 2009-03-01 11:04:03.000000000 +0100 +++ trunk/slirp/socket.h 2009-03-01 11:04:10.000000000 +0100 @@ -13,6 +13,8 @@ #define SO_EXPIRE 240000 #define SO_EXPIREFAST 10000 +struct iovec; + /* * Our socket structure */ Index: trunk/tap-win32.c =================================================================== --- trunk.orig/tap-win32.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/tap-win32.c 2009-03-01 11:04:10.000000000 +0100 @@ -214,9 +214,9 @@ char unit_string[256]; HKEY unit_key; char component_id_string[] = "ComponentId"; - char component_id[256]; + BYTE component_id[256]; char net_cfg_instance_id_string[] = "NetCfgInstanceId"; - char net_cfg_instance_id[256]; + BYTE net_cfg_instance_id[256]; DWORD data_type; len = sizeof (enum_name); @@ -270,7 +270,7 @@ if (status == ERROR_SUCCESS && data_type == REG_SZ) { if (/* !strcmp (component_id, TAP_COMPONENT_ID) &&*/ - !strcmp (net_cfg_instance_id, guid)) { + !strcmp ((char *)net_cfg_instance_id, guid)) { RegCloseKey (unit_key); RegCloseKey (netcard_key); return TRUE; @@ -314,7 +314,7 @@ char enum_name[256]; char connection_string[256]; HKEY connection_key; - char name_data[256]; + BYTE name_data[256]; DWORD name_type; const char name_string[] = "Name"; @@ -365,7 +365,7 @@ snprintf(name, name_size, "%s", enum_name); if (actual_name) { if (strcmp(actual_name, "") != 0) { - if (strcmp(name_data, actual_name) != 0) { + if (strcmp((char *)name_data, actual_name) != 0) { RegCloseKey (connection_key); ++i; continue; @@ -561,7 +561,7 @@ } static void tap_win32_free_buffer(tap_win32_overlapped_t *overlapped, - char* pbuf) + uint8_t *pbuf) { tun_buffer_t* buffer = (tun_buffer_t*)pbuf; put_buffer_on_free_list(overlapped, buffer); @@ -581,7 +581,7 @@ unsigned long minor; unsigned long debug; } version; - LONG version_len; + DWORD version_len; DWORD idThread; HANDLE hThread; Index: trunk/exec.c =================================================================== --- trunk.orig/exec.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/exec.c 2009-03-01 11:04:10.000000000 +0100 @@ -18,24 +18,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA */ #include "config.h" -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#else +#include "qemu-common.h" +#ifndef _WIN32 #include #include #endif -#include -#include -#include -#include -#include -#include -#include #include "cpu.h" #include "exec-all.h" -#include "qemu-common.h" #include "tcg.h" #include "hw/hw.h" #include "osdep.h" Index: trunk/kqemu.c =================================================================== --- trunk.orig/kqemu.c 2009-03-01 11:04:02.000000000 +0100 +++ trunk/kqemu.c 2009-03-01 11:04:10.000000000 +0100 @@ -18,9 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA */ #include "config.h" +#include "qemu-common.h" #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include #include #else #include @@ -30,17 +29,9 @@ #ifdef HOST_SOLARIS #include #endif -#include -#include -#include -#include -#include -#include -#include #include "cpu.h" #include "exec-all.h" -#include "qemu-common.h" #ifdef USE_KQEMU Index: trunk/slirp/tftp.c =================================================================== --- trunk.orig/slirp/tftp.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/slirp/tftp.c 2009-03-01 11:04:10.000000000 +0100 @@ -22,8 +22,8 @@ * THE SOFTWARE. */ -#include #include "qemu-common.h" // for pstrcpy +#include struct tftp_session { int in_use; Index: trunk/vl.c =================================================================== --- trunk.orig/vl.c 2009-03-01 11:04:02.000000000 +0100 +++ trunk/vl.c 2009-03-01 11:25:51.000000000 +0100 @@ -157,6 +157,10 @@ #include "exec-all.h" +#ifndef _WIN32 +# define CONFIG_DAEMONIZE +#endif + //#define DEBUG_UNUSED_IOPORT //#define DEBUG_IOPORT //#define DEBUG_NET @@ -237,7 +241,9 @@ int no_shutdown = 0; int cursor_hide = 1; int graphic_rotate = 0; +#ifdef CONFIG_DAEMONIZE int daemonize = 0; +#endif const char *option_rom[MAX_OPTION_ROMS]; int nb_option_roms; int semihosting_enabled = 0; @@ -1287,8 +1293,9 @@ } #ifdef _WIN32 -void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, - DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) +static void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, + DWORD_PTR dwUser, + DWORD_PTR dw1, DWORD_PTR dw2) #else static void host_alarm_handler(int host_signum) #endif @@ -4050,8 +4057,8 @@ "-no-shutdown stop before shutdown\n" "-loadvm [tag|id]\n" " start right away with a saved state (loadvm in monitor)\n" -#ifndef _WIN32 - "-daemonize daemonize QEMU after initializing\n" +#ifdef CONFIG_DAEMONIZE + "-daemonize daemonize QEMU after initializing\n" #endif "-option-rom rom load a file, rom, into the option ROM space\n" #if defined(TARGET_SPARC) || defined(TARGET_PPC) @@ -4183,7 +4190,9 @@ QEMU_OPTION_no_reboot, QEMU_OPTION_no_shutdown, QEMU_OPTION_loadvm, +#ifdef CONFIG_DAEMONIZE QEMU_OPTION_daemonize, +#endif QEMU_OPTION_option_rom, QEMU_OPTION_prom_env, QEMU_OPTION_clock, @@ -4309,7 +4318,9 @@ { "no-reboot", 0, QEMU_OPTION_no_reboot }, { "no-shutdown", 0, QEMU_OPTION_no_shutdown }, { "loadvm", HAS_ARG, QEMU_OPTION_loadvm }, +#ifdef CONFIG_DAEMONIZE { "daemonize", 0, QEMU_OPTION_daemonize }, +#endif { "option-rom", HAS_ARG, QEMU_OPTION_option_rom }, #if defined(TARGET_SPARC) || defined(TARGET_PPC) { "prom-env", HAS_ARG, QEMU_OPTION_prom_env }, @@ -4636,7 +4647,9 @@ const char *cpu_model; const char *usb_devices[MAX_USB_CMDLINE]; int usb_devices_index; +#ifdef CONFIG_DAEMONIZE int fds[2]; +#endif int tb_size; const char *pid_file = NULL; int autostart; @@ -5211,9 +5224,11 @@ exit(1); } break; - case QEMU_OPTION_daemonize: - daemonize = 1; - break; +#ifdef CONFIG_DAEMONIZE + case QEMU_OPTION_daemonize: + daemonize = 1; + break; +#endif case QEMU_OPTION_option_rom: if (nb_option_roms >= MAX_OPTION_ROMS) { fprintf(stderr, "Too many option ROMs\n"); @@ -5335,7 +5350,7 @@ monitor_device = "stdio"; } -#ifndef _WIN32 +#ifdef CONFIG_DAEMONIZE if (daemonize) { pid_t pid; @@ -5378,7 +5393,6 @@ signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); } -#endif if (pid_file && qemu_create_pidfile(pid_file) != 0) { if (daemonize) { @@ -5388,6 +5402,7 @@ fprintf(stderr, "Could not acquire pid file\n"); exit(1); } +#endif /* CONFIG_DAEMONIZE */ #ifdef USE_KQEMU if (smp_cpus > 1) @@ -5755,6 +5770,7 @@ } } +#ifdef CONFIG_DAEMONIZE if (daemonize) { uint8_t status = 0; ssize_t len; @@ -5773,7 +5789,6 @@ exit(1); } -#ifndef _WIN32 if (run_as) { pwd = getpwnam(run_as); if (!pwd) { @@ -5804,7 +5819,6 @@ exit(1); } } -#endif if (daemonize) { dup2(fd, 0); @@ -5813,6 +5827,7 @@ close(fd); } +#endif /* CONFIG_DAEMONIZE */ main_loop(); quit_timers(); Index: trunk/hw/openpic.c =================================================================== --- trunk.orig/hw/openpic.c 2009-03-01 11:04:03.000000000 +0100 +++ trunk/hw/openpic.c 2009-03-01 11:04:10.000000000 +0100 @@ -43,7 +43,6 @@ #else #define DPRINTF(fmt, args...) do { } while (0) #endif -#define ERROR(fmr, args...) do { printf("ERROR: " fmr , ##args); } while (0) #define USE_MPCxxx /* Intel model is broken, for now */