]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
More LOG() calls changed to variadic form - dndcp plugin.
authorOliver Kurth <okurth@vmware.com>
Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)
committerOliver Kurth <okurth@vmware.com>
Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)
open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c
open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c
open-vm-tools/services/plugins/dndcp/dnd/dndMsg.c
open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp
open-vm-tools/services/plugins/dndcp/dndGuest/rpcV4Util.cpp

index 44f4cf3975ad332f555970363e67468ec58717c0..8bea543dee772c33ec8245d02168a1d79fbebcd3 100644 (file)
@@ -45,6 +45,7 @@
 #include "hostinfo.h"
 
 #define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
 #include "loglevel_user.h"
 
 #define WIN_DIRSEPC     '\\'
@@ -476,7 +477,7 @@ DnD_LegacyConvertToCPName(const char *nameIn,   // IN:  Buffer to convert
    memcpy(fullName + partialNameLen + partialNameSuffixLen, nameIn, nameSize);
    fullName[fullNameSize] = '\0';
 
-   LOG(4, ("%s: generated name is \"%s\"\n", __FUNCTION__, fullName));
+   LOG(4, "%s: generated name is \"%s\"\n", __FUNCTION__, fullName);
 
    /*
     * CPName_ConvertTo implementation is performed here without calling any
@@ -546,8 +547,8 @@ DnD_LegacyConvertToCPName(const char *nameIn,   // IN:  Buffer to convert
        * logging
        */
 
-      LOG(4, ("%s: CPName is \"%s\"\n", __FUNCTION__, 
-              CPName_Print(origOut, result)));
+      LOG(4, "%s: CPName is \"%s\"\n", __FUNCTION__, 
+          CPName_Print(origOut, result));
    }
 
 out:
index 891336524b6ba594bd420944fc23d0431a0e162c..90c11a6ba175b1b8eb252f9da35c4ad2abc41b17 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2005-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2005-2019 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
@@ -46,7 +46,9 @@
 #endif
 
 #define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
 #include "loglevel_user.h"
+
 #include "unicodeOperations.h"
 
 
@@ -300,13 +302,13 @@ Bool
 DnD_AddBlockLegacy(int blockFd,                    // IN
                    const char *blockPath)          // IN
 {
-   LOG(1, ("%s: placing block on %s\n", __func__, blockPath));
+   LOG(1, "%s: placing block on %s\n", __func__, blockPath);
 
    ASSERT(blockFd >= 0);
 
    if (VMBLOCK_CONTROL(blockFd, VMBLOCK_ADD_FILEBLOCK, blockPath) != 0) {
-      LOG(1, ("%s: Cannot add block on %s (%s)\n",
-              __func__, blockPath, Err_Errno2String(errno)));
+      LOG(1, "%s: Cannot add block on %s (%s)\n",
+          __func__, blockPath, Err_Errno2String(errno));
 
       return FALSE;
    }
@@ -335,7 +337,7 @@ Bool
 DnD_RemoveBlockLegacy(int blockFd,                    // IN
                       const char *blockedPath)        // IN
 {
-   LOG(1, ("%s: removing block on %s\n", __func__, blockedPath));
+   LOG(1, "%s: removing block on %s\n", __func__, blockedPath);
 
    if (blockFd >= 0) {
       if (VMBLOCK_CONTROL(blockFd, VMBLOCK_DEL_FILEBLOCK, blockedPath) != 0) {
@@ -345,8 +347,8 @@ DnD_RemoveBlockLegacy(int blockFd,                    // IN
          return FALSE;
       }
    } else {
-      LOG(4, ("%s: Could not remove block on %s: "
-              "fd to vmblock no longer exists.\n", __func__, blockedPath));
+      LOG(4, "%s: Could not remove block on %s: "
+          "fd to vmblock no longer exists.\n", __func__, blockedPath);
    }
 
    return TRUE;
@@ -399,14 +401,14 @@ Bool
 DnD_AddBlockFuse(int blockFd,                    // IN
                  const char *blockPath)          // IN
 {
-   LOG(1, ("%s: placing block on %s\n", __func__, blockPath));
+   LOG(1, "%s: placing block on %s\n", __func__, blockPath);
 
    ASSERT(blockFd >= 0);
 
    if (VMBLOCK_CONTROL_FUSE(blockFd, VMBLOCK_FUSE_ADD_FILEBLOCK,
                             blockPath) != 0) {
-      LOG(1, ("%s: Cannot add block on %s (%s)\n",
-              __func__, blockPath, Err_Errno2String(errno)));
+      LOG(1, "%s: Cannot add block on %s (%s)\n",
+          __func__, blockPath, Err_Errno2String(errno));
 
       return FALSE;
    }
@@ -435,7 +437,7 @@ Bool
 DnD_RemoveBlockFuse(int blockFd,                    // IN
                     const char *blockedPath)        // IN
 {
-   LOG(1, ("%s: removing block on %s\n", __func__, blockedPath));
+   LOG(1, "%s: removing block on %s\n", __func__, blockedPath);
 
    if (blockFd >= 0) {
       if (VMBLOCK_CONTROL_FUSE(blockFd, VMBLOCK_FUSE_DEL_FILEBLOCK,
@@ -446,8 +448,8 @@ DnD_RemoveBlockFuse(int blockFd,                    // IN
          return FALSE;
       }
    } else {
-      LOG(4, ("%s: Could not remove block on %s: "
-              "fd to vmblock no longer exists.\n", __func__, blockedPath));
+      LOG(4, "%s: Could not remove block on %s: "
+          "fd to vmblock no longer exists.\n", __func__, blockedPath);
    }
 
    return TRUE;
@@ -479,8 +481,7 @@ DnD_CheckBlockFuse(int blockFd)                    // IN
 
    size = read(blockFd, buf, sizeof(VMBLOCK_FUSE_READ_RESPONSE));
    if (size < 0) {
-      LOG(4, ("%s: read failed, error %s.\n",
-              __func__, Err_Errno2String(errno)));
+      LOG(4, "%s: read failed, error %s.\n", __func__, Err_Errno2String(errno));
 
       return FALSE;
    }
@@ -489,16 +490,16 @@ DnD_CheckBlockFuse(int blockFd)                    // IN
       /*
        * Refer to bug 817761 of casting size to size_t.
        */
-      LOG(4, ("%s: Response too short (%"FMTSZ"u vs. %"FMTSZ"u).\n",
-              __func__, (size_t)size, sizeof(VMBLOCK_FUSE_READ_RESPONSE)));
+      LOG(4, "%s: Response too short (%"FMTSZ"u vs. %"FMTSZ"u).\n",
+          __func__, (size_t)size, sizeof(VMBLOCK_FUSE_READ_RESPONSE));
 
       return FALSE;
    }
 
    if (memcmp(buf, VMBLOCK_FUSE_READ_RESPONSE,
               sizeof(VMBLOCK_FUSE_READ_RESPONSE))) {
-      LOG(4, ("%s: Invalid response %.*s",
-              __func__, (int)sizeof(VMBLOCK_FUSE_READ_RESPONSE) - 1, buf));
+      LOG(4, "%s: Invalid response %.*s\n",
+          __func__, (int)sizeof(VMBLOCK_FUSE_READ_RESPONSE) - 1, buf);
 
       return FALSE;
    }
@@ -559,7 +560,7 @@ DnD_TryInitVmblock(const char *vmbFsName,          // IN
    /* Make sure the vmblock file system is mounted. */
    fp = OPEN_MNTFILE("r");
    if (fp == NULL) {
-      LOG(1, ("%s: could not open mount file\n", __func__));
+      LOG(1, "%s: could not open mount file\n", __func__);
       goto out;
    }
 
@@ -582,14 +583,13 @@ DnD_TryInitVmblock(const char *vmbFsName,          // IN
       /* Open device node for communication with vmblock. */
       blockFd = Posix_Open(vmbDevice, vmbDeviceMode);
       if (blockFd < 0) {
-         LOG(1, ("%s: Can not open blocker device (%s)\n",
-                 __func__, Err_Errno2String(errno)));
+         LOG(1, "%s: Can not open blocker device (%s)\n",
+             __func__, Err_Errno2String(errno));
       } else {
-         LOG(4, ("%s: Opened blocker device at %s\n",
-                 __func__, VMBLOCK_DEVICE));
+         LOG(4, "%s: Opened blocker device at %s\n", __func__, VMBLOCK_DEVICE);
          if (verifyBlock && !verifyBlock(blockFd)) {
-            LOG(4, ("%s: Blocker device at %s did not pass checks, closing.\n",
-                    __func__, VMBLOCK_DEVICE));
+            LOG(4, "%s: Blocker device at %s did not pass checks, closing.\n",
+                __func__, VMBLOCK_DEVICE);
             close(blockFd);
             blockFd = -1;
          }
@@ -655,7 +655,7 @@ DnD_InitializeBlocking(DnDBlockControl *blkCtrl)   // OUT
       goto out;
    }
 
-   LOG(4, ("%s: could not find vmblock mounted\n", __func__));
+   LOG(4, "%s: could not find vmblock mounted\n", __func__);
 out:
    Id_EndSuperUser(uid);
 
index 291d5db7c77373a338bd6128c020b32129878c75..1d4ad55f756fb90910f741c11fdfc32292c678db 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2016,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2019 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
@@ -37,6 +37,7 @@
 #include "dndInt.h"
 
 #define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
 #include "loglevel_user.h"
 
 
index 655bf41de5b15e93d5fb43c9b7565a9e70fb12d4..cb5b632884bc4d1e444d47e559cee8b1cfbbe604 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2010-2017,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2019 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
 #ifdef VMX86_TOOLS
 extern "C" {      
    #include "debug.h"
-   #define LOG(level, msg) (Debug msg)
+   /* gcc needs special syntax to handle zero-length variadic arguments */
+   #if defined(_MSC_VER)
+   #define LOG(level, fmt, ...) Debug(fmt, __VA_ARGS__)
+   #else
+   #define LOG(level, fmt, ...) Debug(fmt, ##__VA_ARGS__)
+   #endif
 }
 #else
    #define LOGLEVEL_MODULE dnd
+   #define LOGLEVEL_VARIADIC
    #include "loglevel_user.h"
 #endif
 
@@ -139,14 +145,14 @@ RpcV3Util::SendMsg(uint32 cmd,
 
    /* Serialize clip and output into buf. */
    if (!CPClipboard_Serialize(clip, &buf)) {
-      LOG(0, ("%s: CPClipboard_Serialize failed.\n", __FUNCTION__));
+      LOG(0, "%s: CPClipboard_Serialize failed.\n", __FUNCTION__);
       goto exit;
    }
 
    /* Construct msg with both cmd CP_HG_SET_CLIPBOARD and buf. */
    DnDMsg_SetCmd(&msg, cmd);
    if (!DnDMsg_AppendArg(&msg, DynBuf_Get(&buf), DynBuf_GetSize(&buf))) {
-      LOG(0, ("%s: DnDMsg_AppendData failed.\n", __FUNCTION__));
+      LOG(0, "%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -184,7 +190,7 @@ RpcV3Util::SendMsg(uint32 cmd,
 
    if (!DnDMsg_AppendArg(&msg, &x, sizeof x) ||
        !DnDMsg_AppendArg(&msg, &y, sizeof y)) {
-      LOG(0, ("%s: DnDMsg_AppendData failed.\n", __FUNCTION__));
+      LOG(0, "%s: DnDMsg_AppendData failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -214,7 +220,7 @@ RpcV3Util::SendMsg(const DnDMsg *msg)
 
    /* Serialize msg and output to buf. */
    if (!DnDMsg_Serialize((DnDMsg *)msg, &buf)) {
-      LOG(0, ("%s: DnDMsg_Serialize failed.\n", __FUNCTION__));
+      LOG(0, "%s: DnDMsg_Serialize failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -244,11 +250,11 @@ RpcV3Util::SendMsg(const uint8 *binary,
    bool ret = FALSE;
 
    if (binarySize > DNDMSG_MAX_ARGSZ) {
-      LOG(1, ("%s: message is too big, quit.\n", __FUNCTION__));
+      LOG(1, "%s: message is too big, quit.\n", __FUNCTION__);
       return false;
    }
 
-   LOG(4, ("%s: got message, size %d.\n", __FUNCTION__, binarySize));
+   LOG(4, "%s: got message, size %d.\n", __FUNCTION__, binarySize);
 
    if (binarySize <= DND_MAX_TRANSPORT_PACKET_PAYLOAD_SIZE) {
       /*
@@ -271,8 +277,8 @@ RpcV3Util::SendMsg(const uint8 *binary,
 
          if ((Hostinfo_SystemTimerUS() - mSendBuf.lastUpdateTime) <
              DND_MAX_TRANSPORT_LATENCY_TIME) {
-            LOG(1, ("%s: got a big buffer, but there is another pending one, drop it\n",
-                    __FUNCTION__));
+            LOG(1, "%s: got a big buffer, but there is another pending one, drop it\n",
+                __FUNCTION__);
             return false;
          }
       }
@@ -329,7 +335,8 @@ RpcV3Util::OnRecvPacket(uint32 srcId,
          if (packetV3->payloadSize ||
              packetV3->seqNum != mSendBuf.seqNum ||
              packetV3->offset != mSendBuf.offset) {
-            LOG(0, ("%s: received packet does not match local buffer.\n", __FUNCTION__));
+            LOG(0, "%s: received packet does not match local buffer.\n",
+                __FUNCTION__);
             return;
          }
 
@@ -340,7 +347,7 @@ RpcV3Util::OnRecvPacket(uint32 srcId,
              * Not needed to reset mSendBuf because DnD_TransportBufGetPacket already
              * did that.
              */
-            LOG(0, ("%s: DnD_TransportBufGetPacket failed.\n", __FUNCTION__));
+            LOG(0, "%s: DnD_TransportBufGetPacket failed.\n", __FUNCTION__);
             return;
          }
 
@@ -383,7 +390,7 @@ RpcV3Util::OnRecvPacket(uint32 srcId,
 
       /* Received next packet for big binary buffer. */
       if (!DnD_TransportBufAppendPacket(&mRecvBuf, packetV3, packetSize)) {
-         LOG(0, ("%s: DnD_TransportBufAppendPacket failed.\n", __FUNCTION__));
+         LOG(0, "%s: DnD_TransportBufAppendPacket failed.\n", __FUNCTION__);
          return;
       }
 
@@ -402,7 +409,7 @@ RpcV3Util::OnRecvPacket(uint32 srcId,
          replyPacketSize = DnD_TransportReqPacket(&mRecvBuf, &replyPacket);
 
          if (!replyPacketSize) {
-            LOG(0, ("%s: DnD_TransportReqPacket failed.\n", __FUNCTION__));
+            LOG(0, "%s: DnD_TransportReqPacket failed.\n", __FUNCTION__);
             return;
          }
 
@@ -413,12 +420,12 @@ RpcV3Util::OnRecvPacket(uint32 srcId,
       }
       break;
    default:
-      LOG(0, ("%s: unknown packet.\n", __FUNCTION__));
+      LOG(0, "%s: unknown packet.\n", __FUNCTION__);
       break;
    }
 
 invalid_packet:
-   LOG(0, ("%s: received invalid data.\n", __FUNCTION__));
+   LOG(0, "%s: received invalid data.\n", __FUNCTION__);
 }
 
 
index 12ab4ecc5f5a89ad9bcae4daccdbe9fac0cd7e86..4d9c573e76114f74995705d022afcbc3deefe61b 100644 (file)
 #ifdef VMX86_TOOLS
 extern "C" {
    #include "debug.h"
-   #define LOG(level, msg) (Debug msg)
+   /* gcc needs special syntax to handle zero-length variadic arguments */
+   #if defined(_MSC_VER)
+   #define LOG(level, fmt, ...) Debug(fmt, __VA_ARGS__)
+   #else
+   #define LOG(level, fmt, ...) Debug(fmt, ##__VA_ARGS__)
+   #endif
 }
 #else
    #define LOGLEVEL_MODULE dnd
+   #define LOGLEVEL_VARIADIC
    #include "loglevel_user.h"
 #endif
 
@@ -144,7 +150,7 @@ RpcV4Util::SendMsg(RpcParams *params,
    DynBuf_Init(&buf);
 
    if (!CPClipboard_Serialize(clip, &buf)) {
-      LOG(0, ("%s: CPClipboard_Serialize failed.\n", __FUNCTION__));
+      LOG(0, "%s: CPClipboard_Serialize failed.\n", __FUNCTION__);
       goto exit;
    }
 
@@ -341,7 +347,7 @@ RpcV4Util::SendMsg(DnDCPMsgV4 *msg)
 
    if (!DnDCPMsgV4_SerializeWithInputPayloadSizeCheck(msg, &packet,
       &packetSize, mMaxTransportPacketPayloadSize)) {
-      LOG(1, ("%s: DnDCPMsgV4_Serialize failed. \n", __FUNCTION__));
+      LOG(1, "%s: DnDCPMsgV4_Serialize failed. \n", __FUNCTION__);
       return false;
    }
 
@@ -385,7 +391,7 @@ RpcV4Util::OnRecvPacket(uint32 srcId,
       HandlePacket(srcId, packet, packetSize, packetType);
       break;
    default:
-      LOG(1, ("%s: invalid packet. \n", __FUNCTION__));
+      LOG(1, "%s: invalid packet. \n", __FUNCTION__);
       SendCmdReplyMsg(srcId, DNDCP_CMD_INVALID, DND_CP_MSG_STATUS_INVALID_PACKET);
       break;
    }
@@ -410,7 +416,7 @@ RpcV4Util::HandlePacket(uint32 srcId,
    DnDCPMsgV4_Init(&msgIn);
 
    if (!DnDCPMsgV4_UnserializeSingle(&msgIn, packet, packetSize)) {
-      LOG(1, ("%s: invalid packet. \n", __FUNCTION__));
+      LOG(1, "%s: invalid packet. \n", __FUNCTION__);
       SendCmdReplyMsg(srcId, DNDCP_CMD_INVALID, DND_CP_MSG_STATUS_INVALID_PACKET);
       return;
    }
@@ -438,7 +444,7 @@ RpcV4Util::HandlePacket(uint32 srcId,
                     DnDCPMsgPacketType packetType)
 {
    if (!DnDCPMsgV4_UnserializeMultiple(&mBigMsgIn, packet, packetSize)) {
-      LOG(1, ("%s: invalid packet. \n", __FUNCTION__));
+      LOG(1, "%s: invalid packet. \n", __FUNCTION__);
       SendCmdReplyMsg(srcId, DNDCP_CMD_INVALID, DND_CP_MSG_STATUS_INVALID_PACKET);
       goto cleanup;
    }
@@ -451,7 +457,7 @@ RpcV4Util::HandlePacket(uint32 srcId,
     */
    if (DND_CP_MSG_PACKET_TYPE_MULTIPLE_END != packetType) {
       if (!RequestNextPacket()) {
-         LOG(1, ("%s: RequestNextPacket failed.\n", __FUNCTION__));
+         LOG(1, "%s: RequestNextPacket failed.\n", __FUNCTION__);
          goto cleanup;
       }
       /*
@@ -490,7 +496,7 @@ RpcV4Util::HandleMsg(DnDCPMsgV4 *msgIn)
       bool ret = SendMsg(&mBigMsgOut);
 
       if (!ret) {
-         LOG(1, ("%s: SendMsg failed. \n", __FUNCTION__));
+         LOG(1, "%s: SendMsg failed. \n", __FUNCTION__);
       }
 
       /*
@@ -693,8 +699,8 @@ RpcV4Util::SetMaxTransportPacketSize(const uint32 size)
        * if the new size is stricter than the default one.
        */
       mMaxTransportPacketPayloadSize = newProposedPayloadSize;
-      LOG(1, ("%s: The packet size is set to %u. \n", __FUNCTION__,
-              mMaxTransportPacketPayloadSize));
+      LOG(1, "%s: The packet size is set to %u. \n", __FUNCTION__,
+          mMaxTransportPacketPayloadSize);
    }
 }