[Spice-devel] [Spice-commits] 9 commits - spice-protocol vdagent/desktop_layout.cpp vdagent/display_setting.cpp vdagent/file_xfer.cpp vdagent/vdagent.cpp
Christophe Fergeau
cfergeau at redhat.com
Fri Jul 26 04:24:37 PDT 2013
Hey,
These patches do not seem to have been sent to spice-devel@ before commit?
Christophe
On Wed, Jul 17, 2013 at 11:53:25AM -0700, Marc-André Lureau wrote:
> spice-protocol | 2 -
> vdagent/desktop_layout.cpp | 4 +--
> vdagent/display_setting.cpp | 2 -
> vdagent/file_xfer.cpp | 58 +++++++++++++++++++++++++-------------------
> vdagent/vdagent.cpp | 42 +++++++++++++++----------------
> 5 files changed, 58 insertions(+), 50 deletions(-)
>
> New commits:
> commit ad61eec9611ede0b74c577a3426670eb13bde7d0
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:52:17 2013 +0200
>
> Fix cast BOOL->PVOID warning
>
> vdagent/display_setting.cpp:469:50: warning: cast to pointer from
> integer of different size [-Wint-to-pointer-cast]
> if (!SystemParametersInfo(action, 0, (PVOID)param, 0)) {
>
> diff --git a/vdagent/display_setting.cpp b/vdagent/display_setting.cpp
> index fdf5a31..1ec7397 100644
> --- a/vdagent/display_setting.cpp
> +++ b/vdagent/display_setting.cpp
> @@ -466,7 +466,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)) {
> + if (!SystemParametersInfo(action, 0, (PVOID)(uintptr_t)param, 0)) {
> vd_printf("SystemParametersInfo %d: failed %lu", action, GetLastError());
> return false;
> }
> commit fc1de85b499759576fa52dfd20496bfb887c8295
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:49:01 2013 +0200
>
> Fix wrong size_t printf format
>
> vdagent/desktop_layout.cpp:121:763: warning: format '%u' expects
> argument of type 'unsigned int', but argument 8 has type
> 'std::vector<DisplayMode*>::size_type {aka long long unsigned int}'
> [-Wformat=]
>
> diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> index ce259e1..7850e6d 100644
> --- a/vdagent/desktop_layout.cpp
> +++ b/vdagent/desktop_layout.cpp
> @@ -118,7 +118,7 @@ void DesktopLayout::set_displays()
> break;
> }
> if (display_id >= _displays.size()) {
> - vd_printf("display_id %lu out of range, #displays %u", display_id, _displays.size());
> + vd_printf("display_id %lu out of range, #displays %zu" , display_id, _displays.size());
> break;
> }
> if (!init_dev_mode(dev_info.DeviceName, &dev_mode, _displays.at(display_id), true)) {
> commit 492ee05a6bd92acc94557a129cd609d66785dac2
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:43:41 2013 +0200
>
> Replace sscanf_s by sscanf
>
> The _s functions need a recent msvcrt version, not shipped in XP by
> default.
>
> Furthermore, it appears that their sscanf_s usage was missing the extra
> buffer size argument.
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index 9d2f3c5..84f6043 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -182,7 +182,7 @@ bool FileXfer::g_key_get_string(char* data, const char* group, const char* key,
> next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
> if (next_group_pos && key_pos > next_group_pos) return false;
>
> - return !!sscanf_s(key_pos + strlen(key_pfx), "%s\n", value);
> + return !!sscanf(key_pos + strlen(key_pfx), "%s\n", value);
> }
>
> bool FileXfer::g_key_get_uint64(char* data, const char* group, const char* key, uint64_t* value)
> @@ -190,5 +190,5 @@ bool FileXfer::g_key_get_uint64(char* data, const char* group, const char* key,
> char str[G_KEY_MAX_LEN];
>
> if (!g_key_get_string(data, group, key, str)) return false;
> - return !!sscanf_s(str, "%llu", value);
> + return !!sscanf(str, "%" PRIu64, value);
> }
> commit 5129f33899805b55915e506d392c89421db538a2
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:43:14 2013 +0200
>
> Add suggested parentheses
>
> vdagent/vdagent.cpp: In member function 'void
> VDAgent::on_clipboard_grab()':
> vdagent/vdagent.cpp:951:52: warning: suggest parentheses around
> assignment used as truth value [-Wparentheses]
>
> diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
> index 73ca39c..260ee40 100644
> --- a/vdagent/vdagent.cpp
> +++ b/vdagent/vdagent.cpp
> @@ -948,7 +948,7 @@ void VDAgent::on_clipboard_grab()
> set_clipboard_owner(owner_guest);
> } else {
> UINT format = 0;
> - while (format = EnumClipboardFormats(format)) {
> + while ((format = EnumClipboardFormats(format))) {
> vd_printf("Unsupported clipboard format %u", format);
> }
> }
> commit b9d6baec2d346e37798dd1892f6ae95ac9d6c9ef
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:42:31 2013 +0200
>
> Fix task could be used uninitialized
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index 6ba15a3..9d2f3c5 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -82,7 +82,7 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
> VDAgentFileXferStatusMessage* status)
> {
> FileXferTasks::iterator iter;
> - FileXferTask* task;
> + FileXferTask* task = NULL;
> DWORD written;
>
> status->id = data->id;
> @@ -108,13 +108,17 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
> }
> vd_printf("%u completed", iter->first);
> status->result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
> +
> fin:
> - CloseHandle(task->handle);
> - if (status->result != VD_AGENT_FILE_XFER_STATUS_SUCCESS) {
> - DeleteFileA(task->name);
> + if (task) {
> + CloseHandle(task->handle);
> + if (status->result != VD_AGENT_FILE_XFER_STATUS_SUCCESS) {
> + DeleteFileA(task->name);
> + }
> + _tasks.erase(iter);
> + delete task;
> }
> - _tasks.erase(iter);
> - delete task;
> +
> return true;
> }
>
> commit 462295d9f84658aa7b43401fe7d1373cb3b0fc2d
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:41:04 2013 +0200
>
> Fix invalid print format for uint64_t values
>
> format '%lu' expects argument of type 'long unsigned int', but argument
> 9 has type 'uint64_t
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index b7a480c..6ba15a3 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -16,6 +16,10 @@
> */
>
> #include <shlobj.h>
> +#define __STDC_FORMAT_MACROS
> +#define __USE_MINGW_ANSI_STDIO 1
> +#include <inttypes.h>
> +#include <stdio.h>
> #include "file_xfer.h"
>
> FileXfer::~FileXfer()
> @@ -48,7 +52,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> vd_printf("file id %u meta parsing failed", start->id);
> return;
> }
> - vd_printf("%u %s (%llu)", start->id, file_name, file_size);
> + vd_printf("%u %s (%" PRIu64 ")", start->id, file_name, file_size);
> if (FAILED(SHGetFolderPathA(NULL, CSIDL_COMMON_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL,
> SHGFP_TYPE_CURRENT, file_path))) {
> vd_printf("failed getting desktop path");
> @@ -59,7 +63,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> return;
> }
> if (free_bytes.QuadPart < file_size) {
> - vd_printf("insufficient disk space %llu", free_bytes.QuadPart);
> + vd_printf("insufficient disk space %" PRIu64, free_bytes.QuadPart);
> return;
> }
> strcat_s(file_path, MAX_PATH, "\\");
> commit b52c9ddfa862ecd7f774946ed12185384c85a533
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:39:46 2013 +0200
>
> Fix wrong DWORD print fmt
>
> format '%u' expects argument of type 'unsigned int', but argument 8 has type 'DWORD
>
> diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> index 26b6b53..ce259e1 100644
> --- a/vdagent/desktop_layout.cpp
> +++ b/vdagent/desktop_layout.cpp
> @@ -273,7 +273,7 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
> ret = ChangeDisplaySettingsEx(dev_name, dev_mode, NULL, CDS_UPDATEREGISTRY, NULL);
> }
>
> - vd_printf("attach %d", ret);
> + vd_printf("attach %ld", ret);
> hdc = CreateDC(dev_name, NULL, NULL, NULL);
> }
>
> diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
> index fd084a8..73ca39c 100644
> --- a/vdagent/vdagent.cpp
> +++ b/vdagent/vdagent.cpp
> @@ -705,7 +705,7 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size)
> if (err == ERROR_NOT_ENOUGH_MEMORY) {
> vd_printf("Not enough memory to set clipboard data, size %u bytes", size);
> } else {
> - vd_printf("SetClipboardData failed: %u", err);
> + vd_printf("SetClipboardData failed: %lu", err);
> }
> }
> fin:
> @@ -1200,7 +1200,7 @@ bool VDAgent::init_vio_serial()
> _vio_serial = CreateFile(VIOSERIAL_PORT_PATH, GENERIC_READ | GENERIC_WRITE , 0, NULL,
> OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
> if (_vio_serial == INVALID_HANDLE_VALUE) {
> - vd_printf("Failed opening %ls, error %u", VIOSERIAL_PORT_PATH, GetLastError());
> + vd_printf("Failed opening %ls, error %lu", VIOSERIAL_PORT_PATH, GetLastError());
> return false;
> }
> return true;
> commit 3bf46bc2b2a041dcc278a881e5822643a9e4604d
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Wed Jul 17 20:12:37 2013 +0200
>
> dos2unix
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index 0550882..b7a480c 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -20,9 +20,9 @@
>
> FileXfer::~FileXfer()
> {
> - FileXferTasks::iterator iter;
> - FileXferTask* task;
> -
> + FileXferTasks::iterator iter;
> + FileXferTask* task;
> +
> for (iter = _tasks.begin(); iter != _tasks.end(); iter++) {
> task = iter->second;
> CloseHandle(task->handle);
> @@ -36,10 +36,10 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> {
> char* file_meta = (char*)start->data;
> char file_path[MAX_PATH], file_name[MAX_PATH];
> - ULARGE_INTEGER free_bytes;
> - FileXferTask* task;
> + ULARGE_INTEGER free_bytes;
> + FileXferTask* task;
> uint64_t file_size;
> - HANDLE handle;
> + HANDLE handle;
>
> status->id = start->id;
> status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
> @@ -49,7 +49,7 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> return;
> }
> vd_printf("%u %s (%llu)", start->id, file_name, file_size);
> - if (FAILED(SHGetFolderPathA(NULL, CSIDL_COMMON_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL,
> + if (FAILED(SHGetFolderPathA(NULL, CSIDL_COMMON_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL,
> SHGFP_TYPE_CURRENT, file_path))) {
> vd_printf("failed getting desktop path");
> return;
> @@ -64,21 +64,21 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
> }
> strcat_s(file_path, MAX_PATH, "\\");
> strcat_s(file_path, MAX_PATH, file_name);
> - handle = CreateFileA(file_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
> - if (handle == INVALID_HANDLE_VALUE) {
> + handle = CreateFileA(file_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
> + if (handle == INVALID_HANDLE_VALUE) {
> vd_printf("failed creating %s %lu", file_path, GetLastError());
> - return;
> - }
> + return;
> + }
> task = new FileXferTask(handle, file_size, file_path);
> - _tasks[start->id] = task;
> + _tasks[start->id] = task;
> status->result = VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA;
> }
>
> bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
> VDAgentFileXferStatusMessage* status)
> {
> - FileXferTasks::iterator iter;
> - FileXferTask* task;
> + FileXferTasks::iterator iter;
> + FileXferTask* task;
> DWORD written;
>
> status->id = data->id;
> @@ -116,8 +116,8 @@ fin:
>
> void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
> {
> - FileXferTasks::iterator iter;
> - FileXferTask* task;
> + FileXferTasks::iterator iter;
> + FileXferTask* task;
>
> vd_printf("id %u result %u", status->id, status->result);
> if (status->result != VD_AGENT_FILE_XFER_STATUS_CANCELLED) {
> diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
> index e5567f3..fd084a8 100644
> --- a/vdagent/vdagent.cpp
> +++ b/vdagent/vdagent.cpp
> @@ -450,7 +450,7 @@ void VDAgent::input_desktop_message_loop()
> vd_printf("WTSRegisterSessionNotification() failed: %lu", GetLastError());
> }
> if (_system_version == SYS_VER_WIN_7_CLASS) {
> - _add_clipboard_listener(_hwnd);
> + _add_clipboard_listener(_hwnd);
> } else {
> _hwnd_next_viewer = SetClipboardViewer(_hwnd);
> }
> @@ -463,7 +463,7 @@ void VDAgent::input_desktop_message_loop()
> _pending_input = false;
> }
> if (_system_version == SYS_VER_WIN_7_CLASS) {
> - _remove_clipboard_listener(_hwnd);
> + _remove_clipboard_listener(_hwnd);
> } else {
> ChangeClipboardChain(_hwnd, _hwnd_next_viewer);
> }
> @@ -948,9 +948,9 @@ void VDAgent::on_clipboard_grab()
> set_clipboard_owner(owner_guest);
> } else {
> UINT format = 0;
> - while (format = EnumClipboardFormats(format)) {
> - vd_printf("Unsupported clipboard format %u", format);
> - }
> + while (format = EnumClipboardFormats(format)) {
> + vd_printf("Unsupported clipboard format %u", format);
> + }
> }
> }
>
> @@ -1053,7 +1053,7 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
> uint8_t* new_data = NULL;
> long new_size;
> size_t len = 0;
> - CxImage image;
> + CxImage image;
>
> if (_clipboard_owner != owner_guest) {
> vd_printf("Received clipboard request from client while clipboard is not owned by guest");
> @@ -1087,19 +1087,19 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
> DWORD cximage_format = get_cximage_format(clipboard_request->type);
> HPALETTE pal = 0;
>
> - ASSERT(cximage_format);
> - if (IsClipboardFormatAvailable(CF_PALETTE)) {
> + ASSERT(cximage_format);
> + if (IsClipboardFormatAvailable(CF_PALETTE)) {
> pal = (HPALETTE)GetClipboardData(CF_PALETTE);
> }
> - if (!image.CreateFromHBITMAP((HBITMAP)clip_data, pal)) {
> - vd_printf("Image create from handle failed");
> - break;
> - }
> - if (!image.Encode(new_data, new_size, cximage_format)) {
> - vd_printf("Image encode to type %u failed", clipboard_request->type);
> - break;
> - }
> - vd_printf("Image encoded to %lu bytes", new_size);
> + if (!image.CreateFromHBITMAP((HBITMAP)clip_data, pal)) {
> + vd_printf("Image create from handle failed");
> + break;
> + }
> + if (!image.Encode(new_data, new_size, cximage_format)) {
> + vd_printf("Image encode to type %u failed", clipboard_request->type);
> + break;
> + }
> + vd_printf("Image encoded to %lu bytes", new_size);
> break;
> }
> }
> @@ -1124,8 +1124,8 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
> break;
> case VD_AGENT_CLIPBOARD_IMAGE_PNG:
> case VD_AGENT_CLIPBOARD_IMAGE_BMP:
> - memcpy(clipboard->data, new_data, new_size);
> - image.FreeMemory(new_data);
> + memcpy(clipboard->data, new_data, new_size);
> + image.FreeMemory(new_data);
> break;
> }
> CloseClipboard();
> commit 846a787c9f4049ca957b09e9a3f3b02ed771873b
> Author: Marc-Andr?? Lureau <marcandre.lureau at gmail.com>
> Date: Thu May 2 16:10:59 2013 +0200
>
> Update spice-protocol
>
> diff --git a/spice-protocol b/spice-protocol
> index df6bc62..784407f 160000
> --- a/spice-protocol
> +++ b/spice-protocol
> @@ -1 +1 @@
> -Subproject commit df6bc6269ebd3144663cbdb8457fbe71d9202b6a
> +Subproject commit 784407f248e7f99d2bfcc9368f9acd1efb2b9617
> _______________________________________________
> Spice-commits mailing list
> Spice-commits at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-commits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130726/85308c49/attachment.pgp>
More information about the Spice-devel
mailing list