Skip to content

Commit

Permalink
Fix issues using GCC 11 with gtk >= 3.20 and glib >=2.66.3
Browse files Browse the repository at this point in the history
With glib2.0 releases >= 2.66.3, glib header files inside an
extern "C" block will encounter compilation errors.  This has
impacted several OSS packages.  Consumers of newer versions of glib2.0
must not include glib headers in an extern "C" block.

GTK 3.20 has deprecated gdk_display_get_device_manager(); using the
newer gdk_display_get_default_seat() when the GTK version is >= 3.20.

The return value from read() must be used to avoid an unused result
warning from the compiler.  This can be avoided by using dummy retyping
in the case where the return value is not used or in this case, using
the returned value in a debug log message.

Pull Request: #505
Addresses:    #500
Addresses:    #509
  • Loading branch information
johnwvmw committed Apr 19, 2021
1 parent d8ccbf4 commit 82931a1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions open-vm-tools/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ Christian Ehrhardt Build: fix propagation of libtirpc flags

Vincent Milum Jr Adding FreeBSD on ARM64 support to open-vm-tools.
- https://github.com/vmware/open-vm-tools/pull/474

Miroslav Rezanina Fix issues using GCC 11 with gtk >= 3.20 and glib >=2.66.3
- https://github.com/vmware/open-vm-tools/pull/505
4 changes: 1 addition & 3 deletions open-vm-tools/lib/include/tracer.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2013-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2013-2017,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -28,9 +28,7 @@

#include "vm_basic_defs.h"

extern "C" {
#include "glib.h"
}


#ifdef VMX86_DEVEL
Expand Down
3 changes: 2 additions & 1 deletion open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2009-2020 VMware, Inc. All rights reserved.
* Copyright (C) 2009-2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -1666,6 +1666,7 @@ CopyPasteUIX11::FileBlockMonitorThread(void *arg) // IN
char buf[sizeof(VMBLOCK_FUSE_READ_RESPONSE)];
ssize_t size;
size = read(fd, buf, sizeof(VMBLOCK_FUSE_READ_RESPONSE));
g_debug("%s: Number of bytes read : %" FMTSZ "u\n", __FUNCTION__, size);
/*
* The current thread will block in read function until
* any other application accesses the file params->fileBlockName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2010-2017,2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -31,13 +31,13 @@

#include "dnd.h"

extern "C" {
#ifdef VMX86_TOOLS
#include "vmware/tools/guestrpc.h"
#else
extern "C" {
#include "guest_rpc.h"
#endif
}
#endif

#define GUEST_RPC_CMD_STR_DND "dnd.transport"
#define GUEST_RPC_CMD_STR_CP "copypaste.transport"
Expand Down
11 changes: 9 additions & 2 deletions open-vm-tools/services/plugins/dndcp/dndUIX11.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2009-2019 VMware, Inc. All rights reserved.
* Copyright (C) 2009-2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -467,8 +467,15 @@ DnDUIX11::OnSrcDragBegin(const CPClipboard *clip, // IN
#ifndef GTK3
event.device = gdk_device_get_core_pointer();
#else
GdkDeviceManager* manager = gdk_display_get_device_manager(gdk_window_get_display(event.window));
# if GTK_MINOR_VERSION >= 20
GdkSeat *seat =
gdk_display_get_default_seat(gdk_window_get_display(event.window));
event.device = gdk_seat_get_pointer(seat);
# else
GdkDeviceManager *manager =
gdk_display_get_device_manager(gdk_window_get_display(event.window));
event.device = gdk_device_manager_get_client_pointer(manager);
# endif
#endif
event.x_root = mOrigin.get_x();
event.y_root = mOrigin.get_y();
Expand Down
7 changes: 6 additions & 1 deletion open-vm-tools/services/plugins/dndcp/dndcp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2010-2019 VMware, Inc. All rights reserved.
* Copyright (C) 2010-2021 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -31,6 +31,11 @@

#define G_LOG_DOMAIN "dndcp"

/**
* Include glib.h before encountering any extern "C".
*/
#include <glib.h>

extern "C" {
#include "vmware/guestrpc/tclodefs.h"
#include "vmware/tools/plugin.h"
Expand Down

0 comments on commit 82931a1

Please sign in to comment.