[Spice-commits] 22 commits - Makefile.am common/stdint.h common/vdcommon.h common/vdlog.cpp common/vdlog.h configure.ac git.mk vdagent/desktop_layout.cpp vdagent/display_setting.cpp vdagent/display_setting.h vdagent/vdagent.cpp vdservice/pci_vdi_port.cpp vdservice/vdi_port.cpp vdservice/vdservice.cpp vdservice/virtio_vdi_port.cpp

Christophe Fergau teuf at kemper.freedesktop.org
Thu Mar 1 07:56:46 PST 2012


 Makefile.am                   |   48 ++++++++++
 common/stdint.h               |    2 
 common/vdcommon.h             |   14 ++
 common/vdlog.cpp              |    2 
 common/vdlog.h                |   10 +-
 configure.ac                  |   87 ++++++++++++++++++
 git.mk                        |  200 ++++++++++++++++++++++++++++++++++++++++++
 vdagent/desktop_layout.cpp    |   11 +-
 vdagent/display_setting.cpp   |   55 +++++------
 vdagent/display_setting.h     |    2 
 vdagent/vdagent.cpp           |   78 ++++++++--------
 vdservice/pci_vdi_port.cpp    |    9 +
 vdservice/vdi_port.cpp        |    2 
 vdservice/vdservice.cpp       |   56 +++++------
 vdservice/virtio_vdi_port.cpp |   10 +-
 15 files changed, 474 insertions(+), 112 deletions(-)

New commits:
commit 6670fc556ae0f3bbfd850de02a746804bf9beaec
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 1 14:32:39 2012 +0100

    Fix spacing in VDAgent initialization list
    
    The convention in vdagent codebase seems to put a space before
    the opening parenthesis in initialization list, this commit fixes
    2 inconsistencies related to that.

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index aeef433..5ef0a18 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -178,8 +178,8 @@ VDAgent::VDAgent()
     , _display_setting (VD_AGENT_REGISTRY_KEY)
     , _logon_desktop (false)
     , _display_setting_initialized (false)
-    , _client_caps(NULL)
-    , _client_caps_size(0)
+    , _client_caps (NULL)
+    , _client_caps_size (0)
     , _log (NULL)
 {
     TCHAR log_path[MAX_PATH];
commit 63541ea6ac722d332966f28e1779e4d668244fcb
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Feb 23 22:33:48 2012 +0100

    mingw: remove tMain use
    
    mingw does not support it.

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 66b92de..aeef433 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -1355,7 +1355,7 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA
     return 0;
 }
 
-int APIENTRY _tWinMain(HINSTANCE instance, HINSTANCE prev_instance, LPTSTR cmd_line, int cmd_show)
+int main(int argc,char **argv)
 {
     VDAgent* vdagent = VDAgent::get();
     vdagent->run();
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 4701f5a..9c057bb 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -1216,7 +1216,7 @@ void VDService::write_agent_control(uint32_t type, uint32_t opaque)
     }
 }
 
-int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
+int main(int argc, char* argv[], char* envp[])
 {
     bool success = false;
 
@@ -1226,9 +1226,9 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
     }
     VDService* vdservice = VDService::get();
     if (argc > 1) {
-        if (lstrcmpi(argv[1], TEXT("install")) == 0) {
+        if (strcmp(argv[1], "install") == 0) {
             success = vdservice->install();
-        } else if (lstrcmpi(argv[1], TEXT("uninstall")) == 0) {
+        } else if (strcmp(argv[1], "uninstall") == 0) {
             success = vdservice->uninstall();
         } else {
             printf("Use: vdservice install / uninstall\n");
commit 04e53efb312cdb1244b11e10f621fe8569c468f2
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Feb 20 18:11:29 2012 +0100

    mingw: make sure unicode support is enabled
    
    UNICODE and _UNICODE must be defined before including any mingw
    header for proper unicode support.

diff --git a/Makefile.am b/Makefile.am
index cf514f1..2e845ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 INCLUDES =				\
 	-I$(top_srcdir)/common		\
 	$(SPICE_PROTOCOL_CFLAGS)
+AM_CPPFLAGS=-DUNICODE -D_UNICODE
 
 bin_PROGRAMS = vdagent vdservice
 
commit 8da556a6c17588c38d556022e949b499ea704e42
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Feb 23 22:38:30 2012 +0100

    mingw: add Visual C++ files to EXTRA_DIST

diff --git a/Makefile.am b/Makefile.am
index 0aa0328..cf514f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,4 +34,14 @@ vdservice_LDADD = -lwtsapi32
 vdagent_LDADD = $(CXIMAGE_LIBS)
 vdagent_CXXFLAGS = $(CXIMAGE_CFLAGS)
 
+EXTRA_DIST =			\
+	tests/clipboard.py	\
+	vdagent.sln		\
+	vdagent/resource.h	\
+	vdagent/vdagent.rc	\
+	vdagent/vdagent.vcproj	\
+	vdservice/vdservice.rc	\
+	vdservice/vdservice.vcproj
+
+
 -include $(top_srcdir)/git.mk
commit 84628d54755b66076da402015341100f7b9a0027
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Feb 20 18:10:09 2012 +0100

    mingw: workaround _ftime_s bug
    
    mingw has a _ftime_s prototype in its headers, but no corresponding
    symbol available at link time. Workaround this issue for now by
     #defining it to _ftime. This is untested on win64 where the workaround
    may not be needed.

diff --git a/common/vdlog.h b/common/vdlog.h
index eebb0d2..b2a7295 100644
--- a/common/vdlog.h
+++ b/common/vdlog.h
@@ -57,13 +57,19 @@ static unsigned int log_level = LOG_INFO;
     printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms,       \
            __FUNCTION__, ## __VA_ARGS__);
 
+#ifdef __MINGW32__
+#define vd_ftime_s _ftime
+#else
+#define vd_ftime_s _ftime_s
+#endif
+
 #define LOG(type, format, ...) if (type >= log_level && type <= LOG_FATAL) {                    \
     VDLog* log = VDLog::get();                                                                  \
     const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" };                 \
     struct _timeb now;                                                                          \
     struct tm today;                                                                            \
     char datetime_str[20];                                                                      \
-    _ftime_s(&now);                                                                             \
+    vd_ftime_s(&now);                                                                             \
     localtime_s(&today, &now.time);                                                             \
     strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S", &today);                                    \
     if (log) {                                                                                  \
commit 025d0bd58019051ef269c8b80147ba38964308d8
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Feb 20 17:45:25 2012 +0100

    mingw: add autotools build system
    
    This makes building with mingw much more convenient.

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..0aa0328
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,37 @@
+INCLUDES =				\
+	-I$(top_srcdir)/common		\
+	$(SPICE_PROTOCOL_CFLAGS)
+
+bin_PROGRAMS = vdagent vdservice
+
+vdagent_SOURCES =			\
+	common/vdcommon.h		\
+	common/vdlog.cpp		\
+	common/vdlog.h			\
+	vdagent/desktop_layout.cpp	\
+	vdagent/desktop_layout.h	\
+	vdagent/display_setting.cpp	\
+	vdagent/display_setting.h	\
+	vdagent/vdagent.cpp
+
+vdservice_SOURCES =			\
+	common/stdint.h			\
+	common/vdcommon.h		\
+	common/vdlog.cpp		\
+	common/vdlog.h			\
+	vdservice/vdservice.cpp		\
+	vdservice/pci_vdi_port.cpp	\
+	vdservice/pci_vdi_port.h	\
+	vdservice/vdi_port.h		\
+	vdservice/vdi_port.cpp		\
+	vdservice/virtio_vdi_port.h	\
+	vdservice/virtio_vdi_port.cpp
+
+# -lversion is needed for the GetFileVersion* API which is used by
+# vdlog.cpp
+LIBS = -lversion
+vdservice_LDADD = -lwtsapi32
+vdagent_LDADD = $(CXIMAGE_LIBS)
+vdagent_CXXFLAGS = $(CXIMAGE_CFLAGS)
+
+-include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..77d5c25
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,87 @@
+# Copyright (C) 2010 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2011 Christophe Fergeau <cfergeau at redhat.com>
+AC_PREREQ(2.63)
+
+m4_define([vdagent_major_version], [0])
+m4_define([vdagent_minor_version], [0])
+m4_define([vdagent_micro_version], [1])
+m4_define([vdagent_version],
+          [vdagent_major_version.vdagent_minor_version.vdagent_micro_version])
+
+AC_INIT([vdagent-win],[vdagent_version])
+AC_CONFIG_SRCDIR([vdagent])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR([build-aux])
+
+AM_INIT_AUTOMAKE([1.11 subdir-objects no-dist-gzip dist-xz tar-ustar])
+
+AM_SILENT_RULES([yes])
+
+# Check for programs
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+
+dnl ---------------------------------------------------------------------------
+dnl - Extra verbose warning switches
+dnl ---------------------------------------------------------------------------
+
+if test "$GCC" = "yes"; then
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wall"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wcast-align -Wno-uninitialized"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wmissing-declarations"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wpointer-arith"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wcast-align"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wwrite-strings"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Winit-self"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wreturn-type"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wformat-nonliteral"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wformat-security"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wmissing-include-dirs"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wmissing-format-attribute"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wclobbered"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wempty-body"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wignored-qualifiers"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wsign-compare"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wtype-limits"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wuninitialized"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Waggregate-return"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wdeclaration-after-statement"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wshadow"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wno-strict-aliasing"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Winline"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Wmissing-parameter-type"
+	WARNINGFLAGS_C="$WARNINGFLAGS_C -Woverride-init"
+else
+	WARNINGFLAGS_C=""
+fi
+AC_SUBST(WARNINGFLAGS_C)
+
+dnl ---------------------------------------------------------------------------
+dnl - Check library dependencies
+dnl ---------------------------------------------------------------------------
+
+PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol])
+PKG_CHECK_MODULES(CXIMAGE, [cximage])
+
+dnl ---------------------------------------------------------------------------
+dnl - Makefiles, etc.
+dnl ---------------------------------------------------------------------------
+AC_CONFIG_FILES([
+Makefile
+])
+AC_OUTPUT
+
+dnl ==========================================================================
+echo "
+                  vdagent-win $VERSION
+                  ================
+
+        prefix:                    ${prefix}
+        datadir:                   ${datadir}
+        compiler:                  ${CXX}
+        cxxflags:                  ${CXXFLAGS}
+        cppflags:                  ${CPPFLAGS}
+"
diff --git a/git.mk b/git.mk
new file mode 100644
index 0000000..abd6c0a
--- /dev/null
+++ b/git.mk
@@ -0,0 +1,200 @@
+# git.mk
+#
+# Copyright 2009, Red Hat, Inc.
+# Written by Behdad Esfahbod
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+#
+# The canonical source for this file is pango/git.mk, or whereever the
+# header of pango/git.mk suggests in the future.
+#
+# To use in your project, import this file in your git repo's toplevel,
+# then do "make -f git.mk".  This modifies all Makefile.am files in
+# your project to include git.mk.
+#
+# This enables automatic .gitignore generation.  If you need to ignore
+# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
+# But think twice before doing that.  If a file has to be in .gitignore,
+# chances are very high that it's a generated file and should be in one
+# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
+#
+# The only case that you need to manually add a file to GITIGNOREFILES is
+# when remove files in one of mostlyclean-local, clean-local, distclean-local,
+# or maintainer-clean-local.
+#
+# Note that for files like editor backup, etc, there are better places to
+# ignore them.  See "man gitignore".
+#
+# If "make maintainer-clean" removes the files but they are not recognized
+# by this script (that is, if "git status" shows untracked files still), send
+# me the output of "git status" as well as your Makefile.am and Makefile for
+# the directories involved.
+#
+# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
+# pango/Makefile.am.
+#
+# Don't EXTRA_DIST this file.  It is supposed to only live in git clones,
+# not tarballs.  It serves no useful purpose in tarballs and clutters the
+# build dir.
+#
+# This file knows how to handle autoconf, automake, libtool, gtk-doc,
+# gnome-doc-utils, mallard, intltool, gsettings.
+#
+#
+# KNOWN ISSUES:
+#
+# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
+#   submodule doesn't find us.  If you have configure.{in,ac} files in
+#   subdirs, add a proxy git.mk file in those dirs that simply does:
+#   "include $(top_srcdir)/../git.mk".  Add more ..'s to your taste.
+#   And add those files to git.  See vte/gnome-pty-helper/git.mk for
+#   example.
+#
+# ChangeLog
+#
+# - 2010-12-06 Add support for Mallard docs
+# - 2010-12-06 Start this change log
+
+git-all: git-mk-install
+
+git-mk-install:
+	@echo Installing git makefile
+	@any_failed=; find $(top_srcdir) -name Makefile.am | while read x; do \
+		if grep 'include .*/git.mk' $$x >/dev/null; then \
+			echo $$x already includes git.mk; \
+		else \
+			failed=; \
+			echo "Updating $$x"; \
+			{ cat $$x; \
+			  echo ''; \
+			  echo '-include $$(top_srcdir)/git.mk'; \
+			} > $$x.tmp || failed=1; \
+			if test x$$failed = x; then \
+				mv $$x.tmp $$x || failed=1; \
+			fi; \
+			if test x$$failed = x; then : else \
+				echo Failed updating $$x; >&2 \
+				any_failed=1; \
+			fi; \
+	fi; done; test -z "$$any_failed"
+
+.PHONY: git-all git-mk-install
+
+
+### .gitignore generation
+
+$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
+	$(AM_V_GEN) \
+	{ \
+		if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
+			for x in \
+				$(DOC_MODULE)-decl-list.txt \
+				$(DOC_MODULE)-decl.txt \
+				tmpl/$(DOC_MODULE)-unused.sgml \
+				"tmpl/*.bak" \
+				xml html \
+			; do echo /$$x; done; \
+		fi; \
+		if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
+			for x in \
+				$(_DOC_C_DOCS) \
+				$(_DOC_LC_DOCS) \
+				$(_DOC_OMF_ALL) \
+				$(_DOC_DSK_ALL) \
+				$(_DOC_HTML_ALL) \
+				$(_DOC_MOFILES) \
+				$(_DOC_POFILES) \
+				$(DOC_H_FILE) \
+				"*/.xml2po.mo" \
+				"*/*.omf.out" \
+			; do echo /$$x; done; \
+		fi; \
+		if test "x$(gsettings_SCHEMAS)" = x; then :; else \
+			for x in \
+				$(gsettings_SCHEMAS:.xml=.valid) \
+				$(gsettings__enum_file) \
+			; do echo /$$x; done; \
+		fi; \
+		if test -f $(srcdir)/po/Makefile.in.in; then \
+			for x in \
+				po/Makefile.in.in \
+				po/Makefile.in \
+				po/Makefile \
+				po/POTFILES \
+				po/stamp-it \
+				po/.intltool-merge-cache \
+				"po/*.gmo" \
+				"po/*.mo" \
+				po/$(GETTEXT_PACKAGE).pot \
+				intltool-extract.in \
+				intltool-merge.in \
+				intltool-update.in \
+			; do echo /$$x; done; \
+		fi; \
+		if test -f $(srcdir)/configure; then \
+			for x in \
+				autom4te.cache \
+				configure \
+				config.h \
+				stamp-h1 \
+				libtool \
+				config.lt \
+			; do echo /$$x; done; \
+		fi; \
+		for x in \
+			.gitignore \
+			$(GITIGNOREFILES) \
+			$(CLEANFILES) \
+			$(PROGRAMS) \
+			$(check_PROGRAMS) \
+			$(EXTRA_PROGRAMS) \
+			$(LTLIBRARIES) \
+			so_locations \
+			.libs _libs \
+			$(MOSTLYCLEANFILES) \
+			"*.$(OBJEXT)" \
+			"*.lo" \
+			$(DISTCLEANFILES) \
+			$(am__CONFIG_DISTCLEAN_FILES) \
+			$(CONFIG_CLEAN_FILES) \
+			TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
+			"*.tab.c" \
+			$(MAINTAINERCLEANFILES) \
+			$(BUILT_SOURCES) \
+			$(DEPDIR) \
+			Makefile \
+			Makefile.in \
+			"*.orig" \
+			"*.rej" \
+			"*.bak" \
+			"*~" \
+			".*.sw[nop]" \
+			".dirstamp" \
+		; do echo /$$x; done; \
+	} | \
+	sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
+	sed 's@/[.]/@/@g' | \
+	LC_ALL=C sort | uniq > $@.tmp && \
+	mv $@.tmp $@;
+
+all: $(srcdir)/.gitignore gitignore-recurse-maybe
+gitignore-recurse-maybe:
+	@if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
+		$(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \
+	fi;
+gitignore-recurse:
+	@for subdir in $(DIST_SUBDIRS); do \
+	  case " $(SUBDIRS) " in \
+	    *" $$subdir "*) :;; \
+	    *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \
+	  esac; \
+	done
+gitignore: $(srcdir)/.gitignore gitignore-recurse
+
+maintainer-clean: gitignore-clean
+gitignore-clean:
+	-rm -f $(srcdir)/.gitignore
+
+.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
commit afade2bc00641f0889e615d91a6882972b7e69b2
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Feb 20 00:17:20 2012 +0100

    mingw: fix format string for wchar_t
    
    %ls (or %S) must be used to printf a wchar_t *

diff --git a/vdservice/virtio_vdi_port.cpp b/vdservice/virtio_vdi_port.cpp
index c33cee0..31a3862 100644
--- a/vdservice/virtio_vdi_port.cpp
+++ b/vdservice/virtio_vdi_port.cpp
@@ -69,7 +69,7 @@ bool VirtioVDIPort::init()
     _handle = CreateFile(VIOSERIAL_PORT_PATH, GENERIC_READ | GENERIC_WRITE , 0, NULL,
                          OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
     if (_handle == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateFile() %s failed: %lu", VIOSERIAL_PORT_PATH, GetLastError());
+        vd_printf("CreateFile() %ls failed: %lu", VIOSERIAL_PORT_PATH, GetLastError());
         return false;
     }
     _write.overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
commit b1e2f1a8ed7e91b99823d21d7f9ada6b19f40822
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:55:28 2012 +0100

    mingw: fix another signed/unsigned warning
    
    VDAgent::_mouse_x and VDAgent::_mouse_y are both signed but are
    always assigned values from VDAgentMouseState which are unsigned.
    gcc warns about this so change them to unsigned values.

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index a288861..66b92de 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -111,8 +111,8 @@ private:
     HWND _hwnd_next_viewer;
     int _clipboard_owner;
     DWORD _buttons_state;
-    LONG _mouse_x;
-    LONG _mouse_y;
+    ULONG _mouse_x;
+    ULONG _mouse_y;
     INPUT _input;
     DWORD _input_time;
     HANDLE _control_event;
commit 97777a13a320dac9cba654caa35df24573370ab7
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:43:02 2012 +0100

    mingw: use const char * in DisplaySetting()
    
    If we use char * instead of const char *, mingw gets confused when
    calling the constructor with a const char *: it tries to convert it
    to a mutable string through a std::string conversion and outputs
    a warning.

diff --git a/vdagent/display_setting.h b/vdagent/display_setting.h
index 923132f..8c8cdb1 100644
--- a/vdagent/display_setting.h
+++ b/vdagent/display_setting.h
@@ -35,7 +35,7 @@ public:
 
 class DisplaySetting {
 public:
-    DisplaySetting(char* registry_key) : _reg_key (registry_key) {}
+    DisplaySetting(const char* registry_key) : _reg_key (registry_key) {}
     void set(DisplaySettingOptions& opts);
     void load();
 
commit c006de51f6383e5701f9803e9b2f5cda48fabfff
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:42:26 2012 +0100

    mingw: don't redefine CTL_CODE if it's already defined

diff --git a/vdservice/pci_vdi_port.cpp b/vdservice/pci_vdi_port.cpp
index fce13bd..4deace1 100644
--- a/vdservice/pci_vdi_port.cpp
+++ b/vdservice/pci_vdi_port.cpp
@@ -24,9 +24,12 @@
 #define METHOD_BUFFERED     0
 #define FILE_ANY_ACCESS     0
 
+#ifndef CTL_CODE
+//With mingw, this is defined in winioctl.h
 #define CTL_CODE(DeviceType, Function, Method, Access) (                   \
     ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
 )
+#endif
 
 #define FIRST_AVAIL_IO_FUNC 0x800
 #define RED_TUNNEL_CTL_FUNC FIRST_AVAIL_IO_FUNC
commit ff0a9e72b353c03c442b154f20664190ef837cde
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:40:53 2012 +0100

    mingw: workaround ximage.h #defining min/max
    
    This confuses the deque implementation of gcc which uses std::min
    std::max and causes compile failure.

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 06c701d..a288861 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -19,6 +19,8 @@
 #include "desktop_layout.h"
 #include "display_setting.h"
 #include "ximage.h"
+#undef max
+#undef min
 #include <lmcons.h>
 #include <queue>
 #include <set>
commit 22dffb81ad0b63645d528c1af77e89decd48bbb1
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:39:30 2012 +0100

    mingw: fix signed/unsigned comparison warning
    
    DWORD is an unsigned long, but it's assigned -1 in various places.
    mingw warns when comparing a DWORD value against -1. This commit
    casts the -1 to DWORD to avoid the warning.

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index b5295c1..6e255fc 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -263,7 +263,7 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
             best = i;
         }
     }
-    if (best == -1 || !EnumDisplaySettings(dev_name, best, dev_mode)) {
+    if (best == (DWORD)-1 || !EnumDisplaySettings(dev_name, best, dev_mode)) {
         return false;
     }
     dev_mode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
commit 92583e91d4b9339901de30d5dda279d468f6f7bb
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:37:40 2012 +0100

    mingw: workaround "use of unitialized var" warning
    
    mingw warns about using a variable before it's initialized, but
    it's a false alarm. Initialize it to 0 to avoid the warning.

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 3f56292..06c701d 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -976,7 +976,7 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
     HANDLE clip_data;
     uint8_t* new_data = NULL;
     long new_size;
-    size_t len;
+    size_t len = 0;
     CxImage image;
 
     if (_clipboard_owner != owner_guest) {
commit bc99951685fe5c6d9e7df5f6e92af926fd0abb01
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:20:26 2012 +0100

    mingw: use unsigned int in for loops when needed
    
    gcc complains about mixed use of signed/unsigned otherwise

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 1cfa96d..3f56292 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -876,7 +876,7 @@ void VDAgent::on_clipboard_grab()
                                  VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) {
         return;
     }
-    for (int i = 0; i < clipboard_formats_count; i++) {
+    for (unsigned int i = 0; i < clipboard_formats_count; i++) {
         if (IsClipboardFormatAvailable(clipboard_formats[i].format)) {
             for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
                 types[count++] = *ptype;
@@ -1065,7 +1065,7 @@ void VDAgent::handle_clipboard_release()
 
 uint32_t VDAgent::get_clipboard_format(uint32_t type)
 {
-    for (int i = 0; i < clipboard_formats_count; i++) {
+    for (unsigned int i = 0; i < clipboard_formats_count; i++) {
         for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) {
             if (*ptype == type) {
                 return clipboard_formats[i].format;
@@ -1079,7 +1079,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format)
 {
     uint32_t* types = NULL;
 
-    for (int i = 0; i < clipboard_formats_count && !types; i++) {
+    for (unsigned int i = 0; i < clipboard_formats_count && !types; i++) {
         if (clipboard_formats[i].format == format) {
             types = clipboard_formats[i].types;
         }
@@ -1097,7 +1097,7 @@ uint32_t VDAgent::get_clipboard_type(uint32_t format)
 
 DWORD VDAgent::get_cximage_format(uint32_t type)
 {
-    for (int i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
+    for (unsigned int i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
         if (image_types[i].type == type) {
             return image_types[i].cximage_format;
         }
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index ca9ac1e..4701f5a 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -460,7 +460,7 @@ bool VDService::init_vdi_port()
 {
     VDIPort* (*creators[])(void) = { create_virtio_vdi_port, create_pci_vdi_port };
 
-    for (int i = 0 ; i < sizeof(creators)/sizeof(creators[0]); ++i) {
+    for (unsigned int i = 0 ; i < sizeof(creators)/sizeof(creators[0]); ++i) {
         _vdi_port = creators[i]();
         if (_vdi_port->init()) {
             return true;
commit 52d659428491ea7311064970cc2d7a572adc3c10
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:19:30 2012 +0100

    mingw: fix initialization list order for VDAgent()

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 22e9c59..1cfa96d 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -176,9 +176,9 @@ VDAgent::VDAgent()
     , _display_setting (VD_AGENT_REGISTRY_KEY)
     , _logon_desktop (false)
     , _display_setting_initialized (false)
-    , _log (NULL)
     , _client_caps(NULL)
-    , _client_caps_size(NULL)
+    , _client_caps_size(0)
+    , _log (NULL)
 {
     TCHAR log_path[MAX_PATH];
     TCHAR temp_path[MAX_PATH];
commit a8b47ea6535e3ad166b82d9ebfa2433c71bb5be5
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:17:15 2012 +0100

    mingw: remove unused variable

diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
index 8abef3f..fdf5a31 100644
--- a/vdagent/display_setting.cpp
+++ b/vdagent/display_setting.cpp
@@ -122,7 +122,6 @@ DWORD DisplaySetting::get_user_process_id()
 {
     PROCESSENTRY32 proc_entry;
     DWORD explorer_pid = 0;
-    HANDLE token = NULL;
     DWORD agent_session_id;
 
     if (!ProcessIdToSessionId(GetCurrentProcessId(), &agent_session_id)) {
commit 9d1586c1dd052f95d5aeb370e27011e635026787
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:16:33 2012 +0100

    mingw: fix header case
    
    linux systems need it in lower-case, Windows systems shouldn't
    care.

diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
index 0116346..8abef3f 100644
--- a/vdagent/display_setting.cpp
+++ b/vdagent/display_setting.cpp
@@ -16,7 +16,7 @@
 */
 #include <windows.h>
 #include <stdio.h>
-#include <Sddl.h>
+#include <sddl.h>
 #include <string.h>
 #include <tlhelp32.h>
 #include "display_setting.h"
commit fa68400fb4cd2e77e89ab429231e1acd56fa08c5
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:16:06 2012 +0100

    mingw: pick min/max from the std:: namespace

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index f880fd3..b5295c1 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -18,6 +18,11 @@
 #include "desktop_layout.h"
 #include "vdlog.h"
 
+#ifdef __MINGW32__
+using std::min;
+using std::max;
+#endif
+
 void DisplayMode::set_res(DWORD width, DWORD height, DWORD depth)
 {
     _width = width;
commit 5e55cc27b20bf8c00f0a85b94b615b13e528932c
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:11:53 2012 +0100

    mingw: use gcc attributes for struct packing
    
    It automatically chooses between using the gcc construct or the
    visual-c++ construct at compile-time.

diff --git a/common/vdcommon.h b/common/vdcommon.h
index edcfa1e..c5268f4 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -45,12 +45,20 @@ enum {
     VD_AGENT_SESSION_LOGON,
 };
 
-typedef __declspec (align(1)) struct VDPipeMessage {
+#if defined __GNUC__
+#define ALIGN_GCC __attribute__ ((packed))
+#define ALIGN_VC
+#else
+#define ALIGN_GCC
+#define ALIGN_VC __declspec (align(1))
+#endif
+
+typedef struct ALIGN_VC VDPipeMessage {
     uint32_t type;
     uint32_t opaque;
     uint32_t size;
     uint8_t data[0];
-} VDPipeMessage;
+} ALIGN_GCC VDPipeMessage;
 
 typedef struct VDPipeBuffer {
     OVERLAPPED overlap;
commit 89422a3a417fc134b64de59b4a3434a4453c6cdb
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:11:22 2012 +0100

    mingw: disable vc-specific #pragma

diff --git a/common/vdcommon.h b/common/vdcommon.h
index 1097720..edcfa1e 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -18,7 +18,9 @@
 #ifndef _H_VDCOMMON
 #define _H_VDCOMMON
 
+#if !defined __GNUC__
 #pragma warning(disable:4200)
+#endif
 
 #include <windows.h>
 #include "spice/vd_agent.h"
commit a343a280a9febaf384816d9bbcabab67b05e37a5
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:10:43 2012 +0100

    mingw: don't redefine SIZE_MAX
    
    mingw already has SIZE_MAX defined so don't try to redefine it to
    avoid a warning.

diff --git a/common/stdint.h b/common/stdint.h
index 250efb5..411f5bf 100644
--- a/common/stdint.h
+++ b/common/stdint.h
@@ -296,7 +296,9 @@ typedef unsigned long long   uintmax_t;
 
 
 
+#ifndef SIZE_MAX
 #define SIZE_MAX UINT32_MAX
+#endif
 
 
 
commit df3fe9cb90aaeb30f029428cf9030e2526768d08
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Sun Feb 19 23:10:00 2012 +0100

    mingw: fix format string warnings
    
    Most of them are caused by not using %lu to print a DWORD (which
    is an unsigned long).

diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index 8ece384..a0444d9 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -99,7 +99,7 @@ void log_version()
                 size < sizeof(VS_FIXEDFILEINFO)) {
             throw;
         }
-        vd_printf("%d.%d.%d.%d",
+        vd_printf("%lu.%lu.%lu.%lu",
             file_info->dwFileVersionMS >> 16,
             file_info->dwFileVersionMS & 0x0ffff,
             file_info->dwFileVersionLS >> 16,
diff --git a/common/vdlog.h b/common/vdlog.h
index 5a794b6..eebb0d2 100644
--- a/common/vdlog.h
+++ b/common/vdlog.h
@@ -54,7 +54,7 @@ static unsigned int log_level = LOG_INFO;
 #endif
 
 #define PRINT_LINE(type, format, datetime, ms, ...)                                             \
-    printf("%u::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms,       \
+    printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms,       \
            __FUNCTION__, ## __VA_ARGS__);
 
 #define LOG(type, format, ...) if (type >= log_level && type <= LOG_FATAL) {                    \
diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index 0ba7248..f880fd3 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -112,14 +112,14 @@ void DesktopLayout::set_displays()
             break;
         }
         if (display_id >= _displays.size()) {
-            vd_printf("display_id %u out of range, #displays %u", display_id, _displays.size());
+            vd_printf("display_id %lu out of range, #displays %u", display_id, _displays.size());
             break;
         }
         if (!init_dev_mode(dev_info.DeviceName, &dev_mode, _displays.at(display_id), true)) {
             vd_printf("No suitable mode found for display %S", dev_info.DeviceName);
             break;
         }
-        vd_printf("Set display mode %ux%u", dev_mode.dmPelsWidth, dev_mode.dmPelsHeight);
+        vd_printf("Set display mode %lux%lu", dev_mode.dmPelsWidth, dev_mode.dmPelsHeight);
         LONG ret = ChangeDisplaySettingsEx(dev_info.DeviceName, &dev_mode, NULL,
                                            CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
         if (ret == DISP_CHANGE_SUCCESSFUL) {
diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
index 246b78f..0116346 100644
--- a/vdagent/display_setting.cpp
+++ b/vdagent/display_setting.cpp
@@ -55,12 +55,12 @@ void DisplaySetting::set(DisplaySettingOptions& opts)
     status = RegCreateKeyExA(HKEY_LOCAL_MACHINE, _reg_key.c_str(), 0, NULL,
                              REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dispos);
     if (status != ERROR_SUCCESS) {
-        vd_printf("create/open registry key: fail %d", GetLastError());
+        vd_printf("create/open registry key: fail %lu", GetLastError());
     } else {
         status = RegSetValueExA(hkey, DISPLAY_SETTING_MASK_REG_VALUE, 0,
                                 REG_BINARY, &reg_mask, sizeof(reg_mask));
         if (status != ERROR_SUCCESS) {
-            vd_printf("setting registry key DisplaySettingMask: fail %d", GetLastError());
+            vd_printf("setting registry key DisplaySettingMask: fail %lu", GetLastError());
         }
         RegCloseKey(hkey);
     }
@@ -81,7 +81,7 @@ void DisplaySetting::load()
 
     status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, _reg_key.c_str(), 0, KEY_READ, &hkey);
     if (status != ERROR_SUCCESS) {
-        vd_printf("open registry key: fail %d", status);
+        vd_printf("open registry key: fail %lu", status);
         return;
     }
 
@@ -90,7 +90,7 @@ void DisplaySetting::load()
                               &value_type, &setting_mask, &value_size);
 
     if (status != ERROR_SUCCESS) {
-        vd_printf("get registry mask value: fail %d", GetLastError());
+        vd_printf("get registry mask value: fail %lu", GetLastError());
         RegCloseKey(hkey);
         return;
     }
@@ -98,7 +98,7 @@ void DisplaySetting::load()
     RegCloseKey(hkey);
 
     if (value_type != REG_BINARY) {
-        vd_printf("get registry mask value: bad value type %d", value_type);
+        vd_printf("get registry mask value: bad value type %lu", value_type);
         return;
     }
 
@@ -126,19 +126,19 @@ DWORD DisplaySetting::get_user_process_id()
     DWORD agent_session_id;
 
     if (!ProcessIdToSessionId(GetCurrentProcessId(), &agent_session_id)) {
-        vd_printf("ProcessIdToSessionId for current process failed %u", GetLastError());
+        vd_printf("ProcessIdToSessionId for current process failed %lu", GetLastError());
         return 0;
     }
 
     HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
     if (snap == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateToolhelp32Snapshot() failed %u", GetLastError());
+        vd_printf("CreateToolhelp32Snapshot() failed %lu", GetLastError());
         return 0;
     }
     ZeroMemory(&proc_entry, sizeof(proc_entry));
     proc_entry.dwSize = sizeof(PROCESSENTRY32);
     if (!Process32First(snap, &proc_entry)) {
-        vd_printf("Process32First() failed %u", GetLastError());
+        vd_printf("Process32First() failed %lu", GetLastError());
         CloseHandle(snap);
         return 0;
     }
@@ -146,7 +146,7 @@ DWORD DisplaySetting::get_user_process_id()
         if (_tcsicmp(proc_entry.szExeFile, TEXT("explorer.exe")) == 0) {
             DWORD explorer_session_id;
             if (!ProcessIdToSessionId(proc_entry.th32ProcessID, &explorer_session_id)) {
-                vd_printf("ProcessIdToSessionId for explorer failed %u", GetLastError());
+                vd_printf("ProcessIdToSessionId for explorer failed %lu", GetLastError());
                 break;
             }
             
@@ -207,13 +207,13 @@ bool DisplaySetting::reload_from_registry(DisplaySettingOptions& opts)
         vd_printf("get_user_process_id failed");
         return false;
     } else {
-        vd_printf("explorer pid %d", user_pid);
+        vd_printf("explorer pid %ld", user_pid);
     }
 
     hprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, user_pid);
 
     if (!OpenProcessToken(hprocess, TOKEN_ALL_ACCESS, &htoken)) {
-        vd_printf("OpenProcessToken: failed %d", GetLastError());
+        vd_printf("OpenProcessToken: failed %lu", GetLastError());
         CloseHandle(hprocess);
         return false;
     }
@@ -226,14 +226,14 @@ bool DisplaySetting::reload_from_registry(DisplaySettingOptions& opts)
 
         status = RegOpenCurrentUser(KEY_READ, &hkey_cur_user);
         if (status != ERROR_SUCCESS) {
-            vd_printf("RegOpenCurrentUser: failed %d", GetLastError());
+            vd_printf("RegOpenCurrentUser: failed %lu", GetLastError());
             throw;
         }
 
         status = RegOpenKeyExA(hkey_cur_user, USER_DESKTOP_REGISTRY_KEY, 0,
                                KEY_READ, &hkey_desktop);
         if (status != ERROR_SUCCESS) {
-            vd_printf("RegOpenKeyExA: failed %d", GetLastError());
+            vd_printf("RegOpenKeyExA: failed %lu", GetLastError());
             throw;
         }
 
@@ -273,11 +273,11 @@ bool DisplaySetting::reload_from_registry(DisplaySettingOptions& opts)
 
 bool DisplaySetting::disable_wallpaper()
 {
-    if (SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "", 0)) {
+    if (SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, (void*)"", 0)) {
         vd_printf("disable wallpaper: success");
         return true;
     } else {
-        vd_printf("disable wallpaper: fail %d", GetLastError());
+        vd_printf("disable wallpaper: fail %lu", GetLastError());
         return false;
     }
 }
@@ -299,7 +299,7 @@ bool DisplaySetting::reload_wallpaper(HKEY desktop_reg_key)
     }
 
     if (value_type != REG_SZ) {
-        vd_printf("bad wallpaper value type %d (expected REG_SZ)", value_type);
+        vd_printf("bad wallpaper value type %lu (expected REG_SZ)", value_type);
         return false;
     }
 
@@ -320,7 +320,7 @@ bool DisplaySetting::reload_wallpaper(HKEY desktop_reg_key)
         vd_printf("reload wallpaper: success");
         return true;
     } else {
-        vd_printf("reload wallpaper: failed %d", GetLastError());
+        vd_printf("reload wallpaper: failed %lu", GetLastError());
         return false;
     }
 }
@@ -331,7 +331,7 @@ bool DisplaySetting::disable_font_smoothing()
         vd_printf("disable font smoothing: success");
         return true;
     } else {
-        vd_printf("disable font smoothing: fail %d", GetLastError());
+        vd_printf("disable font smoothing: fail %lu", GetLastError());
         return false;
     }
 }
@@ -353,7 +353,7 @@ bool DisplaySetting::reload_font_smoothing(HKEY desktop_reg_key)
     }
 
     if (value_type != REG_SZ) {
-        vd_printf("bad font smoothing value type %d (expected REG_SZ)", value_type);
+        vd_printf("bad font smoothing value type %lu (expected REG_SZ)", value_type);
         return false;
     }
 
@@ -382,7 +382,7 @@ bool DisplaySetting::reload_font_smoothing(HKEY desktop_reg_key)
         vd_printf("reload font smoothing: success");
         return true;
     } else {
-        vd_printf("reload font smoothing: failed %d", GetLastError());
+        vd_printf("reload font smoothing: failed %lu", GetLastError());
         return false;
     }
 }
@@ -401,7 +401,7 @@ bool DisplaySetting::disable_animation()
                               &win_animation, 0)) {
         vd_printf("disable window animation: success");
     } else {
-        vd_printf("disable window animation: fail %d", GetLastError());
+        vd_printf("disable window animation: fail %lu", GetLastError());
         ret = false;
     }
 
@@ -437,7 +437,7 @@ bool DisplaySetting::reload_win_animation(HKEY desktop_reg_key)
     RegCloseKey(win_metrics_hkey);
 
     if (value_type != REG_SZ) {
-        vd_printf("bad MinAnimate value type %d (expected REG_SZ)", value_type);
+        vd_printf("bad MinAnimate value type %lu (expected REG_SZ)", value_type);
         return false;
     }
 
@@ -460,7 +460,7 @@ bool DisplaySetting::reload_win_animation(HKEY desktop_reg_key)
         vd_printf("reload window animation: success");
         return false;
     } else {
-        vd_printf("reload window animation: fail %d", GetLastError());
+        vd_printf("reload window animation: fail %lu", GetLastError());
         return false;
     }
 }
@@ -468,7 +468,7 @@ bool DisplaySetting::reload_win_animation(HKEY desktop_reg_key)
 bool DisplaySetting::set_bool_system_parameter_info(int action, BOOL param)
 {
     if (!SystemParametersInfo(action, 0, (PVOID)param, 0)) {
-        vd_printf("SystemParametersInfo %d: failed %d", action, GetLastError());
+        vd_printf("SystemParametersInfo %d: failed %lu", action, GetLastError());
         return false;
     }
     return true;
@@ -490,11 +490,11 @@ bool DisplaySetting::reload_ui_effects(HKEY desktop_reg_key)
     }
     
     if (value_type != REG_BINARY) {
-        vd_printf("bad UserPreferencesMask value type %d (expected REG_BINARY)", value_type);
+        vd_printf("bad UserPreferencesMask value type %lu (expected REG_BINARY)", value_type);
         return false;
     }
     
-    vd_printf("UserPreferencesMask = %x %x", ui_mask[0], ui_mask[1]);
+    vd_printf("UserPreferencesMask = %lx %lx", ui_mask[0], ui_mask[1]);
 
     ret &= set_bool_system_parameter_info(SPI_SETUIEFFECTS, ui_mask[0] & 0x80000000);
     ret &= set_bool_system_parameter_info(SPI_SETACTIVEWINDOWTRACKING, ui_mask[0] & 0x01);
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index f0f5243..22e9c59 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -205,7 +205,7 @@ DWORD WINAPI VDAgent::event_thread_proc(LPVOID param)
 {
     HANDLE desktop_event = OpenEvent(SYNCHRONIZE, FALSE, L"WinSta0_DesktopSwitch");
     if (!desktop_event) {
-        vd_printf("OpenEvent() failed: %d", GetLastError());
+        vd_printf("OpenEvent() failed: %lu", GetLastError());
         return 1;
     }
     while (_singleton->_running) {
@@ -216,7 +216,7 @@ DWORD WINAPI VDAgent::event_thread_proc(LPVOID param)
             break;
         case WAIT_TIMEOUT:
         default:
-            vd_printf("WaitForSingleObject(): %u", wait_ret);
+            vd_printf("WaitForSingleObject(): %lu", wait_ret);
         }
     }
     CloseHandle(desktop_event);
@@ -231,21 +231,21 @@ bool VDAgent::run()
     WNDCLASS wcls;
 
     if (!ProcessIdToSessionId(GetCurrentProcessId(), &session_id)) {
-        vd_printf("ProcessIdToSessionId failed %u", GetLastError());
+        vd_printf("ProcessIdToSessionId failed %lu", GetLastError());
         return false;
     }
-    vd_printf("***Agent started in session %u***", session_id);
+    vd_printf("***Agent started in session %lu***", session_id);
     log_version();
     if (!SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) {
-        vd_printf("SetPriorityClass failed %u", GetLastError());
+        vd_printf("SetPriorityClass failed %lu", GetLastError());
     }
     if (!SetProcessShutdownParameters(0x100, 0)) {
-        vd_printf("SetProcessShutdownParameters failed %u", GetLastError());
+        vd_printf("SetProcessShutdownParameters failed %lu", GetLastError());
     }
     _control_event = CreateEvent(NULL, FALSE, FALSE, NULL);
     _clipboard_event = CreateEvent(NULL, FALSE, FALSE, NULL);
     if (!_control_event || !_clipboard_event) {
-        vd_printf("CreateEvent() failed: %d", GetLastError());
+        vd_printf("CreateEvent() failed: %lu", GetLastError());
         cleanup();
         return false;
     }
@@ -253,7 +253,7 @@ bool VDAgent::run()
     wcls.lpfnWndProc = &VDAgent::wnd_proc;
     wcls.lpszClassName = VD_AGENT_WINCLASS_NAME;
     if (!RegisterClass(&wcls)) {
-        vd_printf("RegisterClass() failed: %d", GetLastError());
+        vd_printf("RegisterClass() failed: %lu", GetLastError());
         cleanup();
         return false;
     }
@@ -268,7 +268,7 @@ bool VDAgent::run()
     _running = true;
     event_thread = CreateThread(NULL, 0, event_thread_proc, NULL, 0, &event_thread_id);
     if (!event_thread) {
-        vd_printf("CreateThread() failed: %d", GetLastError());
+        vd_printf("CreateThread() failed: %lu", GetLastError());
         cleanup();
         return false;
     }
@@ -299,7 +299,7 @@ void VDAgent::set_control_event(int control_command)
     MUTEX_LOCK(_control_mutex);
     _control_queue.push(control_command);
     if (_control_event && !SetEvent(_control_event)) {
-        vd_printf("SetEvent() failed: %u", GetLastError());
+        vd_printf("SetEvent() failed: %lu", GetLastError());
     }
     MUTEX_UNLOCK(_control_mutex);
 }
@@ -334,19 +334,19 @@ void VDAgent::input_desktop_message_loop()
 
     hdesk = OpenInputDesktop(0, FALSE, GENERIC_ALL);
     if (!hdesk) {
-        vd_printf("OpenInputDesktop() failed: %u", GetLastError());
+        vd_printf("OpenInputDesktop() failed: %lu", GetLastError());
         _running = false;
         return;
     }
     if (!SetThreadDesktop(hdesk)) {
-        vd_printf("SetThreadDesktop failed %u", GetLastError());
+        vd_printf("SetThreadDesktop failed %lu", GetLastError());
         _running = false;
         return;
     }
     if (GetUserObjectInformation(hdesk, UOI_NAME, desktop_name, sizeof(desktop_name), NULL)) {
         vd_printf("Desktop: %S", desktop_name);
     } else {
-        vd_printf("GetUserObjectInformation failed %u", GetLastError());
+        vd_printf("GetUserObjectInformation failed %lu", GetLastError());
     }
 
     // loading the display settings for the current session's logged on user only
@@ -369,7 +369,7 @@ void VDAgent::input_desktop_message_loop()
 
     _hwnd = CreateWindow(VD_AGENT_WINCLASS_NAME, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
     if (!_hwnd) {
-        vd_printf("CreateWindow() failed: %u", GetLastError());
+        vd_printf("CreateWindow() failed: %lu", GetLastError());
         _running = false;
         return;
     }
@@ -391,7 +391,7 @@ void VDAgent::input_desktop_message_loop()
             break;
         case WAIT_TIMEOUT:
         default:
-            vd_printf("MsgWaitForMultipleObjectsEx(): %u", wait_ret);
+            vd_printf("MsgWaitForMultipleObjectsEx(): %lu", wait_ret);
         }
     }
     _desktop_switch = false;
@@ -424,14 +424,14 @@ bool VDAgent::send_input()
         if (KillTimer(_hwnd, VD_TIMER_ID)) {
             _pending_input = false;
         } else {
-            vd_printf("KillTimer failed: %d", GetLastError());
+            vd_printf("KillTimer failed: %lu", GetLastError());
             _running = false;
             _desktop_layout->unlock();
             return false;
         }
     }
     if (!SendInput(1, &_input, sizeof(INPUT)) && GetLastError() != ERROR_ACCESS_DENIED) {
-        vd_printf("SendInput failed: %d", GetLastError());
+        vd_printf("SendInput failed: %lu", GetLastError());
         ret = _running = false;
     }
     _input_time = GetTickCount();
@@ -497,7 +497,7 @@ bool VDAgent::handle_mouse_event(VDAgentMouseState* state)
         if (SetTimer(_hwnd, VD_TIMER_ID, VD_INPUT_INTERVAL_MS, NULL)) {
             _pending_input = true;
         } else {
-            vd_printf("SetTimer failed: %d", GetLastError());
+            vd_printf("SetTimer failed: %lu", GetLastError());
             _running = false;
             ret = false;
         }
@@ -1018,7 +1018,7 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
             vd_printf("Image encode to type %u failed", clipboard_request->type);
             break;
         }
-        vd_printf("Image encoded to %u bytes", new_size);
+        vd_printf("Image encoded to %lu bytes", new_size);
         break;
     }
     }
@@ -1121,19 +1121,19 @@ bool VDAgent::connect_pipe()
 
     ZeroMemory(&a->_pipe_state, sizeof(VDPipeState));
     if (!WaitNamedPipe(VD_SERVICE_PIPE_NAME, NMPWAIT_USE_DEFAULT_WAIT)) {
-        vd_printf("WaitNamedPipe() failed: %d", GetLastError());
+        vd_printf("WaitNamedPipe() failed: %lu", GetLastError());
         return false;
     }
     //assuming vdservice created the named pipe before creating this vdagent process
     pipe = CreateFile(VD_SERVICE_PIPE_NAME, GENERIC_READ | GENERIC_WRITE,
                       0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
     if (pipe == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateFile() failed: %d", GetLastError());
+        vd_printf("CreateFile() failed: %lu", GetLastError());
         return false;
     }
     DWORD pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT;
     if (!SetNamedPipeHandleState(pipe, &pipe_mode, NULL, NULL)) {
-        vd_printf("SetNamedPipeHandleState() failed: %d", GetLastError());
+        vd_printf("SetNamedPipeHandleState() failed: %lu", GetLastError());
         CloseHandle(pipe);
         return false;
     }
@@ -1180,7 +1180,7 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
         vd_printf("Unsupported message type %u size %u", msg->type, msg->size);
     }
     if (!res) {
-        vd_printf("handling message type %u failed: %u", msg->type, GetLastError());
+        vd_printf("handling message type %u failed: %lu", msg->type, GetLastError());
         a->_running = false;
     }
 }
@@ -1195,7 +1195,7 @@ VOID CALLBACK VDAgent::read_completion(DWORD err, DWORD bytes, LPOVERLAPPED over
         return;
     }
     if (err) {
-        vd_printf("vdservice disconnected (%u)", err);
+        vd_printf("vdservice disconnected (%lu)", err);
         a->_running = false;
         return;
     }
@@ -1219,7 +1219,7 @@ VOID CALLBACK VDAgent::read_completion(DWORD err, DWORD bytes, LPOVERLAPPED over
             }
             VDAgentMessage* msg = (VDAgentMessage*)pipe_msg->data;
             if (msg->protocol != VD_AGENT_PROTOCOL) {
-                vd_printf("Invalid protocol %u bytes %u", msg->protocol, bytes);
+                vd_printf("Invalid protocol %u bytes %lu", msg->protocol, bytes);
                 a->_running = false;
                 break;
             }
@@ -1251,7 +1251,7 @@ VOID CALLBACK VDAgent::read_completion(DWORD err, DWORD bytes, LPOVERLAPPED over
     if (a->_running && ps->read.end < sizeof(ps->read.data) &&
         !ReadFileEx(ps->pipe, ps->read.data + ps->read.end, sizeof(ps->read.data) - ps->read.end,
                     overlap, read_completion)) {
-        vd_printf("ReadFileEx() failed: %u", GetLastError());
+        vd_printf("ReadFileEx() failed: %lu", GetLastError());
         a->_running = false;
     }
 }
@@ -1266,7 +1266,7 @@ VOID CALLBACK VDAgent::write_completion(DWORD err, DWORD bytes, LPOVERLAPPED ove
         return;
     }
     if (err) {
-        vd_printf("vdservice disconnected (%u)", err);
+        vd_printf("vdservice disconnected (%lu)", err);
         a->_running = false;
         return;
     }
@@ -1283,7 +1283,7 @@ VOID CALLBACK VDAgent::write_completion(DWORD err, DWORD bytes, LPOVERLAPPED ove
                            ps->write.end - ps->write.start, overlap, write_completion)) {
         a->_pending_write = true;
     } else {
-        vd_printf("WriteFileEx() failed: %u", GetLastError());
+        vd_printf("WriteFileEx() failed: %lu", GetLastError());
         a->_running = false;
     }
     a->write_unlock();
diff --git a/vdservice/pci_vdi_port.cpp b/vdservice/pci_vdi_port.cpp
index d07eab7..fce13bd 100644
--- a/vdservice/pci_vdi_port.cpp
+++ b/vdservice/pci_vdi_port.cpp
@@ -62,17 +62,17 @@ bool PCIVDIPort::init()
     _handle = CreateFile(VDI_PORT_DEV_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                          OPEN_EXISTING, 0, NULL);
     if (_handle == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateFile() failed: %u", GetLastError());
+        vd_printf("CreateFile() failed: %lu", GetLastError());
         return false;
     }
     _event = CreateEvent(NULL, FALSE, FALSE, NULL);
     if (_event == NULL) {
-        vd_printf("CreateEvent() failed: %u", GetLastError());
+        vd_printf("CreateEvent() failed: %lu", GetLastError());
         return false;
     }
     if (!DeviceIoControl(_handle, IOCTL_RED_TUNNEL_SET_EVENT, &_event, sizeof(_event),
                          NULL, 0, &io_ret_len, NULL)) {
-        vd_printf("DeviceIoControl() failed: %u", GetLastError());
+        vd_printf("DeviceIoControl() failed: %lu", GetLastError());
         return false;
     }
     return true;
diff --git a/vdservice/vdi_port.cpp b/vdservice/vdi_port.cpp
index 60bd0ef..bd5ea05 100644
--- a/vdservice/vdi_port.cpp
+++ b/vdservice/vdi_port.cpp
@@ -84,7 +84,7 @@ int VDIPort::handle_error()
         _read.start = _read.end = _read.ring;
         return VDI_PORT_RESET;
     default:
-        vd_printf("port io failed: %u", GetLastError());
+        vd_printf("port io failed: %lu", GetLastError());
         return VDI_PORT_ERROR;
     }
 }
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 50a70c2..ca9ac1e 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -156,7 +156,7 @@ int supported_system_version()
     ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     if (!GetVersionEx((OSVERSIONINFO*)&osvi)) {
-        vd_printf("GetVersionEx() failed: %u", GetLastError());
+        vd_printf("GetVersionEx() failed: %lu", GetLastError());
         return 0;
     }
     if (osvi.dwMajorVersion == 5 && (osvi.dwMinorVersion == 1 || osvi.dwMinorVersion == 2)) {
@@ -252,7 +252,7 @@ bool VDService::install()
         printf("Service already exists\n");
         ret = true;
     } else {
-        printf("Service not installed successfully, error %d\n", GetLastError());
+        printf("Service not installed successfully, error %lu\n", GetLastError());
     }
     CloseServiceHandle(service_control_manager);
     return ret;
@@ -310,7 +310,7 @@ void VDService::set_control_event(int control_command)
     MUTEX_LOCK(_control_mutex);
     _control_queue.push(control_command);
     if (_control_event && !SetEvent(_control_event)) {
-        vd_printf("SetEvent() failed: %u", GetLastError());
+        vd_printf("SetEvent() failed: %lu", GetLastError());
     }
     MUTEX_UNLOCK(_control_mutex);
 }
@@ -360,7 +360,7 @@ DWORD WINAPI VDService::control_handler(DWORD control, DWORD event_type, LPVOID
         break;
     case SERVICE_CONTROL_SESSIONCHANGE: {
         DWORD session_id = ((WTSSESSION_NOTIFICATION*)event_data)->dwSessionId;
-        vd_printf("Session %u %s", session_id, session_events[event_type]);
+        vd_printf("Session %lu %s", session_id, session_events[event_type]);
         SetServiceStatus(s->_status_handle, &s->_status);
         if (s->_system_version != SYS_VER_UNSUPPORTED) {
             if (event_type == WTS_CONSOLE_CONNECT) {
@@ -373,7 +373,7 @@ DWORD WINAPI VDService::control_handler(DWORD control, DWORD event_type, LPVOID
         break;
     }
     default:
-        vd_printf("Unsupported control %u", control);
+        vd_printf("Unsupported control %lu", control);
         ret = ERROR_CALL_NOT_IMPLEMENTED;
     }
     return ret;
@@ -402,7 +402,7 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     vd_printf("***Service started***");
     log_version();
     if (!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS)) {
-        vd_printf("SetPriorityClass failed %u", GetLastError());
+        vd_printf("SetPriorityClass failed %lu", GetLastError());
     }
     status = &s->_status;
     status->dwServiceType = SERVICE_WIN32;
@@ -493,7 +493,7 @@ bool VDService::execute()
                            VD_AGENT_TIMEOUT, &sec_attr);
     LocalFree(sec_desr);
     if (pipe == INVALID_HANDLE_VALUE) {
-        vd_printf("CreatePipe() failed: %u", GetLastError());
+        vd_printf("CreatePipe() failed: %lu", GetLastError());
         return false;
     }
     _pipe_state.pipe = pipe;
@@ -502,7 +502,7 @@ bool VDService::execute()
         vd_printf("WTSGetActiveConsoleSessionId() failed");
         _running = false;
     }
-    vd_printf("Active console session id: %u", _session_id);
+    vd_printf("Active console session id: %lu", _session_id);
     if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, _session_id,
                                    WTSConnectState, (LPTSTR *)&con_state, &bytes)) {
         vd_printf("Connect state: %d", *con_state);
@@ -596,7 +596,7 @@ bool VDService::execute()
                                    _events_vdi_port_base + _vdi_port->get_num_events()) {
                         _vdi_port->handle_event(wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0);
                     } else {
-                        vd_printf("WaitForMultipleObjects failed %u", GetLastError());
+                        vd_printf("WaitForMultipleObjects failed %lu", GetLastError());
                     }
                 }
             }
@@ -796,13 +796,13 @@ BOOL create_process_as_user(IN DWORD session_id, IN LPCWSTR application_name,
 
     HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
     if (snap == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateToolhelp32Snapshot() failed %u", GetLastError());
+        vd_printf("CreateToolhelp32Snapshot() failed %lu", GetLastError());
         return false;
     }
     ZeroMemory(&proc_entry, sizeof(proc_entry));
     proc_entry.dwSize = sizeof(PROCESSENTRY32);
     if (!Process32First(snap, &proc_entry)) {
-        vd_printf("Process32First() failed %u", GetLastError());
+        vd_printf("Process32First() failed %lu", GetLastError());
         CloseHandle(snap);
         return false;
     }
@@ -823,20 +823,20 @@ BOOL create_process_as_user(IN DWORD session_id, IN LPCWSTR application_name,
     }
     winlogon_proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, winlogon_pid);
     if (!winlogon_proc) {
-        vd_printf("OpenProcess() failed %u", GetLastError());
+        vd_printf("OpenProcess() failed %lu", GetLastError());
         return false;
     }
     ret = OpenProcessToken(winlogon_proc, TOKEN_DUPLICATE, &token);
     CloseHandle(winlogon_proc);
     if (!ret) {
-        vd_printf("OpenProcessToken() failed %u", GetLastError());
+        vd_printf("OpenProcessToken() failed %lu", GetLastError());
         return false;
     }
     ret = DuplicateTokenEx(token, MAXIMUM_ALLOWED, NULL, SecurityIdentification, TokenPrimary,
                            &token_dup);
     CloseHandle(token);
     if (!ret) {
-        vd_printf("DuplicateTokenEx() failed %u", GetLastError());
+        vd_printf("DuplicateTokenEx() failed %lu", GetLastError());
         return false;
     }
     ret = CreateProcessAsUser(token_dup, application_name, command_line, process_attributes,
@@ -881,7 +881,7 @@ bool VDService::launch_agent()
         return false;
     }
     if (!ret) {
-        vd_printf("CreateProcess() failed: %u", GetLastError());
+        vd_printf("CreateProcess() failed: %lu", GetLastError());
         return false;
     }
     _agent_alive = true;
@@ -898,12 +898,12 @@ bool VDService::launch_agent()
         DWORD wait_ret = WaitForMultipleObjects(2, wait_handles, FALSE, VD_AGENT_TIMEOUT);
         if (wait_ret != WAIT_OBJECT_0) {
             _agent_proc_info.hProcess = 0;
-            vd_printf("Failed waiting for vdagent connection: %u error: %u", wait_ret,
+            vd_printf("Failed waiting for vdagent connection: %lu error: %lu", wait_ret,
                 wait_ret == WAIT_FAILED ? GetLastError() : 0);
             ret = FALSE;
         }
     } else if (err != 0 && err != ERROR_PIPE_CONNECTED) {
-        vd_printf("ConnectNamedPipe() failed: %u", err);
+        vd_printf("ConnectNamedPipe() failed: %lu", err);
         ret = FALSE;
     }
     if (ret) {
@@ -937,10 +937,10 @@ bool VDService::kill_agent()
         switch (wait_ret) {
         case WAIT_OBJECT_0:
             if (GetExitCodeProcess(proc_handle, &exit_code)) {
-                vd_printf("vdagent exit code %u", exit_code);
+                vd_printf("vdagent exit code %lu", exit_code);
                 ret = (exit_code != STILL_ACTIVE);
             } else {
-                vd_printf("GetExitCodeProcess() failed: %u", GetLastError());
+                vd_printf("GetExitCodeProcess() failed: %lu", GetLastError());
             }
             break;
         case WAIT_TIMEOUT:
@@ -949,7 +949,7 @@ bool VDService::kill_agent()
             break;
         case WAIT_FAILED:
         default:
-            vd_printf("WaitForSingleObject() failed: %u", GetLastError());
+            vd_printf("WaitForSingleObject() failed: %lu", GetLastError());
             break;
         }
     }
@@ -1008,7 +1008,7 @@ void VDService::pipe_write_completion()
             vd_printf("Overlapped write is pending");
             return;
         } else {
-            vd_printf("GetOverlappedResult() failed : %d", GetLastError());
+            vd_printf("GetOverlappedResult() failed : %lu", GetLastError());
         }
         _pending_write = false;
     }
@@ -1017,7 +1017,7 @@ void VDService::pipe_write_completion()
         _pending_write = true;
         if (!WriteFile(ps->pipe, ps->write.data + ps->write.start,
                        ps->write.end - ps->write.start, NULL, &_pipe_state.write.overlap)) {
-            vd_printf("vdagent disconnected (%u)", GetLastError());
+            vd_printf("vdagent disconnected (%lu)", GetLastError());
             _pending_write = false;
             _pipe_connected = false;
             DisconnectNamedPipe(_pipe_state.pipe);
@@ -1048,7 +1048,7 @@ void VDService::pipe_read_completion()
     case ERROR_IO_INCOMPLETE:
         break;
     default:
-        vd_printf("vdagent disconnected (%u)", err);
+        vd_printf("vdagent disconnected (%lu)", err);
         _pipe_connected = false;
         DisconnectNamedPipe(_pipe_state.pipe);
     }
@@ -1067,7 +1067,7 @@ void VDService::read_pipe()
             handle_pipe_data(bytes);
             read_pipe();
         } else if (GetLastError() != ERROR_IO_PENDING) {
-            vd_printf("vdagent disconnected (%u)", GetLastError());
+            vd_printf("vdagent disconnected (%lu)", GetLastError());
             _pending_read = false;
             _pipe_connected = false;
             DisconnectNamedPipe(_pipe_state.pipe);
diff --git a/vdservice/virtio_vdi_port.cpp b/vdservice/virtio_vdi_port.cpp
index 019d97c..c33cee0 100644
--- a/vdservice/virtio_vdi_port.cpp
+++ b/vdservice/virtio_vdi_port.cpp
@@ -69,17 +69,17 @@ bool VirtioVDIPort::init()
     _handle = CreateFile(VIOSERIAL_PORT_PATH, GENERIC_READ | GENERIC_WRITE , 0, NULL,
                          OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
     if (_handle == INVALID_HANDLE_VALUE) {
-        vd_printf("CreateFile() %s failed: %u", VIOSERIAL_PORT_PATH, GetLastError());
+        vd_printf("CreateFile() %s failed: %lu", VIOSERIAL_PORT_PATH, GetLastError());
         return false;
     }
     _write.overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
     if (_write.overlap.hEvent == NULL) {
-        vd_printf("CreateEvent() failed: %u", GetLastError());
+        vd_printf("CreateEvent() failed: %lu", GetLastError());
         return false;
     }
     _read.overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
     if (_read.overlap.hEvent == NULL) {
-        vd_printf("CreateEvent() failed: %u", GetLastError());
+        vd_printf("CreateEvent() failed: %lu", GetLastError());
         return false;
     }
     return true;
@@ -121,7 +121,7 @@ void VirtioVDIPort::write_completion()
         return;
     }
     if (!GetOverlappedResult(_handle, &_write.overlap, &bytes, FALSE)) {
-        vd_printf("GetOverlappedResult failed: %u", GetLastError());
+        vd_printf("GetOverlappedResult failed: %lu", GetLastError());
         return;
     }
     _write.start = _write.ring + (_write.start - _write.ring + bytes) % BUF_SIZE;
@@ -171,7 +171,7 @@ void VirtioVDIPort::read_completion()
             _read.pending = false;
             return;
         } else if (err != ERROR_MORE_DATA) {
-            vd_printf("GetOverlappedResult failed: %u", err);
+            vd_printf("GetOverlappedResult failed: %lu", err);
             return;
         }
     }


More information about the Spice-commits mailing list