]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix a minor issue reported by Codacy code scanner.
authorOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:40 +0000 (16:12 -0700)
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.

34 files changed:
open-vm-tools/lib/appUtil/appUtil.c
open-vm-tools/lib/file/fileIO.c
open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c
open-vm-tools/lib/guestApp/guestApp.c
open-vm-tools/lib/hgfsServer/hgfsServerOplock.c
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c
open-vm-tools/lib/misc/util_misc.c
open-vm-tools/lib/nicInfo/nicInfo.c
open-vm-tools/lib/procMgr/procMgrPosix.c
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/libvmtools/vmtoolsLog.c
open-vm-tools/namespacetool/namespacetool.c
open-vm-tools/rpctool/rpctool.c
open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c
open-vm-tools/services/plugins/dndcp/dndGuest/rpcV3Util.cpp
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c
open-vm-tools/services/plugins/hgfsServer/hgfsPlugin.c
open-vm-tools/services/plugins/vix/foundryToolsDaemon.c
open-vm-tools/services/plugins/vmbackup/scriptOps.c
open-vm-tools/services/vmtoolsd/cmdLine.c
open-vm-tools/services/vmtoolsd/pluginMgr.c
open-vm-tools/vgauth/cli/main.c
open-vm-tools/vgauth/common/certverify.c
open-vm-tools/vgauth/common/i18n.c
open-vm-tools/vgauth/common/usercheck.c
open-vm-tools/vgauth/lib/proto.c
open-vm-tools/vgauth/service/servicePosix.c
open-vm-tools/vgauth/serviceImpl/alias.c
open-vm-tools/vgauth/serviceImpl/netPosix.c
open-vm-tools/vgauth/serviceImpl/proto.c
open-vm-tools/vgauth/serviceImpl/ticket.c
open-vm-tools/vmhgfs-fuse/dir.c
open-vm-tools/vmhgfs-fuse/file.c
open-vm-tools/vmhgfs-fuse/request.c

index fe49e17e02c39f01ab6f64c61c0234bdb564f818..56ef037e31dfa9ad6c407f72f3c8c1e3a21a3c50 100644 (file)
@@ -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;
index 39f021ec25aba8beb7afdfefee6f18c82d6ace69..9da068ba8aff714e3526d155719a9fafdea00265 100644 (file)
@@ -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)
index b468ad450ac0570ad3a4e93329064be77f856bc3..b0c6200e7dd992aa0b7defc0aa98581c6516e711 100644 (file)
@@ -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;
 
index 1e0234590bf7d964c128dcad22c4f4b1a31fea23..c767d5d1abaabb511c7cfcce10f7d48264dc6697 100644 (file)
@@ -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;
index 378a3c2fce8b8e4c02dff7adbe7cb477bb06e7d4..f5d4b4fcbf6c75a526707f839b2fe75862a2b038 100644 (file)
@@ -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);
 
index 60a67d408d555f9915de82812cf7efed3e94cb42..86c95e4a24746ef4be7b9c61c33aeb6f02c0ac18 100644 (file)
@@ -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);
index de671a07ece1b431cc89ec022a3330c7214f1a57..e4b1bac4cb90e6333b51494c0e0924fe7b0b376d 100644 (file)
@@ -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];
index 694a9a0566ac5b0559f3af30390e163262f47e85..580fbf27579c1650c4a070687988d6b4d5f94094 100644 (file)
@@ -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));
 
index f3e176a15e8f6105f24e22f902ae7fa05a6b6331..c6099d44904c68632afbad721bc1b6d8092c074b 100644 (file)
@@ -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);
 
index 7d1edbde404b6a823f6f937405142a8cd0ee807b..b7c2c083c4deee4de74f2bd7710476163127a2c3 100644 (file)
@@ -398,7 +398,7 @@ exit:
 gboolean
 RpcChannel_Dispatch(RpcInData *data)
 {
-   char *name = NULL;
+   char *name;
    unsigned int index = 0;
    size_t nameLen;
    Bool status;
index 3259d84ca454d001b37a58e275c51ad7b885f59d..82c232286e3bf12a79b4f3d1d05a4ab9fb8cc997 100644 (file)
@@ -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);
    }
index 171e3526724d47a5d8997fe85f58b147757c5a0e..c60976cfba11f7fbf0f73d0c1ab8a8b19012e646 100644 (file)
@@ -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"),
index d7bfd5204c9efd07aa5695836c0f4a031babb7ee..a0e2a77b59d8fda4990013d70023c2d0c7c815f3 100644 (file)
@@ -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 {
index d0ae754f95a5809e4b60e2c0ae1edfc1b4f4c803..cf837002ac86a9c82b82c3b85d47fa938cdf2d7f 100644 (file)
@@ -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');
index 6f95c027aa44680f47db0abca28b20df6cf61826..8cc9c480aff9c419fd4c9cff5f31e5c4e918f592 100644 (file)
@@ -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);
index 5c5ccc35f66184867cf48e240a66cf0a953fb7ff..b5f766c8ffd680e22133b3b138a2e7ec87db209f 100644 (file)
@@ -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;
 
index e04d0adad44e1dacb88434724072929ca1cd44cc..5eefefacbfad57c07b464c09a3bcbe372c3308f3 100644 (file)
@@ -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;
index 6218203651e841e5e38d2f4fd7c604366b323320..dd969a626aadc68c0a2fb8c529d77afaf9d5f9c6 100644 (file)
@@ -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;
index 71059130b100262405ddad20e08ca4edaf78232b..0f24ffa5768026556c742a8c0f4d62dd8ee75de1 100644 (file)
@@ -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;
index 27342d499a5b215e617370ea8c60e7eba9315c64..9e37eafef661cfa85aa6a79c5581d6ba4d24dc2a 100644 (file)
@@ -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");
index 75c86c8f4aa82042828e098d3c273351fde90faf..a7338db9070793ef2802faafa41e1120d3862636 100644 (file)
@@ -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);
 
index 89f06cb484f5f7c369c4a8d9c585e1c4ca239c2a..25fbde7f2a6c59d60ad10ba4fde1fd5967bc180f 100644 (file)
@@ -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);
index db280e919b669c185b5c21088b4a934f17d25d60..2de935fae612f0a4e53c27f7d9275c9ea47afb66 100644 (file)
@@ -439,7 +439,7 @@ CertVerifyX509ToString(X509 *x)
 gchar *
 CertVerify_CertToX509String(const gchar *pemCert)
 {
-   X509 *x = NULL;
+   X509 *x;
    gchar *retVal = NULL;
 
    x = CertStringToX509(pemCert);
index 896b6d4fdb3179c29f1259dfefa39c3b46b3a4d5..6377f335fd1d4c041a299cf3db2506970399c4dd 100644 (file)
@@ -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;
       }
index 185a60778aece3c33c364350f58ce89e6269da8d..31eeb5a7768c97fdf0a742a623bdea0567c0700a 100644 (file)
@@ -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?
index 36bd76f168aa0b6646954ed8a1a3db49deb3fac8..d4d3c4d3645b276904d1bdfd9263b692cfaf3efd 100644 (file)
@@ -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;
 
index fbdc631aad84289f80b3c191552c3a0357b6c1e3..7bb719a195a99de61f24fd324ce38659e35516a8 100644 (file)
@@ -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);
index 5e2c008920cea857361f2e3dbdddfedcf0c8ede1..0ee824469521922d5a4c4d84ad5fb2ced456c858 100644 (file)
@@ -1437,7 +1437,7 @@ AliasLoadAliases(const gchar *userName,
       NULL,
       NULL,
    };
-   GMarkupParseContext *context = NULL;
+   GMarkupParseContext *context;
    gboolean bRet;
    gchar *fileContents = NULL;
    gsize fileSize;
index d4a997c8f6af90eee6512bb4a607d5af163dbbde..3611766e9184b100ae7f0f8ca60c7cc765c912d9 100644 (file)
@@ -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);
 
    /*
index b6e7b3f0348591b0033e829cd945d42e322d41b7..3cef3b55da7071d2876985950ba6b19a1b5a8d64 100644 (file)
@@ -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;
index 27b482d30cd8f19832d461824cad3c5bbfb331db..e275bfbd3fbc86899651fd2275bae76b4949020b 100644 (file)
@@ -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;
index 44fda2e476616bba8f85c45f2125c3cc7bd22449..d5fd1f8b5d8cc5c4d7d6a16ab5218feedfb33a79 100644 (file)
@@ -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;
 
index d6895e3d01af53bb89e5e8f773948ae2b3f7aca5..14b68960d79258f105f0807074767ed8cd2bd4b4 100644 (file)
@@ -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));
 
index 9481ccd86f28ed078a946e247a2af64c430d672a..bba1f444f2184f232261bc9b612cd59a2b89b6aa 100644 (file)
@@ -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;