[Spice-devel] [PATCH 01/20] mingw: fix format string warnings

Christophe Fergeau cfergeau at redhat.com
Thu Mar 1 02:17:35 PST 2012


Most of them are caused by not using %lu to print a DWORD (which
is an unsigned long).
---
 common/vdlog.cpp              |    2 +-
 common/vdlog.h                |    2 +-
 vdagent/desktop_layout.cpp    |    4 +-
 vdagent/display_setting.cpp   |   52 +++++++++++++++++++-------------------
 vdagent/vdagent.cpp           |   56 ++++++++++++++++++++--------------------
 vdservice/pci_vdi_port.cpp    |    6 ++--
 vdservice/vdi_port.cpp        |    2 +-
 vdservice/vdservice.cpp       |   48 +++++++++++++++++-----------------
 vdservice/virtio_vdi_port.cpp |   10 +++---
 9 files changed, 91 insertions(+), 91 deletions(-)

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;
         }
     }
-- 
1.7.7.6



More information about the Spice-devel mailing list