From: Oliver Kurth Date: Mon, 28 Oct 2019 23:12:40 +0000 (-0700) Subject: Fix a minor issue reported by Codacy code scanner. X-Git-Tag: stable-11.1.0~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4cdf9876993f7a3c9f3bbd33efb6a1446697375;p=thirdparty%2Fopen-vm-tools.git Fix a minor issue reported by Codacy code scanner. One of the code quality checkers (Codacy) reported the following issue for a bunch of files bundled in 'open-vm-tools'. """ Fix 'variable has been re-assigned before it's value has been used' """ Checked all applicable files and removed the variable initialization where it's really not necessary. This is really not a major issue but it's no harm fixing. --- diff --git a/open-vm-tools/lib/appUtil/appUtil.c b/open-vm-tools/lib/appUtil/appUtil.c index fe49e17e0..56ef037e3 100644 --- a/open-vm-tools/lib/appUtil/appUtil.c +++ b/open-vm-tools/lib/appUtil/appUtil.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -53,8 +53,7 @@ AppUtil_SendGuestCaps(const GuestCapabilities *caps, // IN: array of capabilitie 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); @@ -62,6 +61,7 @@ AppUtil_SendGuestCaps(const GuestCapabilities *caps, // IN: array of capabilitie 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; diff --git a/open-vm-tools/lib/file/fileIO.c b/open-vm-tools/lib/file/fileIO.c index 39f021ec2..9da068ba8 100644 --- a/open-vm-tools/lib/file/fileIO.c +++ b/open-vm-tools/lib/file/fileIO.c @@ -695,7 +695,7 @@ FileIOResult FileIO_AtomicTempFile(FileIODescriptor *fileFD, // IN: FileIODescriptor *tempFD) // OUT: { - char *tempPath = NULL; + char *tempPath; int permissions; FileIOResult status; #if !defined(_WIN32) diff --git a/open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c b/open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c index b468ad450..b0c6200e7 100644 --- a/open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c +++ b/open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -108,7 +108,7 @@ Vix_TranslateGuestRegistryError(int systemError) // IN VixError Vix_TranslateSystemError(int systemError) // IN { - VixError err = VIX_E_FAIL; + VixError err; #ifdef _WIN32 char *msg; diff --git a/open-vm-tools/lib/guestApp/guestApp.c b/open-vm-tools/lib/guestApp/guestApp.c index 1e0234590..c767d5d1a 100644 --- a/open-vm-tools/lib/guestApp/guestApp.c +++ b/open-vm-tools/lib/guestApp/guestApp.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -137,7 +137,7 @@ GuestApp_GetInstallPathW(void) 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; diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c index 378a3c2fc..f5d4b4fcb 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -133,7 +133,7 @@ HgfsHandle2ServerLock(HgfsHandle handle, // IN: Hgfs file handle { #ifdef HGFS_OPLOCKS Bool found = FALSE; - HgfsFileNode *fileNode = NULL; + HgfsFileNode *fileNode; ASSERT(lock); diff --git a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c index 60a67d408..86c95e4a2 100644 --- a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c +++ b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -696,7 +696,7 @@ HgfsChannelGuest_Receive(HgfsServerMgrData *mgrData, // IN/OUT : conn manager char *packetOut, // OUT: outgoing packet size_t *packetOutSize) // IN/OUT: outgoing packet size { - HgfsChannelData *channel = NULL; + HgfsChannelData *channel; Bool result = FALSE; ASSERT(NULL != mgrData); @@ -740,7 +740,7 @@ HgfsChannelGuest_Receive(HgfsServerMgrData *mgrData, // IN/OUT : conn manager uint32 HgfsChannelGuest_InvalidateInactiveSessions(HgfsServerMgrData *mgrData) // IN: conn manager { - HgfsChannelData *channel = NULL; + HgfsChannelData *channel; uint32 result = 0; ASSERT(NULL != mgrData); diff --git a/open-vm-tools/lib/misc/util_misc.c b/open-vm-tools/lib/misc/util_misc.c index de671a07e..e4b1bac4c 100644 --- a/open-vm-tools/lib/misc/util_misc.c +++ b/open-vm-tools/lib/misc/util_misc.c @@ -550,7 +550,7 @@ UtilDoTildeSubst(const char *user) // IN: name of user 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]; diff --git a/open-vm-tools/lib/nicInfo/nicInfo.c b/open-vm-tools/lib/nicInfo/nicInfo.c index 694a9a056..580fbf275 100644 --- a/open-vm-tools/lib/nicInfo/nicInfo.c +++ b/open-vm-tools/lib/nicInfo/nicInfo.c @@ -299,7 +299,7 @@ GuestInfo_GetNicInfo(unsigned int maxIPv4Routes, unsigned int maxIPv6Routes, NicInfoV3 **nicInfo) { - Bool retval = FALSE; + Bool retval; *nicInfo = Util_SafeCalloc(1, sizeof (struct NicInfoV3)); diff --git a/open-vm-tools/lib/procMgr/procMgrPosix.c b/open-vm-tools/lib/procMgr/procMgrPosix.c index f3e176a15..c6099d449 100644 --- a/open-vm-tools/lib/procMgr/procMgrPosix.c +++ b/open-vm-tools/lib/procMgr/procMgrPosix.c @@ -270,9 +270,7 @@ ProcMgr_ListProcesses(void) * 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; @@ -1387,7 +1385,7 @@ ProcMgr_ExecSyncWithExitCode(char const *cmd, // IN: UTF-8 comm Bool *validExitCode, // OUT: exit code is valid int *exitCode) // OUT: exit code { - Bool result = FALSE; + Bool result; ASSERT(exitCode != NULL && validExitCode != NULL); diff --git a/open-vm-tools/lib/rpcChannel/rpcChannel.c b/open-vm-tools/lib/rpcChannel/rpcChannel.c index 7d1edbde4..b7c2c083c 100644 --- a/open-vm-tools/lib/rpcChannel/rpcChannel.c +++ b/open-vm-tools/lib/rpcChannel/rpcChannel.c @@ -398,7 +398,7 @@ exit: gboolean RpcChannel_Dispatch(RpcInData *data) { - char *name = NULL; + char *name; unsigned int index = 0; size_t nameLen; Bool status; diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index 3259d84ca..82c232286 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -851,10 +851,9 @@ VMToolsGetLogFilePath(const gchar *key, 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); } diff --git a/open-vm-tools/namespacetool/namespacetool.c b/open-vm-tools/namespacetool/namespacetool.c index 171e35267..c60976cfb 100644 --- a/open-vm-tools/namespacetool/namespacetool.c +++ b/open-vm-tools/namespacetool/namespacetool.c @@ -256,8 +256,7 @@ static Bool 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"), diff --git a/open-vm-tools/rpctool/rpctool.c b/open-vm-tools/rpctool/rpctool.c index d7bfd5204..a0e2a77b5 100644 --- a/open-vm-tools/rpctool/rpctool.c +++ b/open-vm-tools/rpctool/rpctool.c @@ -182,9 +182,8 @@ int 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 { diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c b/open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c index d0ae754f9..cf837002a 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c @@ -422,11 +422,10 @@ CreateStagingDirectory( 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'); diff --git a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp index 6f95c027a..8cc9c480a 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp +++ b/open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -104,7 +104,7 @@ bool RpcV3Util::SendMsg(uint32 cmd) { DnDMsg msg; - bool ret = false; + bool ret; DnDMsg_Init(&msg); DnDMsg_SetCmd(&msg, cmd); diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 5c5ccc35f..b5f766c8f 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -210,8 +210,8 @@ GuestInfoVMSupport(RpcInData *data) #if defined(_WIN32) char vmSupportCmd[] = "vm-support.vbs"; - char *vmSupportPath = NULL; - gchar *vmSupport = NULL; + char *vmSupportPath; + gchar *vmSupport; SECURITY_ATTRIBUTES saProcess = {0}, saThread = {0}; @@ -1035,7 +1035,7 @@ GuestInfoSendData(ToolsAppCtx *ctx, // IN Bool status; gchar *request; u_int msgLength = infoLength; - gchar *message = NULL; + gchar *message; char *reply = NULL; size_t replyLen; diff --git a/open-vm-tools/services/plugins/hgfsServer/hgfsPlugin.c b/open-vm-tools/services/plugins/hgfsServer/hgfsPlugin.c index e04d0adad..5eefefacb 100644 --- a/open-vm-tools/services/plugins/hgfsServer/hgfsPlugin.c +++ b/open-vm-tools/services/plugins/hgfsServer/hgfsPlugin.c @@ -302,7 +302,7 @@ static DWORD HgfsServerClientRedirectorExecOpImpl(HgfsClientRdrServiceOp serviceOp, DWORD accessFlags) { - SC_HANDLE serviceControlManager = NULL; + SC_HANDLE serviceControlManager; PCWSTR serviceName = HGFS_SERVICE_NAME_U; DWORD result = ERROR_SUCCESS; @@ -801,7 +801,7 @@ HgfsServerDestroyClientRdrSA(PSID *everyoneSID, static DWORD HgfsServerClientRdrCreateEvent(LPCWSTR syncEventName) { - DWORD result = ERROR_SUCCESS; + DWORD result; PSID everyoneSID = NULL, adminSID = NULL; PACL accessControlList = NULL; PSECURITY_DESCRIPTOR securityDescriptor = NULL; diff --git a/open-vm-tools/services/plugins/vix/foundryToolsDaemon.c b/open-vm-tools/services/plugins/vix/foundryToolsDaemon.c index 621820365..dd969a626 100644 --- a/open-vm-tools/services/plugins/vix/foundryToolsDaemon.c +++ b/open-vm-tools/services/plugins/vix/foundryToolsDaemon.c @@ -162,7 +162,7 @@ static Bool thisProcessRunsAsRoot = FALSE; gboolean FoundryToolsDaemonRunProgram(RpcInData *data) // IN { - VixError err = VIX_OK; + VixError err; char *requestName = NULL; char *commandLine = NULL; char *commandLineArgs = NULL; @@ -283,7 +283,7 @@ abort: 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; @@ -494,12 +494,13 @@ ToolsDaemonTcloGetEncodedQuotedString(const char *args, // IN 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; } @@ -536,8 +537,8 @@ ToolsDaemonTcloSyncDriverFreeze(RpcInData *data) { 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; diff --git a/open-vm-tools/services/plugins/vmbackup/scriptOps.c b/open-vm-tools/services/plugins/vmbackup/scriptOps.c index 71059130b..0f24ffa57 100644 --- a/open-vm-tools/services/plugins/vmbackup/scriptOps.c +++ b/open-vm-tools/services/plugins/vmbackup/scriptOps.c @@ -436,7 +436,7 @@ VmBackup_NewScriptOp(VmBackupScriptType type, // IN { Bool fail = FALSE; char **fileList = NULL; - char *scriptDir = NULL; + char *scriptDir; int numFiles = 0; size_t i; VmBackupScriptOp *op = NULL; diff --git a/open-vm-tools/services/vmtoolsd/cmdLine.c b/open-vm-tools/services/vmtoolsd/cmdLine.c index 27342d499..9e37eafef 100644 --- a/open-vm-tools/services/vmtoolsd/cmdLine.c +++ b/open-vm-tools/services/vmtoolsd/cmdLine.c @@ -67,9 +67,7 @@ ToolsCoreRunCommand(const gchar *option, #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"); diff --git a/open-vm-tools/services/vmtoolsd/pluginMgr.c b/open-vm-tools/services/vmtoolsd/pluginMgr.c index 75c86c8f4..a7338db90 100644 --- a/open-vm-tools/services/vmtoolsd/pluginMgr.c +++ b/open-vm-tools/services/vmtoolsd/pluginMgr.c @@ -656,7 +656,7 @@ ToolsCore_LoadPlugins(ToolsServiceState *state) #ifdef USE_APPLOADER { - Bool ret = FALSE; + Bool ret; GModule *mainModule = g_module_open(NULL, G_MODULE_BIND_LAZY); ASSERT(mainModule); diff --git a/open-vm-tools/vgauth/cli/main.c b/open-vm-tools/vgauth/cli/main.c index 89f06cb48..25fbde7f2 100644 --- a/open-vm-tools/vgauth/cli/main.c +++ b/open-vm-tools/vgauth/cli/main.c @@ -190,7 +190,7 @@ CliAddAlias(VGAuthContext *ctx, gboolean addMapped, const char *comment) { - gchar *pemCert = NULL; + gchar *pemCert; VGAuthError err; VGAuthAliasInfo ai; @@ -246,7 +246,7 @@ CliRemoveAlias(VGAuthContext *ctx, const char *pemFilename) { VGAuthError err; - gchar *pemCert = NULL; + gchar *pemCert; VGAuthSubject subj; pemCert = CliLoadPemFILE(pemFilename); diff --git a/open-vm-tools/vgauth/common/certverify.c b/open-vm-tools/vgauth/common/certverify.c index db280e919..2de935fae 100644 --- a/open-vm-tools/vgauth/common/certverify.c +++ b/open-vm-tools/vgauth/common/certverify.c @@ -439,7 +439,7 @@ CertVerifyX509ToString(X509 *x) gchar * CertVerify_CertToX509String(const gchar *pemCert) { - X509 *x = NULL; + X509 *x; gchar *retVal = NULL; x = CertStringToX509(pemCert); diff --git a/open-vm-tools/vgauth/common/i18n.c b/open-vm-tools/vgauth/common/i18n.c index 896b6d4fd..6377f335f 100644 --- a/open-vm-tools/vgauth/common/i18n.c +++ b/open-vm-tools/vgauth/common/i18n.c @@ -817,9 +817,7 @@ I18n_GetString(const char *domain, } 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; } diff --git a/open-vm-tools/vgauth/common/usercheck.c b/open-vm-tools/vgauth/common/usercheck.c index 185a60778..31eeb5a77 100644 --- a/open-vm-tools/vgauth/common/usercheck.c +++ b/open-vm-tools/vgauth/common/usercheck.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -215,9 +215,8 @@ UsercheckUserExists(const gchar *userName) { gboolean result = TRUE; #ifdef _WIN32 - PSID pSidUser = NULL; + PSID pSidUser = WinUtil_LookupSid(userName); - pSidUser = WinUtil_LookupSid(userName); if (!pSidUser) { result = FALSE; } else { @@ -404,7 +403,7 @@ Usercheck_IsAdminMember(const gchar *userName) 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? diff --git a/open-vm-tools/vgauth/lib/proto.c b/open-vm-tools/vgauth/lib/proto.c index 36bd76f16..d4d3c4d36 100644 --- a/open-vm-tools/vgauth/lib/proto.c +++ b/open-vm-tools/vgauth/lib/proto.c @@ -1043,9 +1043,7 @@ static GMarkupParser wireParser = { 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; @@ -1200,10 +1198,10 @@ VGAuth_ReadAndParseResponse(VGAuthContext *ctx, 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; @@ -1306,7 +1304,7 @@ VGAuth_SendSessionRequest(VGAuthContext *ctx, const char *userName, char **pipeName) // OUT { - VGAuthError err = VGAUTH_E_OK; + VGAuthError err; gchar *packet; ProtoReply *reply = NULL; diff --git a/open-vm-tools/vgauth/service/servicePosix.c b/open-vm-tools/vgauth/service/servicePosix.c index fbdc631aa..7bb719a19 100644 --- a/open-vm-tools/vgauth/service/servicePosix.c +++ b/open-vm-tools/vgauth/service/servicePosix.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -162,14 +162,13 @@ ServiceResetProcessState(int *keepFds, 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); diff --git a/open-vm-tools/vgauth/serviceImpl/alias.c b/open-vm-tools/vgauth/serviceImpl/alias.c index 5e2c00892..0ee824469 100644 --- a/open-vm-tools/vgauth/serviceImpl/alias.c +++ b/open-vm-tools/vgauth/serviceImpl/alias.c @@ -1437,7 +1437,7 @@ AliasLoadAliases(const gchar *userName, NULL, NULL, }; - GMarkupParseContext *context = NULL; + GMarkupParseContext *context; gboolean bRet; gchar *fileContents = NULL; gsize fileSize; diff --git a/open-vm-tools/vgauth/serviceImpl/netPosix.c b/open-vm-tools/vgauth/serviceImpl/netPosix.c index d4a997c8f..3611766e9 100644 --- a/open-vm-tools/vgauth/serviceImpl/netPosix.c +++ b/open-vm-tools/vgauth/serviceImpl/netPosix.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -52,9 +52,8 @@ gboolean 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); /* diff --git a/open-vm-tools/vgauth/serviceImpl/proto.c b/open-vm-tools/vgauth/serviceImpl/proto.c index b6e7b3f03..3cef3b55d 100644 --- a/open-vm-tools/vgauth/serviceImpl/proto.c +++ b/open-vm-tools/vgauth/serviceImpl/proto.c @@ -953,9 +953,8 @@ static GMarkupParser wireParser = { 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 @@ -2104,7 +2103,7 @@ static VGAuthError ServiceProtoValidateSamlBearerToken(ServiceConnection *conn, ProtoRequest *req) { - VGAuthError err = VGAUTH_E_FAIL; + VGAuthError err; gchar *packet; gchar *sPacket; char *userName = NULL; diff --git a/open-vm-tools/vgauth/serviceImpl/ticket.c b/open-vm-tools/vgauth/serviceImpl/ticket.c index 27b482d30..e275bfbd3 100644 --- a/open-vm-tools/vgauth/serviceImpl/ticket.c +++ b/open-vm-tools/vgauth/serviceImpl/ticket.c @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -438,9 +438,8 @@ ServiceCreateTicketWin(const char *userName, { 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; diff --git a/open-vm-tools/vmhgfs-fuse/dir.c b/open-vm-tools/vmhgfs-fuse/dir.c index 44fda2e47..d5fd1f8b5 100644 --- a/open-vm-tools/vmhgfs-fuse/dir.c +++ b/open-vm-tools/vmhgfs-fuse/dir.c @@ -247,7 +247,7 @@ HgfsReadDirFromReply(uint32 *f_pos, // IN/OUT: Offset 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; diff --git a/open-vm-tools/vmhgfs-fuse/file.c b/open-vm-tools/vmhgfs-fuse/file.c index d6895e3d0..14b68960d 100644 --- a/open-vm-tools/vmhgfs-fuse/file.c +++ b/open-vm-tools/vmhgfs-fuse/file.c @@ -953,7 +953,7 @@ out: int HgfsRename(const char* from, const char* to) { - HgfsReq *req = NULL; + HgfsReq *req; int result = 0; uint32 reqSize; HgfsOp opUsed; @@ -1467,7 +1467,7 @@ HgfsRelease(HgfsHandle handle) //IN:File handle to close HgfsReq *req; HgfsOp opUsed; HgfsStatus replyStatus; - int result = 0; + int result; LOG(6, ("Entry(handle = %u)\n", handle)); diff --git a/open-vm-tools/vmhgfs-fuse/request.c b/open-vm-tools/vmhgfs-fuse/request.c index 9481ccd86..bba1f444f 100644 --- a/open-vm-tools/vmhgfs-fuse/request.c +++ b/open-vm-tools/vmhgfs-fuse/request.c @@ -54,9 +54,7 @@ pthread_mutex_t hgfsIdLock = PTHREAD_MUTEX_INITIALIZER; 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;