Re: [spice-gtk] Fix VD_AGENT_HAS_CAPABILITY use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good, ack.

On 09/07/2012 04:07 PM, Christophe Fergeau wrote:
The 'size' argument to this macro (defined in
spice-protocol/spice/vd_agent.h) is the number of 32 bit elements
available in its first argument. In channel-main.c it's used
most of the time with SpiceMainChannelPrivate::agent_caps which is
an uint32_t[VD_AGENT_CAPS_SIZE]. The 'size' argument to pass to
VD_AGENT_HAS_CAPABILITY is thus the number of elements in this array,
and not sizeof(agent_caps).

Fixes rhbz#837545
---
  gtk/channel-main.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index ff9b0c1..a413ec4 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1041,7 +1041,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
  }

  #define HAS_CLIPBOARD_SELECTION(c) \
-    VD_AGENT_HAS_CAPABILITY((c)->agent_caps, sizeof((c)->agent_caps), VD_AGENT_CAP_CLIPBOARD_SELECTION)
+    VD_AGENT_HAS_CAPABILITY((c)->agent_caps, G_N_ELEMENTS((c)->agent_caps), VD_AGENT_CAP_CLIPBOARD_SELECTION)

  /* any context: the message is not flushed immediately,
     you can wakeup() the channel coroutine or send_msg_queue() */
@@ -1058,7 +1058,7 @@ static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection,
          return;

      g_return_if_fail(VD_AGENT_HAS_CAPABILITY(c->agent_caps,
-        sizeof(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
+        G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));

      size = sizeof(VDAgentClipboardGrab) + sizeof(uint32_t) * ntypes;
      if (HAS_CLIPBOARD_SELECTION(c))
@@ -1098,7 +1098,7 @@ static void agent_clipboard_notify(SpiceMainChannel *channel, guint selection,
      g_return_if_fail(c->agent_connected);

      g_return_if_fail(VD_AGENT_HAS_CAPABILITY(c->agent_caps,
-        sizeof(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
+        G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));

      msgsize = sizeof(VDAgentClipboard);
      if (HAS_CLIPBOARD_SELECTION(c))
@@ -1134,7 +1134,7 @@ static void agent_clipboard_request(SpiceMainChannel *channel, guint selection,
      g_return_if_fail(c->agent_connected);

      g_return_if_fail(VD_AGENT_HAS_CAPABILITY(c->agent_caps,
-        sizeof(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
+        G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));

      msgsize = sizeof(VDAgentClipboardRequest);
      if (HAS_CLIPBOARD_SELECTION(c))
@@ -1170,7 +1170,7 @@ static void agent_clipboard_release(SpiceMainChannel *channel, guint selection)
      g_return_if_fail(c->agent_connected);

      g_return_if_fail(VD_AGENT_HAS_CAPABILITY(c->agent_caps,
-        sizeof(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
+        G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));

      if (HAS_CLIPBOARD_SELECTION(c)) {
          msg[0] = selection;
@@ -1398,7 +1398,7 @@ static void main_agent_handle_msg(SpiceChannel *channel,
      case VD_AGENT_CLIPBOARD_REQUEST:
      case VD_AGENT_CLIPBOARD_GRAB:
      case VD_AGENT_CLIPBOARD:
-        if (VD_AGENT_HAS_CAPABILITY(c->agent_caps, sizeof(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_SELECTION)) {
+        if (VD_AGENT_HAS_CAPABILITY(c->agent_caps, G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_CLIPBOARD_SELECTION)) {
              selection = *((guint8*)payload);
              payload = ((guint8*)payload) + 4;
              msg->size -= 4;
@@ -1431,7 +1431,7 @@ static void main_agent_handle_msg(SpiceChannel *channel,
          if (caps->request)
              agent_announce_caps(SPICE_MAIN_CHANNEL(channel));

-        if (VD_AGENT_HAS_CAPABILITY(caps->caps, sizeof(c->agent_caps), VD_AGENT_CAP_DISPLAY_CONFIG) &&
+        if (VD_AGENT_HAS_CAPABILITY(caps->caps, G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_DISPLAY_CONFIG) &&
              !c->agent_display_config_sent) {
              agent_display_config(SPICE_MAIN_CHANNEL(channel));
              agent_send_msg_queue(SPICE_MAIN_CHANNEL(channel));
@@ -2021,7 +2021,7 @@ gboolean spice_main_agent_test_capability(SpiceMainChannel *channel, guint32 cap
      if (!c->agent_caps_received)
          return FALSE;

-    return VD_AGENT_HAS_CAPABILITY(c->agent_caps, sizeof(c->agent_caps), cap);
+    return VD_AGENT_HAS_CAPABILITY(c->agent_caps, G_N_ELEMENTS(c->agent_caps), cap);
  }

  /**

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]