/*********************************************************
- * Copyright (C) 2008-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-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
size_t numCaps, // IN: number of capabilities
Bool enabled) // IN: capabilities status
{
- char *capsStr = NULL;
- char *capsTemp = NULL;
+ char *capsStr;
size_t capIdx;
ASSERT(caps);
capsStr = strdup(GUEST_CAP_FEATURES);
for (capIdx = 0; capIdx < numCaps; capIdx++) {
+ char *capsTemp;
if (!capsStr) {
Debug("%s: Not enough memory to create capabilities string\n", __FUNCTION__);
return;
FileIO_AtomicTempFile(FileIODescriptor *fileFD, // IN:
FileIODescriptor *tempFD) // OUT:
{
- char *tempPath = NULL;
+ char *tempPath;
int permissions;
FileIOResult status;
#if !defined(_WIN32)
/*********************************************************
- * Copyright (C) 2003-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-2017,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
VixError
Vix_TranslateSystemError(int systemError) // IN
{
- VixError err = VIX_E_FAIL;
+ VixError err;
#ifdef _WIN32
char *msg;
/*********************************************************
- * Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-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
static LPCWSTR INSTALLPATH_VALUE_NAME = L"InstallPath";
HKEY key = NULL;
- LONG rc = ERROR_SUCCESS;
+ LONG rc;
DWORD cbData = 0;
DWORD temp = 0;
PWCHAR data = NULL;
/*********************************************************
- * Copyright (C) 2012-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2012-2016,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 HGFS_OPLOCKS
Bool found = FALSE;
- HgfsFileNode *fileNode = NULL;
+ HgfsFileNode *fileNode;
ASSERT(lock);
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2017,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
char *packetOut, // OUT: outgoing packet
size_t *packetOutSize) // IN/OUT: outgoing packet size
{
- HgfsChannelData *channel = NULL;
+ HgfsChannelData *channel;
Bool result = FALSE;
ASSERT(NULL != mgrData);
uint32
HgfsChannelGuest_InvalidateInactiveSessions(HgfsServerMgrData *mgrData) // IN: conn manager
{
- HgfsChannelData *channel = NULL;
+ HgfsChannelData *channel;
uint32 result = 0;
ASSERT(NULL != mgrData);
char *
Util_ExpandString(const char *fileName) // IN file path to expand
{
- char *copy = NULL;
+ char *copy;
char *result = NULL;
int nchunk = 0;
char *chunks[UTIL_MAX_PATH_CHUNKS];
unsigned int maxIPv6Routes,
NicInfoV3 **nicInfo)
{
- Bool retval = FALSE;
+ Bool retval;
*nicInfo = Util_SafeCalloc(1, sizeof (struct NicInfoV3));
* with the seconds since epoch that the system booted up.
*/
if (0 == hostStartTime) {
- FILE *uptimeFile = NULL;
-
- uptimeFile = fopen("/proc/uptime", "r");
+ FILE *uptimeFile = fopen("/proc/uptime", "r");
if (NULL != uptimeFile) {
double secondsSinceBoot;
char *realLocale;
Bool *validExitCode, // OUT: exit code is valid
int *exitCode) // OUT: exit code
{
- Bool result = FALSE;
+ Bool result;
ASSERT(exitCode != NULL && validExitCode != NULL);
gboolean
RpcChannel_Dispatch(RpcInData *data)
{
- char *name = NULL;
+ char *name;
unsigned int index = 0;
size_t nameLen;
Bool status;
GKeyFile *cfg)
{
gsize len = 0;
- gchar *path = NULL;
gchar *origPath = NULL;
+ gchar *path = g_key_file_get_string(cfg, LOGGING_GROUP, key, NULL);
- path = g_key_file_get_string(cfg, LOGGING_GROUP, key, NULL);
if (path == NULL) {
return VMToolsDefaultLogFilePath(domain);
}
GetValueFromFile(const char *filePath, char **fileContents, gsize *length)
{
GError *gErr = NULL;
- Bool retVal = FALSE;
- retVal = g_file_get_contents(filePath, fileContents, length, &gErr);
+ Bool retVal = g_file_get_contents(filePath, fileContents, length, &gErr);
if (retVal == FALSE) {
fprintf(stderr, "%s: %s: %s\n", gAppName,
(gErr != NULL ? gErr->message : "Failed while reading file"),
RpcToolCommand(int argc, char *argv[])
{
char *result = NULL;
- Bool status = FALSE;
+ Bool status = RpcOut_sendOne(&result, NULL, "%s", argv[0]);
- status = RpcOut_sendOne(&result, NULL, "%s", argv[0]);
if (!status) {
fprintf(stderr, "%s\n", result ? result : "NULL");
} else {
int i;
for (i = 0; i < 10 && result == NULL; i++) {
- char *realStagingDir = NULL;
char *apparentStagingDir = NULL;
-
// Reminder: mkdtemp updates its arg in-place.
- realStagingDir = Str_SafeAsprintf(NULL, "%sXXXXXX", realRoot);
+ char *realStagingDir = Str_SafeAsprintf(NULL, "%sXXXXXX", realRoot);
+
if (mkdtemp(realStagingDir) != NULL) {
char *randomPart = strrchr(realStagingDir, '/') + 1;
VERIFY(*randomPart != '\0');
/*********************************************************
- * Copyright (C) 2010-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2017,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
RpcV3Util::SendMsg(uint32 cmd)
{
DnDMsg msg;
- bool ret = false;
+ bool ret;
DnDMsg_Init(&msg);
DnDMsg_SetCmd(&msg, cmd);
#if defined(_WIN32)
char vmSupportCmd[] = "vm-support.vbs";
- char *vmSupportPath = NULL;
- gchar *vmSupport = NULL;
+ char *vmSupportPath;
+ gchar *vmSupport;
SECURITY_ATTRIBUTES saProcess = {0}, saThread = {0};
Bool status;
gchar *request;
u_int msgLength = infoLength;
- gchar *message = NULL;
+ gchar *message;
char *reply = NULL;
size_t replyLen;
HgfsServerClientRedirectorExecOpImpl(HgfsClientRdrServiceOp serviceOp,
DWORD accessFlags)
{
- SC_HANDLE serviceControlManager = NULL;
+ SC_HANDLE serviceControlManager;
PCWSTR serviceName = HGFS_SERVICE_NAME_U;
DWORD result = ERROR_SUCCESS;
static DWORD
HgfsServerClientRdrCreateEvent(LPCWSTR syncEventName)
{
- DWORD result = ERROR_SUCCESS;
+ DWORD result;
PSID everyoneSID = NULL, adminSID = NULL;
PACL accessControlList = NULL;
PSECURITY_DESCRIPTOR securityDescriptor = NULL;
gboolean
FoundryToolsDaemonRunProgram(RpcInData *data) // IN
{
- VixError err = VIX_OK;
+ VixError err;
char *requestName = NULL;
char *commandLine = NULL;
char *commandLineArgs = NULL;
gboolean
FoundryToolsDaemonGetToolsProperties(RpcInData *data) // IN
{
- VixError err = VIX_OK;
+ VixError err;
int additionalError = 0;
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
char *serializedBuffer = NULL;
const char **endOfArg, // OUT
char **result) // OUT
{
- VixError err = VIX_OK;
+ VixError err;
char *rawResultStr = NULL;
char *resultStr = NULL;
rawResultStr = ToolsDaemonTcloGetQuotedString(args, endOfArg);
if (NULL == rawResultStr) {
+ err = VIX_OK;
goto abort;
}
{
static char resultBuffer[DEFAULT_RESULT_MSG_MAX_LENGTH];
VixError err = VIX_OK;
- char *driveList = NULL;
- char *timeout = NULL;
+ char *driveList;
+ char *timeout;
int timeoutVal;
DECLARE_SYNCDRIVER_ERROR(sysError);
ToolsAppCtx *ctx = data->appCtx;
{
Bool fail = FALSE;
char **fileList = NULL;
- char *scriptDir = NULL;
+ char *scriptDir;
int numFiles = 0;
size_t i;
VmBackupScriptOp *op = NULL;
#endif
if (VmCheck_IsVirtualWorld()) {
char *result = NULL;
- Bool status = FALSE;
-
- status = RpcChannel_SendOne(&result, NULL, "%s", value);
+ Bool status = RpcChannel_SendOne(&result, NULL, "%s", value);
if (!status) {
g_printerr("%s\n", result ? result : "NULL");
#ifdef USE_APPLOADER
{
- Bool ret = FALSE;
+ Bool ret;
GModule *mainModule = g_module_open(NULL, G_MODULE_BIND_LAZY);
ASSERT(mainModule);
gboolean addMapped,
const char *comment)
{
- gchar *pemCert = NULL;
+ gchar *pemCert;
VGAuthError err;
VGAuthAliasInfo ai;
const char *pemFilename)
{
VGAuthError err;
- gchar *pemCert = NULL;
+ gchar *pemCert;
VGAuthSubject subj;
pemCert = CliLoadPemFILE(pemFilename);
gchar *
CertVerify_CertToX509String(const gchar *pemCert)
{
- X509 *x = NULL;
+ X509 *x;
gchar *retVal = NULL;
x = CertStringToX509(pemCert);
}
if (source != NULL) {
- const void *retval = NULL;
-
- retval = g_hash_table_lookup(source, idBuf);
+ const void *retval = g_hash_table_lookup(source, idBuf);
if (NULL != retval) {
strp = retval;
}
/*********************************************************
- * Copyright (C) 2011-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2016,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
{
gboolean result = TRUE;
#ifdef _WIN32
- PSID pSidUser = NULL;
+ PSID pSidUser = WinUtil_LookupSid(userName);
- pSidUser = WinUtil_LookupSid(userName);
if (!pSidUser) {
result = FALSE;
} else {
DWORD accountChar2Needed = 0;
DWORD domainChar2Needed = 0;
SID_NAME_USE eUse;
- PSID pSid = NULL;
+ PSID pSid;
/*
* XXX Should this cache some (all?) of the returned data for a perf boost?
ProtoReply *
Proto_NewReply(ProtoReplyType expectedReplyType)
{
- ProtoReply *reply = NULL;
-
- reply = g_malloc0(sizeof(ProtoReply));
+ ProtoReply *reply = g_malloc0(sizeof(ProtoReply));
reply->parseState = PARSE_STATE_NONE;
reply->complete = FALSE;
reply->errorCode = VGAUTH_E_OK;
ProtoReply **wireReply)
{
VGAuthError err = VGAUTH_E_OK;
- GMarkupParseContext *parseContext = NULL;
+ GMarkupParseContext *parseContext;
gsize len;
gchar *rawReply = NULL;
- ProtoReply *reply = NULL;
+ ProtoReply *reply;
gboolean bRet;
GError *gErr = NULL;
const char *userName,
char **pipeName) // OUT
{
- VGAuthError err = VGAUTH_E_OK;
+ VGAuthError err;
gchar *packet;
ProtoReply *reply = NULL;
/*********************************************************
- * Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2017,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
gboolean
ServiceSuicide(const char *pidPath)
{
- FILE *pidPathFp = NULL;
char pidBuf[32];
int pid;
int ret;
int errCode;
gboolean bRet = FALSE;
+ FILE *pidPathFp = g_fopen(pidPath, "r");
- pidPathFp = g_fopen(pidPath, "r");
if (NULL == pidPathFp) {
Warning("%s: failed to open pid file '%s', error %u\n",
__FUNCTION__, pidPath, errno);
NULL,
NULL,
};
- GMarkupParseContext *context = NULL;
+ GMarkupParseContext *context;
gboolean bRet;
gchar *fileContents = NULL;
gsize fileSize;
/*********************************************************
- * Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2017,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
ServiceNetworkCreateSocketDir(void)
{
gboolean bRet = TRUE;
- char *socketDir = NULL;
+ char *socketDir = g_path_get_dirname(SERVICE_PUBLIC_PIPE_NAME);
- socketDir = g_path_get_dirname(SERVICE_PUBLIC_PIPE_NAME);
ASSERT(socketDir != NULL);
/*
ProtoRequest *
Proto_NewRequest(void)
{
- ProtoRequest *req = NULL;
+ ProtoRequest *req = g_malloc0(sizeof(ProtoRequest));
- req = g_malloc0(sizeof(ProtoRequest));
req->parseState = PARSE_STATE_NONE;
req->complete = FALSE;
#if VGAUTH_PROTO_TRACE
ServiceProtoValidateSamlBearerToken(ServiceConnection *conn,
ProtoRequest *req)
{
- VGAuthError err = VGAUTH_E_FAIL;
+ VGAuthError err;
gchar *packet;
gchar *sPacket;
char *userName = NULL;
/*********************************************************
- * Copyright (C) 2011-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2016,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
{
VGAuthError retCode = VGAUTH_E_FAIL;
TicketInfo *newInfo = NULL;
- HANDLE copyHandle = NULL;
+ HANDLE copyHandle = ServiceDupHandleFrom(clientProcHandle, token);
- copyHandle = ServiceDupHandleFrom(clientProcHandle, token);
if (!copyHandle) {
VGAUTH_LOG_WARNING("ServiceDupHandleFrom() failed, user = %s", userName);
goto done;
uint32 replyCount;
HgfsAttrInfo attr;
HgfsDirEntry *hgfsDirent = NULL; /* Only for V3. */
- char *escName = NULL; /* Buffer for escaped version of name */
+ char *escName; /* Buffer for escaped version of name */
size_t escNameLength = NAME_MAX + 1;
int result = 0;
int
HgfsRename(const char* from, const char* to)
{
- HgfsReq *req = NULL;
+ HgfsReq *req;
int result = 0;
uint32 reqSize;
HgfsOp opUsed;
HgfsReq *req;
HgfsOp opUsed;
HgfsStatus replyStatus;
- int result = 0;
+ int result;
LOG(6, ("Entry(handle = %u)\n", handle));
HgfsReq *
HgfsGetNewRequest(void)
{
- HgfsReq *req = NULL;
-
- req = (HgfsReq*)malloc(sizeof(HgfsReq));
+ HgfsReq *req = (HgfsReq*) malloc(sizeof(HgfsReq));
if (req == NULL) {
LOG(4, ("Can't allocate memory.\n"));
return NULL;