qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix some compiler warnings for windows
@ 2009-02-13 21:26 Stefan Weil
  2009-02-25 21:30 ` Robert Riebisch
  2009-03-01 10:38 ` Stefan Weil
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Weil @ 2009-02-13 21:26 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 92 bytes --]

Hello,

this patch fixes some warnings for compilation with mingw32.

Regards
Stefan Weil



[-- Attachment #2: winwarnings.patch --]
[-- Type: text/x-diff, Size: 10884 bytes --]

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 <weil@mail.berlios.de>

Index: trunk/block-raw-win32.c
===================================================================
--- trunk.orig/block-raw-win32.c	2009-02-13 21:06:15.000000000 +0100
+++ trunk/block-raw-win32.c	2009-02-13 21:13:39.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-02-13 21:17:29.000000000 +0100
+++ trunk/bt-host.c	2009-02-13 21:17:44.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-02-13 21:20:17.000000000 +0100
+++ trunk/hw/bt-sdp.c	2009-02-13 21:20:58.000000000 +0100
@@ -787,10 +787,12 @@
         .type       = SDP_DTYPE_UUID | SDP_DSIZE_16,	\
         .value.uint = val,				\
     },
+#undef TRUE
 #define TRUE	{				\
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,	\
         .value.uint = 1,				\
     },
+#undef FALSE
 #define FALSE	{				\
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,	\
         .value.uint = 0,				\
Index: trunk/nbd.c
===================================================================
--- trunk.orig/nbd.c	2009-02-13 21:06:37.000000000 +0100
+++ trunk/nbd.c	2009-02-13 21:16:39.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-02-13 21:27:36.000000000 +0100
+++ trunk/slirp/socket.h	2009-02-13 21:28:00.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-02-13 21:21:30.000000000 +0100
+++ trunk/tap-win32.c	2009-02-13 21:25:35.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-02-13 21:37:06.000000000 +0100
+++ trunk/exec.c	2009-02-13 21:40:16.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 <windows.h>
-#else
+#include "qemu-common.h"
+#ifndef _WIN32
 #include <sys/types.h>
 #include <sys/mman.h>
 #endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <inttypes.h>
 
 #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-02-13 21:38:12.000000000 +0100
+++ trunk/kqemu.c	2009-02-13 21:40:00.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 <windows.h>
 #include <winioctl.h>
 #else
 #include <sys/types.h>
@@ -30,17 +29,9 @@
 #ifdef HOST_SOLARIS
 #include <sys/ioccom.h>
 #endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <inttypes.h>
 
 #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-02-13 21:29:30.000000000 +0100
+++ trunk/slirp/tftp.c	2009-02-13 21:29:33.000000000 +0100
@@ -22,8 +22,8 @@
  * THE SOFTWARE.
  */
 
-#include <slirp.h>
 #include "qemu-common.h" // for pstrcpy
+#include <slirp.h>
 
 struct tftp_session {
     int in_use;
Index: trunk/vl.c
===================================================================
--- trunk.orig/vl.c	2009-02-13 21:29:52.000000000 +0100
+++ trunk/vl.c	2009-02-13 21:34:31.000000000 +0100
@@ -229,7 +229,9 @@
 int no_shutdown = 0;
 int cursor_hide = 1;
 int graphic_rotate = 0;
+#ifndef _WIN32
 int daemonize = 0;
+#endif
 const char *option_rom[MAX_OPTION_ROMS];
 int nb_option_roms;
 int semihosting_enabled = 0;
@@ -1279,8 +1281,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
@@ -4168,7 +4171,9 @@
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_no_shutdown,
     QEMU_OPTION_loadvm,
+#ifndef _WIN32
     QEMU_OPTION_daemonize,
+#endif
     QEMU_OPTION_option_rom,
     QEMU_OPTION_prom_env,
     QEMU_OPTION_clock,
@@ -4291,7 +4296,9 @@
     { "no-reboot", 0, QEMU_OPTION_no_reboot },
     { "no-shutdown", 0, QEMU_OPTION_no_shutdown },
     { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
+#ifndef _WIN32
     { "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 },
@@ -4616,7 +4623,9 @@
     const char *cpu_model;
     const char *usb_devices[MAX_USB_CMDLINE];
     int usb_devices_index;
+#ifndef _WIN32
     int fds[2];
+#endif
     int tb_size;
     const char *pid_file = NULL;
     int autostart;
@@ -5182,9 +5191,11 @@
                     exit(1);
                 }
                 break;
-	    case QEMU_OPTION_daemonize:
-		daemonize = 1;
-		break;
+#ifndef _WIN32
+            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");
@@ -5345,7 +5356,6 @@
         signal(SIGTTOU, SIG_IGN);
         signal(SIGTTIN, SIG_IGN);
     }
-#endif
 
     if (pid_file && qemu_create_pidfile(pid_file) != 0) {
         if (daemonize) {
@@ -5355,6 +5365,7 @@
             fprintf(stderr, "Could not acquire pid file\n");
         exit(1);
     }
+#endif
 
 #ifdef USE_KQEMU
     if (smp_cpus > 1)
@@ -5722,6 +5733,7 @@
         }
     }
 
+#ifndef _WIN32
     if (daemonize) {
 	uint8_t status = 0;
 	ssize_t len;
@@ -5746,6 +5758,7 @@
 
 	close(fd);
     }
+#endif
 
     main_loop();
     quit_timers();
Index: trunk/hw/openpic.c
===================================================================
--- trunk.orig/hw/openpic.c	2009-02-13 21:57:30.000000000 +0100
+++ trunk/hw/openpic.c	2009-02-13 21:57:35.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 */
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix some compiler warnings for windows
  2009-02-13 21:26 [Qemu-devel] [PATCH] Fix some compiler warnings for windows Stefan Weil
@ 2009-02-25 21:30 ` Robert Riebisch
  2009-03-01 10:38 ` Stefan Weil
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Riebisch @ 2009-02-25 21:30 UTC (permalink / raw)
  To: qemu-devel

Stefan Weil wrote:

> this patch fixes some warnings for compilation with mingw32.

Why does nobody care about this?

Robert Riebisch
-- 
BTTR Software
http://www.bttr-software.de/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix some compiler warnings for windows
  2009-02-13 21:26 [Qemu-devel] [PATCH] Fix some compiler warnings for windows Stefan Weil
  2009-02-25 21:30 ` Robert Riebisch
@ 2009-03-01 10:38 ` Stefan Weil
  2009-03-01 12:00   ` malc
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2009-03-01 10:38 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

Stefan Weil schrieb:
> Hello,
>
> this patch fixes some warnings for compilation with mingw32.
>
> Regards
> Stefan Weil

Here is an update of my patch for the current Qemu trunk.
It reduces the number of warnings for win32 from 256 to 67.

At least one warning indicates an error in Qemu for Windows:
vl.c:5386: warning: fds[1] is used uninitialized in this function
This was fixed, too.

Could one of the maintainers please apply this patch to Qemu trunk?

Regards
Stefan Weil




[-- Attachment #2: winwarnings.patch --]
[-- Type: text/x-diff, Size: 11854 bytes --]

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 <weil@mail.berlios.de>

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 <windows.h>
-#else
+#include "qemu-common.h"
+#ifndef _WIN32
 #include <sys/types.h>
 #include <sys/mman.h>
 #endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <inttypes.h>
 
 #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 <windows.h>
 #include <winioctl.h>
 #else
 #include <sys/types.h>
@@ -30,17 +29,9 @@
 #ifdef HOST_SOLARIS
 #include <sys/ioccom.h>
 #endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <inttypes.h>
 
 #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 <slirp.h>
 #include "qemu-common.h" // for pstrcpy
+#include <slirp.h>
 
 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 */
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix some compiler warnings for windows
  2009-03-01 10:38 ` Stefan Weil
@ 2009-03-01 12:00   ` malc
  2009-03-01 17:38     ` Stefan Weil
  0 siblings, 1 reply; 5+ messages in thread
From: malc @ 2009-03-01 12:00 UTC (permalink / raw)
  To: qemu-devel

On Sun, 1 Mar 2009, Stefan Weil wrote:

> Stefan Weil schrieb:
> > Hello,
> >
> > this patch fixes some warnings for compilation with mingw32.
> >
> > Regards
> > Stefan Weil
> 
> Here is an update of my patch for the current Qemu trunk.
> It reduces the number of warnings for win32 from 256 to 67.
> 
> At least one warning indicates an error in Qemu for Windows:
> vl.c:5386: warning: fds[1] is used uninitialized in this function
> This was fixed, too.
> 
> Could one of the maintainers please apply this patch to Qemu trunk?

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;

[..snip..]

http://msdn.microsoft.com/en-us/library/aa364955(VS.85).aspx
DWORD WINAPI GetFileSize(
  __in       HANDLE hFile,
  __out_opt  LPDWORD lpFileSizeHigh
);

IOW LONG doesn't seem to be correct.

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] Fix some compiler warnings for windows
  2009-03-01 12:00   ` malc
@ 2009-03-01 17:38     ` Stefan Weil
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Weil @ 2009-03-01 17:38 UTC (permalink / raw)
  To: qemu-devel

malc schrieb:
> On Sun, 1 Mar 2009, Stefan Weil wrote:
>
>   
>> Stefan Weil schrieb:
>>     
>>> Hello,
>>>
>>> this patch fixes some warnings for compilation with mingw32.
>>>
>>> Regards
>>> Stefan Weil
>>>       
>> Here is an update of my patch for the current Qemu trunk.
>> It reduces the number of warnings for win32 from 256 to 67.
>>
>> At least one warning indicates an error in Qemu for Windows:
>> vl.c:5386: warning: fds[1] is used uninitialized in this function
>> This was fixed, too.
>>
>> Could one of the maintainers please apply this patch to Qemu trunk?
>>     
>
> 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;
>
> [..snip..]
>
> http://msdn.microsoft.com/en-us/library/aa364955(VS.85).aspx
> DWORD WINAPI GetFileSize(
>   __in       HANDLE hFile,
>   __out_opt  LPDWORD lpFileSizeHigh
> );
>
> IOW LONG doesn't seem to be correct.
>
>   

LONG low, high belongs to a call to SetFilePointer which takes LONG, PLONG
arguments: http://msdn.microsoft.com/en-us/library/aa365541(VS.85).aspx

GetFileSize is in another function.

Everything (not really, but more than now) will be correct, when my patch
is finally applied :-)

Regards
Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-01 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-13 21:26 [Qemu-devel] [PATCH] Fix some compiler warnings for windows Stefan Weil
2009-02-25 21:30 ` Robert Riebisch
2009-03-01 10:38 ` Stefan Weil
2009-03-01 12:00   ` malc
2009-03-01 17:38     ` Stefan Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).