#define vm_warning(fmt, ...) g_warning("%s: " fmt, FUNC, ## __VA_ARGS__)
#endif // ! (windows & glib >= 2.46)
+/* Checks if a string is null before it is passed in logging function */
+#define VM_SAFE_STR(string) (string != NULL ? string : "(NULL)")
G_BEGIN_DECLS
&reply, &replyLen);
if (!status) {
g_warning("%s: update failed: request \"%s\", reply \"%s\".\n",
- __FUNCTION__, request, reply);
+ __FUNCTION__, request, VM_SAFE_STR(reply));
}
vm_free(reply);
}
status = RpcChannel_Send(ctx->rpc, message, msgLength, &reply, &replyLen);
if (!status) {
g_warning("%s: update failed: request \"%s\", reply \"%s\".\n",
- __FUNCTION__, request, reply);
+ __FUNCTION__, request, VM_SAFE_STR(reply));
}
vm_free(reply);
}
} else {
g_debug("%s: RPC failed (%d) reply '%s'\n",
- __FUNCTION__, status, reply ? reply : "");
+ __FUNCTION__, status, VM_SAFE_STR(reply));
}
vm_free(reply);
/*********************************************************
- * Copyright (C) 2007-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2020 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
#include "vmware/tools/utils.h"
#include "vmware/tools/vmbackup.h"
+#include "vmware/tools/log.h"
#include "xdrutil.h"
#if !defined(__APPLE__)
NULL);
} else {
g_warning("Failed to send vmbackup event: %s, result: %s.\n",
- msg, result);
+ msg, VM_SAFE_STR(result));
}
vm_free(result);
g_free(msg);
if (!RpcChannel_Send(state->ctx.rpc, toolsVersion, strlen(toolsVersion) + 1,
&result, &resultLen)) {
- g_warning("Error setting tools version: %s.\n", result);
+ g_warning("Error setting tools version: %s.\n",
+ VM_SAFE_STR(result));
}
}
vm_free(result);
cap->name,
set ? cap->value : 0);
if (!RpcChannel_Send(chan, tmp, strlen(tmp) + 1, &result, &resultLen)) {
- g_warning("Error sending capability %s: %s\n", cap->name, result);
+ g_warning("Error sending capability %s: %s\n", cap->name,
+ VM_SAFE_STR(result));
}
vm_free(result);
g_free(tmp);
if (set) {
tmp = g_strdup_printf("tools.capability.%s ", cap->name);
if (!RpcChannel_Send(chan, tmp, strlen(tmp), &result, &resultLen)) {
- g_warning("Error sending capability %s: %s\n", cap->name, result);
+ g_warning("Error sending capability %s: %s\n", cap->name,
+ VM_SAFE_STR(result));
}
vm_free(result);
g_free(tmp);
if (newcaps != NULL) {
result = NULL;
if (!RpcChannel_Send(chan, newcaps, strlen(newcaps) + 1, &result, &resultLen)) {
- g_warning("Error sending new-style capabilities: %s\n", result);
+ g_warning("Error sending new-style capabilities: %s\n",
+ VM_SAFE_STR(result));
}
vm_free(result);
g_free(newcaps);
/*********************************************************
- * Copyright (C) 2015-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2015-2020 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 "toolboxCmdInt.h"
#include "vmware/tools/i18n.h"
#include "vmware/tools/utils.h"
+#include "vmware/tools/log.h"
#ifdef _WIN32
#include "netutil.h"
#endif
&reply, &replyLen);
if (!status) {
g_warning("%s: update failed: request \"%s\", reply \"%s\".\n",
- __FUNCTION__, request, reply);
+ __FUNCTION__, request, VM_SAFE_STR(reply));
}
ToolsCmd_FreeRPC(reply);
}
/*********************************************************
- * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2020 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 "wiper.h"
#include "vmware/guestrpc/tclodefs.h"
#include "vmware/tools/i18n.h"
+#include "vmware/tools/log.h"
#ifndef _WIN32
static void ShrinkWiperDestroy(int signal);
SU_(disk.shrink.complete, "Disk shrinking complete.\n"));
retVal = EXIT_SUCCESS;
} else {
- ToolsCmd_PrintErr(SU_(disk.shrink.error,
- "Error while shrinking: %s\n"), result);
+ ToolsCmd_PrintErr(SU_(disk.shrink.error, "Error while shrinking: %s\n"),
+ VM_SAFE_STR(result));
retVal = EX_TEMPFAIL;
}
/*********************************************************
- * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2020 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 "vmware/guestrpc/tclodefs.h"
#include "vmware/guestrpc/timesync.h"
#include "vmware/tools/i18n.h"
+#include "vmware/tools/log.h"
/*
TimeSyncSet(TRUE, &reply, &replyLen)) {
ToolsCmd_Print("%s\n", SU_(option.enabled, "Enabled"));
} else {
- ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), reply);
+ ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"),
+ VM_SAFE_STR(reply));
ret = EXIT_FAILURE;
}
TimeSyncSet(FALSE, &reply, &replyLen)) {
ToolsCmd_Print("%s\n", SU_(option.disabled, "Disabled"));
} else {
- ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), reply);
+ ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"),
+ VM_SAFE_STR(reply));
ret = EXIT_FAILURE;
}