#include "hostinfo.h"
#define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
#include "loglevel_user.h"
#define WIN_DIRSEPC '\\'
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
* 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:
/*********************************************************
- * 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
#endif
#define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
#include "loglevel_user.h"
+
#include "unicodeOperations.h"
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;
}
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) {
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;
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;
}
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,
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;
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;
}
/*
* 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;
}
/* 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;
}
/* 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;
}
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);
/*********************************************************
- * 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
#include "dndInt.h"
#define LOGLEVEL_MODULE dnd
+#define LOGLEVEL_VARIADIC
#include "loglevel_user.h"
/*********************************************************
- * 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
/* 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;
}
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;
}
/* 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;
}
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) {
/*
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;
}
}
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;
}
* 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;
}
/* 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;
}
replyPacketSize = DnD_TransportReqPacket(&mRecvBuf, &replyPacket);
if (!replyPacketSize) {
- LOG(0, ("%s: DnD_TransportReqPacket failed.\n", __FUNCTION__));
+ LOG(0, "%s: DnD_TransportReqPacket failed.\n", __FUNCTION__);
return;
}
}
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__);
}
#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
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;
}
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;
}
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;
}
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;
}
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;
}
*/
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;
}
/*
bool ret = SendMsg(&mBigMsgOut);
if (!ret) {
- LOG(1, ("%s: SendMsg failed. \n", __FUNCTION__));
+ LOG(1, "%s: SendMsg failed. \n", __FUNCTION__);
}
/*
* 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);
}
}