]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix 'variable scope can be reduced' warnings.
authorOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:42 +0000 (16:12 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 28 Oct 2019 23:12:42 +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 'The scope of the variable 'var' can be reduced.'
"""

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.

51 files changed:
open-vm-tools/hgfsclient/hgfsclient.c
open-vm-tools/lib/appUtil/appUtilX11.c
open-vm-tools/lib/asyncsocket/asyncSocketInterface.c
open-vm-tools/lib/dataMap/dataMap.c
open-vm-tools/lib/file/fileIO.c
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/file/fileLockPrimitive.c
open-vm-tools/lib/file/fileStandAlone.c
open-vm-tools/lib/file/fileTempPosix.c
open-vm-tools/lib/foundryMsg/foundryMsg.c
open-vm-tools/lib/glibUtils/fileLogger.c
open-vm-tools/lib/hgfs/hgfsEscape.c
open-vm-tools/lib/lock/ulExcl.c
open-vm-tools/lib/misc/codesetOld.c
open-vm-tools/lib/misc/hostinfoPosix.c
open-vm-tools/lib/misc/machineID.c
open-vm-tools/lib/misc/strutil.c
open-vm-tools/lib/misc/util_misc.c
open-vm-tools/lib/nicInfo/nicInfoPosix.c
open-vm-tools/lib/rpcChannel/simpleSocket.c
open-vm-tools/lib/rpcIn/rpcin.c
open-vm-tools/lib/unicode/unicodeSimpleTypes.c
open-vm-tools/lib/user/util.c
open-vm-tools/libDeployPkg/linuxDeployment.c
open-vm-tools/libDeployPkg/processPosix.c
open-vm-tools/modules/solaris/vmxnet/vmxnet.c
open-vm-tools/modules/solaris/vmxnet3/vmxnet3_main.c
open-vm-tools/modules/solaris/vmxnet3/vmxnet3_rx.c
open-vm-tools/namespacetool/namespacetool.c
open-vm-tools/services/plugins/deployPkg/deployPkg.c
open-vm-tools/services/plugins/dndcp/copyPasteCompatX11.c
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
open-vm-tools/services/plugins/dndcp/dnd/dndMsg.c
open-vm-tools/services/plugins/dndcp/dnd/dndXdg.c
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp
open-vm-tools/services/plugins/dndcp/pointer.cpp
open-vm-tools/services/plugins/dndcp/vmCopyPasteDnDWrapper.cpp
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c
open-vm-tools/services/plugins/resolutionSet/resolutionRandR12.c
open-vm-tools/services/plugins/resolutionSet/resolutionX11.c
open-vm-tools/services/plugins/vmbackup/scriptOps.c
open-vm-tools/services/vmtoolsd/toolsRpc.c
open-vm-tools/tests/testVmblock/manual-blocker.c
open-vm-tools/vgauth/service/fileLogger.c
open-vm-tools/vgauth/service/gio.c
open-vm-tools/vgauth/serviceImpl/alias.c
open-vm-tools/vgauth/serviceImpl/proto.c
open-vm-tools/vgauth/serviceImpl/verify.c
open-vm-tools/vmblock-fuse/fsops.c
open-vm-tools/vmhgfs-fuse/cache.c
open-vm-tools/vmhgfs-fuse/file.c

index 8ba516c20e886b8871d085ac37873bb517fc363c..12b668253fd4dc8f33fbe5f4b505fbdcebeb616b 100644 (file)
@@ -259,32 +259,32 @@ HgfsClient_PrintShares(void)
    int offset = 0;
    char escapedName[PATH_MAX + 1];
    HgfsHandle rootHandle;
-   HgfsFileName *fileName;
 
    if (!HgfsClient_Open(&rootHandle)) {
       return success;
    }
 
    while (TRUE) {
-      fileName = HgfsClient_Read(rootHandle, offset++);
+      HgfsFileName *fileName = HgfsClient_Read(rootHandle, offset++);
+
       if (fileName == NULL) {
          break;
       }
-  
+
       /* Are we done? */
       if (fileName->length == 0) {
          success = TRUE;
          break;
       }
 
-      /* 
+      /*
        * Escape this filename. If we get back a negative result, it means that
        * the escaped filename is too big, so skip this share.
        */
       if (HgfsEscape_Do(fileName->name, fileName->length,
                            sizeof escapedName, escapedName) < 0) {
-         continue;
-      } 
+        continue;
+      }
 
       /* Skip "." and ".." which can be returned. */
       if (strcmp(".", escapedName) == 0 ||
@@ -294,7 +294,7 @@ HgfsClient_PrintShares(void)
       printf("%s\n", escapedName);
 
    }
-   
+
    if (!HgfsClient_Close(rootHandle)) {
       success = FALSE;
    }
index bdc5a1a6a7c625aad7035f4c1ffbbec167030abf..1e2c94031488b3ce571e95f901c9bb74826a5240 100644 (file)
@@ -489,10 +489,6 @@ AppUtil_CollectIconArray(const char *iconName,        // IN
             GdkPixbuf *pixbuf;
             int width;
             int height;
-            int x;
-            int y;
-            int rowstride;
-            guchar *pixels;
 
             ASSERT((nitems - i) >= 2);
             width = value[i];
@@ -500,8 +496,10 @@ AppUtil_CollectIconArray(const char *iconName,        // IN
             i += 2;
             pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
             if (pixbuf) {
-               pixels = gdk_pixbuf_get_pixels(pixbuf);
-               rowstride = gdk_pixbuf_get_rowstride(pixbuf);
+               int x;
+               int y;
+               int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
+               guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
 
                for (y = 0; y < height; y++) {
                   for (x = 0; x < width && i < nitems; x++, i++) {
index dd270a381a61800189c70903b76b9b6ac81fe172..587e89f6b7e9af354d6876770e0e25fd0b553df6 100644 (file)
@@ -1733,9 +1733,11 @@ AsyncSocket_WaitForReadMultiple(AsyncSocket **asock,  // IN
                                 int timeoutMS,        // IN
                                 int *outIdx)          // OUT
 {
-   int i;
    int ret;
+
    if (numSock > 0 && VALID(asock[0], waitForReadMultiple)) {
+      int i;
+
       for (i = 0; i < numSock; i++) {
          AsyncSocketLock(asock[i]);
       }
index 067cfe05e5b3928b5835672cb10d33c1a04fb007..dd1fce96f9992cdc250a435adb15b8fa9d2c0a3d 100644 (file)
@@ -2453,7 +2453,6 @@ DataMap_ToString(const DataMap *that,               // IN
 {
    ClientData clientData;
    char *buffPtr;
-   const char *truncStr = " DATA TRUNCATED!!!\n";
 
    /* This API is for debugging only, so we use hard coded buffer size */
    const int32 maxBuffSize = 10 * 1024;
@@ -2496,6 +2495,8 @@ DataMap_ToString(const DataMap *that,               // IN
    ASSERT(buffPtr + maxBuffSize >= clientData.buffer);
 
    if (clientData.result == DMERR_BUFFER_TOO_SMALL) {
+      const char truncStr[] = " DATA TRUNCATED!!!\n";
+
       ASSERT(maxBuffSize > strlen(truncStr));
       Str_Strcpy(buffPtr + maxBuffSize - strlen(truncStr) - 1, truncStr,
                 strlen(truncStr) + 1);
index 9da068ba8aff714e3526d155719a9fafdea00265..677e7944b4843b5b033e318111a702d50e224770 100644 (file)
@@ -836,8 +836,6 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
    uint32 newAccess;
    FileIOResult status;
    FileIODescriptor tmpFD;
-#else
-   int fd;
 #endif
    int savedErrno = 0;
    int ret = 0;
@@ -909,6 +907,8 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
        */
       if (savedErrno == ENOSYS || savedErrno == ENOTTY) {
          if (renameOnNFS) {
+            int fd;
+
             /*
              * NFS allows renames of locked files, even if both files
              * are locked.  The file lock follows the file handle, not
@@ -1015,6 +1015,8 @@ swapdone:
           __FUNCTION__, newPath, currPath, errno);
           savedErrno = errno;
    } else {
+      int fd;
+
       ret = TRUE;
       fd = newFD->posix;
       newFD->posix = currFD->posix;
index b79560e62ba63f3e92b7327c209679968c6f9421..e92f34cf24aa289bb55fa1d8e5b8822fe073ec63 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
@@ -536,7 +536,6 @@ ProxyReceiveResults(int sock_fd,      // IN:
    int err;
    struct iovec iov;
    struct msghdr msg;
-   struct cmsghdr *cmsg;
    uint8_t cmsgBuf[CMSG_SPACE(sizeof(int))];
 
    iov.iov_base = recv_errno;
@@ -561,7 +560,7 @@ ProxyReceiveResults(int sock_fd,      // IN:
    if (msg.msg_controllen == 0) {
       *recv_fd = -1;
    } else {
-      cmsg = CMSG_FIRSTHDR(&msg);
+      struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
 
       if ((cmsg->cmsg_level == SOL_SOCKET) &&
           (cmsg->cmsg_type == SCM_RIGHTS)) {
index 2ade15c9b1b49f4cff0ee64f6427962ce068629f..9f0bdea074b97df569f3f74c08d1abb071eff197 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2018 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
@@ -755,7 +755,6 @@ FileLockScanDirectory(const char *lockDir,      // IN:
       LockValues *ptr;
       Bool       myLockFile;
       LockValues memberValues;
-      char       buffer[FILELOCK_DATA_SIZE];
 
       if ((fileList[i] == NULL) ||
           (*fileList[i] == 'E')) {
@@ -769,6 +768,8 @@ FileLockScanDirectory(const char *lockDir,      // IN:
          /* It's me! No need to read or validate anything. */
          ptr = myValues;
       } else {
+         char       buffer[FILELOCK_DATA_SIZE];
+
          /* It's not me! Attempt to extract the member values. */
          err = FileLockMemberValues(lockDir, fileList[i], buffer,
                                     FILELOCK_DATA_SIZE, &memberValues);
index df264124647c0ee44917432e6c34bdbc3d05248c..6d3cba21ac9f92f81a9a3b5fa7f95fecba9591be 100644 (file)
@@ -543,7 +543,6 @@ File_MapPathPrefix(const char *oldPath,       // IN:
    size_t oldPathLen = strlen(oldPath);
 
    for (i = 0; i < numPrefixes; i++) {
-      char *newPath;
       char *oldPrefix;
       char *newPrefix;
       size_t oldPrefixLen;
@@ -576,6 +575,7 @@ File_MapPathPrefix(const char *oldPath,       // IN:
               (oldPath[oldPrefixLen] == '\0'))) {
          size_t newPrefixLen = strlen(newPrefix);
          size_t newPathLen = (oldPathLen - oldPrefixLen) + newPrefixLen;
+         char *newPath;
 
          ASSERT(newPathLen > 0);
          ASSERT(oldPathLen >= oldPrefixLen);
index 2bd591319431535c3aaca194c053f2f9330a1f11..097d1d499d28d2f22b008fd19f07df531e0977f5 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-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 char *
 FileTryDir(const char *dirName)  // IN: Is this a writable directory?
 {
-   char *edirName;
-
    if (dirName != NULL) {
-      edirName = Util_ExpandString(dirName);
+      char *edirName = Util_ExpandString(dirName);
 
       if ((edirName != NULL) && FileIsWritableDir(edirName)) {
          return edirName;
index 7704e44818bf388c58e5915ad6481ea5b9e6ce78..99d811a6b80af60ae64bf1adcc1ec2e8a9d0a77c 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004-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
@@ -20,8 +20,8 @@
  * foundryMsg.c --
  *
  * This is a library for formatting and parsing the messages sent
- * between a foundry client and the VMX. It is a stand-alone library 
- * so it can be used by the VMX tree without also linking in the 
+ * between a foundry client and the VMX. It is a stand-alone library
+ * so it can be used by the VMX tree without also linking in the
  * entire foundry client-side library.
  */
 
@@ -631,7 +631,6 @@ VixMsg_AllocRequestMsg(size_t msgHeaderAndBodyLength,    // IN
    VixCommandRequestHeader *commandRequest = NULL;
    size_t providedCredentialLength = 0;
    size_t totalCredentialLength = 0;
-   char *destPtr;
 
    if ((VIX_USER_CREDENTIAL_NAME_PASSWORD == credentialType)
       || (VIX_USER_CREDENTIAL_HOST_CONFIG_SECRET == credentialType)
@@ -692,7 +691,8 @@ VixMsg_AllocRequestMsg(size_t msgHeaderAndBodyLength,    // IN
          || (VIX_USER_CREDENTIAL_TICKETED_SESSION == credentialType)
          || (VIX_USER_CREDENTIAL_SSPI == credentialType)
          || (VIX_USER_CREDENTIAL_SAML_BEARER_TOKEN == credentialType)) {
-      destPtr = (char *) commandRequest;
+      char *destPtr = (char *) commandRequest;
+
       destPtr += commandRequest->commonHeader.headerLength;
       destPtr += commandRequest->commonHeader.bodyLength;
       if (NULL != credential) {
index 4940928b8a204b5a949f3da6376b314a032bf85d..ace171d1ecf06832a9ad8d4793f3959a8d3f4f03 100644 (file)
@@ -258,7 +258,6 @@ FileLoggerOpen(FileLogger *data)
           * will always be index "0"). When not rotating, "maxFiles" is 1, so we
           * always keep one backup.
           */
-         gchar *log;
          guint id;
          GPtrArray *logfiles = g_ptr_array_new();
 
@@ -268,7 +267,8 @@ FileLoggerOpen(FileLogger *data)
           * file, which may or may not exist.
           */
          for (id = 0; id < data->maxFiles; id++) {
-            log = FileLoggerGetPath(data, id);
+            gchar *log = FileLoggerGetPath(data, id);
+
             g_ptr_array_add(logfiles, log);
             if (!g_file_test(log, G_FILE_TEST_IS_REGULAR)) {
                break;
index 5166d799c8a916cae733c31e8f2b9891317c76ab..7921b08bcffd8c0a4c2707c2a3600785e0412af5 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
@@ -875,7 +875,6 @@ HgfsEscapeUndoComponent(char   *bufIn,             // IN: Characters to be unesc
                         uint32 *unprocessedLength) // IN: Unprocessed characters
                                                    //     in the whole name
 {
-   size_t offset;
    size_t sizeIn;
    char* curOutBuffer;
    char* escapePointer;
@@ -886,7 +885,8 @@ HgfsEscapeUndoComponent(char   *bufIn,             // IN: Characters to be unesc
    sizeIn = strlen(curOutBuffer);
    escapePointer = strchr(curOutBuffer, HGFS_ESCAPE_CHAR);
    while (escapePointer != NULL) {
-      offset = escapePointer - bufIn;
+      size_t offset = escapePointer - bufIn;
+
       if (HgfsIsEscapeSequence(bufIn, offset, sizeIn)) {
          char* substitute = strchr(HGFS_SUBSTITUTE_CHARS, bufIn[offset - 1]);
          if (substitute != NULL) {
index 27d16346aaaa96a8d01083544f4efe219852df72..a0ad1c923e88cd751130969a2d997c52bd42c73f 100644 (file)
@@ -451,7 +451,6 @@ MXUser_AcquireExclLock(MXUserExclLock *lock)  // IN/OUT:
 
    if (vmx86_stats) {
       VmTimeType value = 0;
-      MXUserHeldStats *heldStats;
       MXUserAcquireStats *acquireStats;
 
       acquireStats = Atomic_ReadPtr(&lock->acquireStatsMem);
@@ -461,6 +460,7 @@ MXUser_AcquireExclLock(MXUserExclLock *lock)  // IN/OUT:
 
       if (LIKELY(acquireStats != NULL)) {
          MXUserHisto *histo;
+         MXUserHeldStats *heldStats;
 
          MXUserAcquisitionSample(&acquireStats->data, TRUE,
                             value > acquireStats->data.contentionDurationFloor,
index efd5aee02046070c78f65da6c9be800eafa1a587..7d5474c01e02d95f0e224dc0015fa7ebd45c08b8 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-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
@@ -758,11 +758,13 @@ CodeSetOld_GetCurrentCodeSet(void)
 
    if (!cachedCodeset) {
       char *gFilenameEncoding = getenv("G_FILENAME_ENCODING");
-      char *p;
 
       if (gFilenameEncoding && *gFilenameEncoding) {
+         char *p;
+
          gFilenameEncoding = Util_SafeStrdup(gFilenameEncoding);
          p = strchr(gFilenameEncoding, ',');
+
          if (p) {
             *p = '\0';
          }
index e7ae9d25756e041c5af545f40efc1d00355c3340..3baee94f43f1fcc92d72d5773a75b17ca7602f94 100644 (file)
@@ -2962,10 +2962,11 @@ HostinfoGetCpuInfo(int nCpu,    // IN:
    while (cpu <= nCpu &&
           StdIO_ReadNextLine(f, &line, 0, NULL) == StdIO_Success) {
       char *s;
-      char *e;
 
       if ((s = strstr(line, name)) &&
           (s = strchr(s, ':'))) {
+         char *e;
+
          s++;
          e = s + strlen(s);
 
index 5f1ba786a12cf0ecb4776f47d727169823daec5f..92efa03e932c15bf0107916ee274b2d056ab0eef 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-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
@@ -322,7 +322,6 @@ static int
 ObtainHardwareID(uint64 *hardwareID)  // OUT:
 {
    uint32 i;
-   struct ifaddrs *p;
    struct ifaddrs *ifp;
 
    // Attempt to get the list of networking interfaces
@@ -337,7 +336,7 @@ ObtainHardwareID(uint64 *hardwareID)  // OUT:
 
    // search through a "reasonable" number of interfaces
    for (i = 0, *hardwareID = 0; i < 8; i++) {
-      p = CheckEthernet(ifp, i);
+      struct ifaddrs *p = CheckEthernet(ifp, i);
 
       if (p != NULL) {
          memcpy(hardwareID, LLADDR((struct sockaddr_dl *)p->ifa_addr), ETHER_ADDR_LEN);
index 70737bd1a8f7ed34aa321bce23880e27571fa4a0..5ce64ac354d6ae8cb8db579a3c7a8eed1b4d04b7 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
@@ -1341,7 +1341,6 @@ StrUtil_ReplaceAll(const char *orig, // IN
     char *tmp;
     size_t lenWhat;
     size_t lenWith;
-    size_t lenBefore;
     size_t occurrences = 0;
     size_t lenNew;
 
@@ -1363,6 +1362,8 @@ StrUtil_ReplaceAll(const char *orig, // IN
     result = tmp;
 
     while (occurrences--) {
+       size_t lenBefore;
+
        current = strstr(orig, what);
        lenBefore = current - orig;
        tmp = memcpy(tmp, orig, lenBefore);
index e4b1bac4cb90e6333b51494c0e0924fe7b0b376d..8fbedc62b9104d9a27c74013332a304932aefbdc 100644 (file)
@@ -211,13 +211,14 @@ UtilGetLegacyEncodedString(const char *path)  // IN: UTF-8
 
    if (cpath != NULL) {
       char *apath = NULL;
-      int retlen;
       WCHAR *wcpath = Unicode_GetAllocUTF16(cpath);
 
       /* First get the length of multibyte string */
       int alen = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, wcpath, -1,
                                      NULL, 0, NULL, NULL);
       if (alen > 0) {
+         int retlen;
+
          /* Now get the converted string */
          ret = Util_SafeMalloc(alen);
          retlen = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, wcpath, -1,
index e661993b387bcb402f7358c5a66cfd6ff4a51133..6e1f4d8f9da1d83bb4af512abc3156ab88cb4aef 100644 (file)
@@ -303,8 +303,6 @@ GuestInfoGetInterface(struct ifaddrs *ifaddrs,
     * records are intermingled with AF_INET and AF_INET6 records.
     */
    for (pkt = ifaddrs; pkt != NULL; pkt = pkt->ifa_next) {
-      GuestNicV3 *nic;
-      struct ifaddrs *ip;
       struct sockaddr_ll *sll = (struct sockaddr_ll *)pkt->ifa_addr;
 
       if (GuestInfo_IfaceGetPriority(pkt->ifa_name) != priority ||
@@ -314,6 +312,8 @@ GuestInfoGetInterface(struct ifaddrs *ifaddrs,
 
       if (sll != NULL && sll->sll_family == AF_PACKET) {
          char macAddress[NICINFO_MAC_LEN];
+         GuestNicV3 *nic;
+         struct ifaddrs *ip;
 
          /*
           * PR 2193804:
@@ -672,8 +672,6 @@ ReadInterfaceDetails(const struct intf_entry *entry, // IN
 
    if (entry->intf_type == INTF_TYPE_ETH &&
        entry->intf_link_addr.addr_type == ADDR_TYPE_ETH) {
-      GuestNicV3 *nic = NULL;
-      char macAddress[NICINFO_MAC_LEN];
 
       /*
        * There is a race where the guest info plugin might be iterating over the
@@ -683,6 +681,9 @@ ReadInterfaceDetails(const struct intf_entry *entry, // IN
        * pick up any changes.
        */
       if (entry->intf_link_addr.addr_type == ADDR_TYPE_ETH) {
+         char macAddress[NICINFO_MAC_LEN];
+         GuestNicV3 *nic = NULL;
+
          Str_Sprintf(macAddress, sizeof macAddress, "%s",
                      addr_ntoa(&entry->intf_link_addr));
 
index 4634137309a8de3e5b5e1459d683553194ee3d50..9af19ea9741356692d7a85ef61bdce769908f8af 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2013-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013-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
@@ -173,11 +173,10 @@ Socket_Recv(SOCKET fd,      // IN
             int len)        // IN
 {
    int remaining = len;
-   int rv;
    int sysErr;
 
    while (remaining > 0) {
-      rv = recv(fd, buf , remaining, 0);
+      int rv = recv(fd, buf , remaining, 0);
       if (rv == 0) {
          Debug(LGPFX "Socket %d closed by peer.", fd);
          return FALSE;
index 47a3380e4216480f088a854692069af24819e650..094cd228c887d8e52a235deb78cb5cd6506c0ea0 100644 (file)
@@ -1071,7 +1071,6 @@ RpcInConnErrorHandler(int err,             // IN
                       void *clientData)    // IN
 {
    ConnInfo *conn = (ConnInfo *)clientData;
-   char const *errmsg ="RpcIn: vsocket connection error";
    RpcIn *in = conn->in;
 
    Debug("RpcIn: Error in socket %d, closing connection: %s.\n",
@@ -1080,7 +1079,7 @@ RpcInConnErrorHandler(int err,             // IN
    in->errStatus = TRUE;
 
    if (conn->connected) {
-      RpcInCloseChannel(conn->in, errmsg);
+      RpcInCloseChannel(conn->in, "RpcIn: vsocket connection error");
    } else { /* the connection never gets connected */
       RpcInCloseConn(conn);
       Debug("RpcIn: falling back to use backdoor ...\n");
index eb157fba55ca14bf90f3c5e23b3a6c94eb61fc0d..5ace167e2fa371235fe6863fb6b99e3f69e5487c 100644 (file)
@@ -2980,14 +2980,14 @@ void
 UnicodeICUTest(void)
 {
    StringEncoding enc, enc2;
-   const char *name;
    Bool supported;
    Bool redirected;
    Bool canGetBytes;
 
    for (enc = STRING_ENCODING_FIRST; enc < STRING_ENCODING_MAX_SPECIFIED;
         enc++ ) {
-      name =  Unicode_EncodingEnumToName(enc);
+      const char *name =  Unicode_EncodingEnumToName(enc);
+
       enc2 = Unicode_EncodingNameToEnum(name);
       redirected = FALSE;
       if (enc2 == STRING_ENCODING_UNKNOWN) {
index e89d13475b982c1de7e6d189aa79a620d1ac200d..23376f452ae05fc652b1a247f0829cd19b521423 100644 (file)
@@ -205,13 +205,12 @@ Util_Checksumv(void *iov,      // IN
 {
    uint32 checksum = 0;
    struct UtilVector *vector = (struct UtilVector *) iov;
-   uint32 partialChecksum;
    int bytesSoFar = 0;
-   int rotate;
 
    while (numEntries-- > 0) {
-      partialChecksum = Util_Checksum(vector->base, vector->len);
-      rotate = (bytesSoFar & 3) * 8;
+      uint32 partialChecksum = Util_Checksum(vector->base, vector->len);
+      int rotate = (bytesSoFar & 3) * 8;
+
       checksum ^= ((partialChecksum << rotate) |
                    (partialChecksum >> (32 - rotate)));
       bytesSoFar += vector->len;
index 7615c9f8faf7dc91acb76e63a12a49510213a1a7..97a69cfd74a010c71e9513bc6bf736b72682aa0d 100644 (file)
@@ -1219,7 +1219,6 @@ Deploy(const char* packageName)
    char* pkgCommand = NULL;
    char* command = NULL;
    int deploymentResult = 0;
-   char *nics;
    char* cleanupCommand;
    uint8 archiveType;
    uint8 flags;
@@ -1348,7 +1347,8 @@ Deploy(const char* packageName)
          sLog(log_error, "Deployment failed."
                          "The forked off process returned error code.\n");
       } else {
-         nics = GetNicsToEnable(imcDirPath);
+         char *nics = GetNicsToEnable(imcDirPath);
+
          if (nics) {
             // XXX: Sleep before the last SetCustomizationStatusInVmx
             //      This is a temporary-hack for PR 422790
index b81ec80edbccf3517985ee36be92db095d1351b4..340b05b0174eb77ee11644f6f724393bf471bc28 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-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
@@ -259,7 +259,6 @@ ProcessRead(ProcessInternal *p, ReadStatus *status, Bool stdout, Bool readToEof)
 {
    char buf[1024];
    size_t currSize, newSize;
-   ssize_t count;
    char** saveTo;
    int fd;
    char* stdstr = stdout ? "stdout" : "stderr";
@@ -270,7 +269,8 @@ ProcessRead(ProcessInternal *p, ReadStatus *status, Bool stdout, Bool readToEof)
 
    // if there's output waiting, read it out. FDs should already be non-blocking
    do {
-      count = read(fd, buf, sizeof buf);
+      ssize_t count = read(fd, buf, sizeof buf);
+
       if (count > 0) {
          // save output
          currSize = strlen(*saveTo);
index 925985060464100b6ec3f1012937c1e749799bd5..243c725752a81eb2e2634c55388886160640615a 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2004 VMware, Inc. All rights reserved.
+ * Copyright (C) 2004,2019 VMware, Inc. All rights reserved.
  *
  * The contents of this file are subject to the terms of the Common
  * Development and Distribution License (the "License") version 1.0
@@ -405,9 +405,7 @@ Vxn_GetStats(gld_mac_info_t *macInfo, struct gld_stats *gs)
 static void
 Vxn_ApplyAddressFilter(vxn_softc_t *dp)
 {
-   uint8_t *ep;
    int i, j, bit, byte;
-   uint32_t crc, poly = CRC_POLYNOMIAL_LE;
    Vmxnet2_DriverData *dd = dp->driverData;
    volatile uint16_t *mcastTable = (uint16_t *)dd->LADRF;
 
@@ -418,8 +416,9 @@ Vxn_ApplyAddressFilter(vxn_softc_t *dp)
    dd->LADRF[1] = 0;
 
    for (i = 0; i < dp->multiCount; i++) {
-      crc = 0xffffffff;
-      ep = (uint8_t *)&dp->multicastList[i].ether_addr_octet;
+      uint32_t crc = 0xffffffff;
+      uint32_t poly = CRC_POLYNOMIAL_LE;
+      uint8_t *ep = (uint8_t *)&dp->multicastList[i].ether_addr_octet;
 
       for (byte = 0; byte < 6; byte++) {
          for (bit = *ep++, j = 0; j < 8; j++, bit >>= 1) {
@@ -1095,9 +1094,7 @@ Vxn_TxComplete(vxn_softc_t *dp, boolean_t *reschedp)
 static boolean_t
 Vxn_Receive(vxn_softc_t *dp)
 {
-   int ringnext;
-   short pktlen;
-   Vmxnet2_DriverData *dd = dp->driverData;   
+   Vmxnet2_DriverData *dd = dp->driverData;
    rx_dma_buf_t *rxDesc;
    rx_dma_buf_t *newRxDesc;
    mblk_t *mblk;
@@ -1109,17 +1106,18 @@ Vxn_Receive(vxn_softc_t *dp)
    ASSERT(MUTEX_HELD(&dp->intrlock));
 
    /*
-    * Walk receive ring looking for entries with ownership 
+    * Walk receive ring looking for entries with ownership
     * reverted back to driver
     */
    while (1) {
       Vmxnet2_RxRingEntry *rre;
       rx_dma_buf_t **rbuf;
+      short pktlen;
+      int ringnext = dd->rxDriverNext;
 
-      ringnext = dd->rxDriverNext;
       rre = &dp->rxRing[ringnext];
       rbuf = &dp->rxRingBuffPtr[ringnext];
-      
+
       if (rre->ownership != VMXNET2_OWNERSHIP_DRIVER) {
          break;
       }
index a2b205e4fa8d39f540702488660643b80689aa58..28f2529f6b7719bc69193ea8a0aaf3ff29e2e8a5 100644 (file)
@@ -1200,7 +1200,6 @@ vmxnet3_get_prop(void *data,
                void *prop_val)
 {
    vmxnet3_softc_t *dp = data;
-   int ret = 0;
 
    switch (prop_id) {
       case MAC_PROP_MTU: {
@@ -1210,7 +1209,6 @@ vmxnet3_get_prop(void *data,
       }
       default: {
          VMXNET3_WARN(dp, "vmxnet3_get_prop property %d not supported", prop_id);
-         ret = ENOTSUP;
       }
    }
    return (0);
index f23a7914f627b2e9b0d6bf31f2afc5b921bb48ff..7866201bc04f71fefc7567a3a217c08357c4d3e8 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007,2019 VMware, Inc. All rights reserved.
  *
  * The contents of this file are subject to the terms of the Common
  * Development and Distribution License (the "License") version 1.0
@@ -327,9 +327,9 @@ static void
 vmxnet3_rx_hwcksum(vmxnet3_softc_t *dp, mblk_t *mp,
                    Vmxnet3_GenericDesc *compDesc)
 {
-   uint32_t flags = 0;
-
    if (!compDesc->rcd.cnc) {
+      uint32_t flags = 0;
+
       if (compDesc->rcd.v4 && compDesc->rcd.ipc) {
          flags |= HCK_IPV4_HDRCKSUM;
          if ((compDesc->rcd.tcp || compDesc->rcd.udp) &&
index c60976cfba11f7fbf0f73d0c1ab8a8b19012e646..3e3319b8ca96be7fad3d0433b388f1550bda209a 100644 (file)
@@ -154,10 +154,11 @@ ValidateNSCommands(const gchar *cmdName)
 static void
 PrintInternalCommand(const char *data, size_t dataSize)
 {
-   int readCounter = 0;
    char *tmp = NULL;
    char *printBuf = NULL;
    if (dataSize > 0) {
+      int readCounter = 0;
+
       printBuf = (char *) calloc((int)dataSize, sizeof(char));
       if (printBuf == NULL) {
          fprintf(stderr, "Out of memory error");
@@ -527,8 +528,8 @@ static gboolean
 PostVerifySetKeyOptions(GOptionContext *context, GOptionGroup *group,
                         gpointer data, GError **error)
 {
-   int usedOptions = 0;
    NamespaceOptionsState *nsOptions;
+
    ASSERT(data);
    nsOptions = (NamespaceOptionsState *) data;
 
@@ -543,6 +544,8 @@ PostVerifySetKeyOptions(GOptionContext *context, GOptionGroup *group,
       return FALSE;
    }
    if (g_strcmp0(nsOptions->cmdName, NSDB_SET_KEY_USER_CMD) == 0) {
+      int usedOptions = 0;
+
       if (nsOptions->keyName == NULL) {
          g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
                      "Key name must be specified");
index 635a2016446cc2d9771f998bca3ee81537249859..8735cb6c4c11f7ba2e2deb84d49a12f603d2a360 100644 (file)
@@ -175,12 +175,13 @@ ExitPoint:
 gboolean
 DeployPkg_TcloBegin(RpcInData *data)   // IN
 {
-   static char resultBuffer[FILE_MAXPATH];
    char *tempDir = DeployPkgGetTempDir();
 
    g_debug("DeployPkgTcloBegin got call\n");
 
    if (tempDir) {
+      static char resultBuffer[FILE_MAXPATH];
+
       Str_Strcpy(resultBuffer, tempDir, sizeof resultBuffer);
       free(tempDir);
       return RPCIN_SETRETVALS(data, resultBuffer, TRUE);
@@ -210,7 +211,6 @@ DeployPkgExecDeploy(ToolsAppCtx *ctx,   // IN: app context
 {
    char errMsg[2048];
    ToolsDeployPkgError ret;
-   gchar *msg;
    char *pkgNameStr = (char *) pkgName;
 
    g_debug("%s: Deploypkg deploy task started.\n", __FUNCTION__);
@@ -218,10 +218,11 @@ DeployPkgExecDeploy(ToolsAppCtx *ctx,   // IN: app context
    /* Unpack the package and run the command. */
    ret = DeployPkgDeployPkgInGuest(ctx, pkgNameStr, errMsg, sizeof errMsg);
    if (ret != TOOLSDEPLOYPKG_ERROR_SUCCESS) {
-      msg = g_strdup_printf("deployPkg.update.state %d %d %s",
-                            TOOLSDEPLOYPKG_DEPLOYING,
-                            TOOLSDEPLOYPKG_ERROR_DEPLOY_FAILED,
-                            errMsg);
+      gchar *msg = g_strdup_printf("deployPkg.update.state %d %d %s",
+                                   TOOLSDEPLOYPKG_DEPLOYING,
+                                   TOOLSDEPLOYPKG_ERROR_DEPLOY_FAILED,
+                                   errMsg);
+
       if (!RpcChannel_Send(ctx->rpc, msg, strlen(msg), NULL, NULL)) {
          g_warning("%s: failed to send error code %d for state TOOLSDEPLOYPKG_DEPLOYING\n",
                    __FUNCTION__,
index e8eca5176d6194171c27d25125f4f4e611402015..248073405632e11e2c774d0606fe85a0154a5f00 100644 (file)
@@ -156,7 +156,6 @@ CopyPasteSelectionRemoveTarget(GtkWidget *widget,
                                GdkAtom target)
 {
    const char *selection_handler_key = "gtk-selection-handlers";
-   struct SelectionTargetList *targetList;
    GList *tempList;
    GList *selectionLists;
 
@@ -169,7 +168,7 @@ CopyPasteSelectionRemoveTarget(GtkWidget *widget,
    tempList = selectionLists;
    while (tempList) {
       /* Enumerate the list to find the selection. */
-      targetList = tempList->data;
+      struct SelectionTargetList *targetList = tempList->data;
       if (targetList->selection == selection) {
          /* Remove target. */
          gtk_target_list_remove(targetList->list, target);
@@ -681,11 +680,8 @@ void
 CopyPasteSetBackdoorSelections(void)
 {
    uint32 const *p;
-   size_t len;
-   size_t aligned_len;
    size_t primaryLen;
    size_t clipboardLen;
-   unsigned int i;
 
    primaryLen = strlen(gGuestSelPrimaryBuf);
    clipboardLen = strlen(gGuestSelClipboardBuf);
@@ -716,7 +712,10 @@ CopyPasteSetBackdoorSelections(void)
       CopyPaste_SetSelLength(0);
       g_debug("CopyPasteSetBackdoorSelections Set empty text.\n");
    } else {
-      len = strlen((char *)p);
+      size_t len = strlen((char *)p);
+      size_t aligned_len;
+      unsigned int i;
+
       g_debug("CopyPasteSetBackdoorSelections Set text [%s].\n", (char *)p);
       aligned_len = (len + 4) & ~3;
 
index fad000e3a85115697ce94dab5721d000eba62c15..89e5f661e3fed8da38f8c9b740060c10f326b1d8 100644 (file)
@@ -990,7 +990,6 @@ CopyPasteUIX11::LocalGetSelectionFileList(const Gtk::SelectionData& sd)      //
 {
    utf::string source;
    char *newPath;
-   char *newRelPath;
    size_t newPathLen;
    size_t index = 0;
    DnDFileList fileList;
@@ -1025,6 +1024,8 @@ CopyPasteUIX11::LocalGetSelectionFileList(const Gtk::SelectionData& sd)      //
    while ((newPath = DnD_UriListGetNextFile(source.c_str(),
                                             &index,
                                             &newPathLen)) != NULL) {
+      char *newRelPath;
+
 #if defined(__linux__)
       if (DnD_UriIsNonFileSchemes(newPath)) {
          /* Try to get local file path for non file uri. */
index eb1f81bdb93b021774f25784eb7dd4368df70daa..291d5db7c77373a338bd6128c020b32129878c75 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-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
@@ -288,7 +288,6 @@ Bool
 DnDMsg_Serialize(DnDMsg *msg,   // IN/OUT: the message
                  DynBuf* buf)   // OUT: the output buffer
 {
-   DynBuf *curArg;
    uint32 nargs;
    uint32 i;
    uint32 serializeArgsSz = 0;
@@ -313,7 +312,8 @@ DnDMsg_Serialize(DnDMsg *msg,   // IN/OUT: the message
       uint32 curArgsSz;
 
       for (i = 0; i < nargs; i++) {
-         curArg = DynBufArray_AddressOf(&msg->args, i);
+         DynBuf *curArg = DynBufArray_AddressOf(&msg->args, i);
+
          curArgsSz = DynBuf_GetSize(curArg);
 
          if (!DynBuf_Append(buf, &curArgsSz, sizeof curArgsSz) ||
index cf837002ac86a9c82b82c3b85d47fa938cdf2d7f..da54ee58507c4490e558d6c35d4f2d2252fe2efd 100644 (file)
@@ -85,10 +85,11 @@ const char *
 Xdg_GetCacheHome(void)
 {
    static char *result = NULL;
-   struct passwd *pw;
 
    if (result == NULL) {
       do {
+         struct passwd *pw;
+
          if (!Id_IsSetUGid()) {
             const char *base = NULL;
 
index 015dd363193eca38c94df107ea09cc0938179b3d..8eb7f826c24dd051649f4a0da021e2fb68bf7163 100644 (file)
@@ -1079,7 +1079,6 @@ DnDUIX11::OnGtkDragDataGet(
    guint info,                                  // UNUSED
    guint time)                                  // IN: event timestamp
 {
-   size_t index = 0;
    std::string str;
    std::string uriList;
    std::string stagingDirName;
@@ -1105,6 +1104,7 @@ DnDUIX11::OnGtkDragDataGet(
 
    if (   target == DRAG_TARGET_NAME_URI_LIST
        && CPClipboard_GetItem(&mClipboard, CPFORMAT_FILELIST, &buf, &sz)) {
+      size_t index = 0;
 
       /* Provide path within vmblock file system instead of actual path. */
       stagingDirName = GetLastDirName(mHGStagingDir);
@@ -1413,10 +1413,6 @@ DnDUIX11::OnGtkDragDrop(
 bool
 DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN
 {
-   char *newPath;
-   char *newRelPath;
-   size_t newPathLen;
-   size_t index = 0;
    DnDFileList fileList;
    DynBuf buf;
    uint64 totalSize = 0;
@@ -1431,6 +1427,10 @@ DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN
        * one for just the last path component.
        */
       utf::string source = sd.get_data_as_string().c_str();
+      size_t index = 0;
+      char *newPath;
+      size_t newPathLen;
+
       g_debug("%s: Got file list: [%s]\n", __FUNCTION__, source.c_str());
 
       if (sd.get_data_as_string().length() == 0) {
@@ -1458,6 +1458,8 @@ DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN
       while ((newPath = DnD_UriListGetNextFile(source.c_str(),
                                                &index,
                                                &newPathLen)) != NULL) {
+         char *newRelPath;
+
 #if defined(__linux__)
          if (DnD_UriIsNonFileSchemes(newPath)) {
             /* Try to get local file path for non file uri. */
index b5ae2974725c48ab9081e8ceb03351601f563d30..b4cfcc4b9048fd6f26d72bb75b90c0011074d153 100644 (file)
@@ -393,13 +393,12 @@ PointerUpdatePointerLoop(gpointer clientData) // IN: unused
 
    if (!CopyPaste_IsRpcCPSupported() ||
        (absoluteMouseState == ABSMOUSE_UNAVAILABLE)) {
-
-      GSource *src;
-
       CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
       ToolsAppCtx *ctx = wrapper->GetToolsAppCtx();
+
       if (ctx) {
-         src = VMTools_CreateTimer(POINTER_UPDATE_TIMEOUT);
+         GSource *src = VMTools_CreateTimer(POINTER_UPDATE_TIMEOUT);
+
          VMTOOLSAPP_ATTACH_SOURCE(ctx, src, PointerUpdatePointerLoop, NULL, NULL);
          g_source_unref(src);
       }
index b7cbb0e4ecae1808b2d1e385a0f813e0fa988835..86060b53faa38c9d14a735b72e08559bca156ae6 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2018-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
@@ -138,15 +138,18 @@ VMCopyPasteDnDWrapper::RemoveDnDPluginResetTimer(void)
 void
 VMCopyPasteDnDWrapper::OnCapReg(gboolean set)
 {
+   ToolsAppCtx *ctx;
+
    g_debug("%s: enter\n", __FUNCTION__);
-   char *reply = NULL;
-   size_t replyLen;
-   const char *toolsDnDVersion = TOOLS_DND_VERSION_4;
-   char *toolsCopyPasteVersion = NULL;
-   int version;
 
-   ToolsAppCtx *ctx = GetToolsAppCtx();
+   ctx = GetToolsAppCtx();
    if (ctx) {
+      char *reply = NULL;
+      size_t replyLen;
+      const char *toolsDnDVersion = TOOLS_DND_VERSION_4;
+      char *toolsCopyPasteVersion = NULL;
+      int version;
+
       /*
        * First DnD.
        */
index b5f766c8ffd680e22133b3b138a2e7ec87db209f..5c343e66cc005cacb46f2c9f4e5d2101b370ae19 100644 (file)
@@ -1796,9 +1796,7 @@ static Bool
 DiskInfoChanged(const GuestDiskInfoInt *diskInfo)
 {
    int index;
-   char *name;
    int i;
-   int matchedPartition;
    GuestDiskInfoInt *cachedDiskInfo;
 
    cachedDiskInfo = gInfoCache.diskInfo;
@@ -1817,7 +1815,8 @@ DiskInfoChanged(const GuestDiskInfoInt *diskInfo)
 
    /* Have any disks been modified? */
    for (index = 0; index < cachedDiskInfo->numEntries; index++) {
-      name = cachedDiskInfo->partitionList[index].name;
+      int matchedPartition;
+      char *name = cachedDiskInfo->partitionList[index].name;
 
       /* Find the corresponding partition in the new partition info. */
       for (i = 0; i < diskInfo->numEntries; i++) {
index 7be698458b472a50ab1e9a85f6c67865d638b3ec..6340b113b9687934d28d79f7be34aee470783645 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
@@ -827,8 +827,6 @@ RandR12DeleteModes(Display *display,  // IN: The display connection
                    RandR12Info *info) // IN: RandR12Info context
 {
    XRRScreenResources *xrrRes = info->xrrRes;
-   XRRModeInfo *modeInfo;
-   RandR12Output *rrOutput;
    unsigned int i, j;
    unsigned int w, h;
    Bool used;
@@ -839,7 +837,8 @@ RandR12DeleteModes(Display *display,  // IN: The display connection
     */
 
    for (i = 0; i < xrrRes->nmode; ++i) {
-      modeInfo = &xrrRes->modes[i];
+      XRRModeInfo *modeInfo = &xrrRes->modes[i];
+
       if (sscanf(modeInfo->name, RR12_MODE_FORMAT, &w, &h) != 2) {
          continue;
       }
@@ -854,7 +853,7 @@ RandR12DeleteModes(Display *display,  // IN: The display connection
        */
 
       for (j = 0; j < info->nOutput; ++j) {
-         rrOutput = &info->outputs[j];
+         RandR12Output *rrOutput = &info->outputs[j];
 
          if (rrOutput->mode != modeInfo->id) {
             if (RandR12OutputHasMode(rrOutput->output, modeInfo)) {
index e17a58a289b9d5515e871abf27ad19d5417aceea..c5591139d07fad22c35ac2b65dcbf7fa7d5103b8 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-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
@@ -17,7 +17,7 @@
  *********************************************************/
 
 /*
- * @file resolutionX11.c 
+ * @file resolutionX11.c
  *
  * X11 backend for resolutionSet plugin.
  */
@@ -375,16 +375,18 @@ ResolutionCanSet(void)
     */
    if (major > 1 || (major == 1 && minor >= 2)) {
       XRRScreenResources* xrrRes;
-      XRROutputInfo* xrrOutput;
       unsigned int num;
-      int i;
 
       xrrRes = XRRGetScreenResources(resInfoX->display, resInfoX->rootWindow);
 
       if (xrrRes) {
+         int i;
+
          for (i = 0; i < xrrRes->noutput; i++) {
-            xrrOutput = XRRGetOutputInfo(resInfoX->display, xrrRes,
-                                         xrrRes->outputs[i]);
+            XRROutputInfo* xrrOutput =
+               XRRGetOutputInfo(resInfoX->display, xrrRes,
+                                xrrRes->outputs[i]);
+
             if (!xrrOutput) {
                break;
             }
index 0f24ffa5768026556c742a8c0f4d62dd8ee75de1..f8ce30f7d53cbddf60687c36fcda240ac2780ed1 100644 (file)
@@ -154,9 +154,9 @@ VmBackupRunNextScript(VmBackupScriptOp *op)  // IN/OUT
    }
 
    while (index >= 0 && scripts[index].path != NULL) {
-      char *cmd;
-
       if (File_IsFile(scripts[index].path)) {
+         char *cmd;
+
          if (op->state->scriptArg != NULL) {
             cmd = Str_Asprintf(NULL, "\"%s\" %s \"%s\"", scripts[index].path,
                                scriptOp, op->state->scriptArg);
@@ -345,11 +345,12 @@ exit:
 static void
 VmBackupScriptOpRelease(VmBackupOp *_op)  // IN
 {
-   size_t i;
    VmBackupScriptOp *op = (VmBackupScriptOp *) _op;
 
    if (op->type != VMBACKUP_SCRIPT_FREEZE && op->state->scripts != NULL) {
+      size_t i;
       VmBackupScript *scripts = op->state->scripts;
+
       for (i = 0; scripts[i].path != NULL; i++) {
          free(scripts[i].path);
          if (scripts[i].proc != NULL) {
index e9e3ef7f9b39fb687426ceafeeff2e82f31e2dc3..53133731c10ce1947201862e44e22b8cb8dca986 100644 (file)
@@ -354,7 +354,6 @@ ToolsCore_InitRpc(ToolsServiceState *state)
       { "Set_Option", ToolsCoreRpcSetOption, NULL, NULL, NULL, 0 },
    };
 
-   size_t i;
    const gchar *app;
    GMainContext *mainCtx = g_main_loop_get_context(state->ctx.mainLoop);
 
@@ -396,6 +395,7 @@ ToolsCore_InitRpc(ToolsServiceState *state)
        */
       RpcChannelFailureCb failureCb = NULL;
       guint errorLimit = 0;
+      size_t i;
 
 #if !defined(_WIN32)
 
index 42ac297db624550ac5655f6537bb7ec2149105e5..012926bf5efd453fbf2711584f1515b2af93a715 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-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
@@ -55,7 +55,6 @@ main(int argc,
      char *argv[])
 {
    int status;
-   char op;
 
    if (argc < 2 ||
        strcmp(argv[1], "-h") == 0 ||
@@ -74,7 +73,8 @@ main(int argc,
    printf("Opened " VMBLOCK_DEVICE " as fd %d.\n", fd);
 
    while (1) {
-      op = getchar();
+      char op = getchar();
+
       if (op == 'a') {
          status = VMBLOCK_CONTROL(fd, VMBLOCK_ADD_FILEBLOCK, argv[1]);
          if (status != 0) {
index 06ae1c3f504a8e0d459d408438b125e93fb3a7b6..eca231d89175ab067ae0c512147637437961e697 100644 (file)
@@ -87,7 +87,6 @@ ServiceFileLoggerOpen(FileLoggerData *data)
           * will always be index "0"). When not rotating, "maxFiles" is 1, so we
           * always keep one backup.
           */
-         gchar *fname;
          guint id;
          GPtrArray *logfiles = g_ptr_array_new();
 
@@ -97,7 +96,8 @@ ServiceFileLoggerOpen(FileLoggerData *data)
           * file, which may or may not exist.
           */
          for (id = 0; id < data->maxFiles; id++) {
-            fname = g_strdup_printf("%s.%d", data->path, id);
+            gchar *fname = g_strdup_printf("%s.%d", data->path, id);
+
             g_ptr_array_add(logfiles, fname);
             if (!g_file_test(fname, G_FILE_TEST_IS_REGULAR)) {
                break;
index 1ff6a29431c45392197bceb396b0fe9e51674aeb..ce2e2ac17ee654cb5d8b72cadef80b286c37203c 100644 (file)
@@ -338,12 +338,7 @@ ServiceIOAcceptGSource(gpointer userData)
 {
    ServiceConnection *newConn = NULL;
    ServiceConnection *lConn = (ServiceConnection *) userData;
-   VGAuthError err = VGAUTH_E_OK;
-#ifdef _WIN32
-   GSource *gSourceData;
-#else
-   GIOChannel *echan;
-#endif
+   VGAuthError err;
 
    err = ServiceConnectionClone(lConn, &newConn);
    if (VGAUTH_E_OK != err) {
@@ -353,6 +348,12 @@ ServiceIOAcceptGSource(gpointer userData)
 
    err = ServiceAcceptConnection(lConn, newConn);
    if (VGAUTH_E_OK == err) {
+#ifdef _WIN32
+      GSource *gSourceData;
+#else
+      GIOChannel *echan;
+#endif
+
       VGAUTH_LOG_DEBUG("Established a new pipe connection %d on %s", newConn->connId,
                        newConn->pipeName);
 #ifdef _WIN32
index 0ee824469521922d5a4c4d84ad5fb2ced456c858..89156008b55e00005bae6a6cf14be3bbad19b315 100644 (file)
@@ -1087,7 +1087,6 @@ AliasStartElement(GMarkupParseContext *parseContext,
 {
    AliasParseList *list = (AliasParseList *) userData;
    ServiceAliasInfo *infos;
-   int n;
 
    ASSERT(list);
 
@@ -1132,6 +1131,8 @@ AliasStartElement(GMarkupParseContext *parseContext,
       break;
    case ALIAS_PARSE_STATE_ALIASINFOS:
       if (g_strcmp0(elementName, ALIASINFO_ALIASINFO_ELEMENT_NAME) == 0) {
+         int n;
+
          list->state = ALIAS_PARSE_STATE_ALIASINFO;
 
          // grow
index 3cef3b55da7071d2876985950ba6b19a1b5a8d64..dc1dfd7f2151d1bcb8bebc0252b7b052adf74954 100644 (file)
@@ -1833,10 +1833,7 @@ ServiceProtoQueryMappedAliases(ServiceConnection *conn,
 {
    VGAuthError err;
    gchar *packet;
-   gchar *endPacket;
    int num;
-   int i;
-   int j;
    ServiceMappedAlias *maList;
 
    /*
@@ -1848,10 +1845,14 @@ ServiceProtoQueryMappedAliases(ServiceConnection *conn,
    if (err != VGAUTH_E_OK) {
       packet = Proto_MakeErrorReply(conn, req, err, "queryMappedIds failed");
    } else {
+      int i;
+      gchar *endPacket;
+
       packet = g_markup_printf_escaped(VGAUTH_QUERYMAPPEDALIASES_REPLY_FORMAT_START,
                                        req->sequenceNumber);
       for (i = 0; i < num; i++) {
          gchar *tPacket;
+         int j;
 
          tPacket = g_markup_printf_escaped(VGAUTH_MAPPEDALIASES_FORMAT_START,
                                            maList[i].userName,
index bda1013eaa933266d6aaddc69ed9b98dfc6431c6..1a47c6c1b4263cfe7c8886ee9d13c42682e5f06e 100644 (file)
@@ -118,10 +118,8 @@ ServiceVerifyAndCheckTrustCertChainForSubject(int numCerts,
     * Dump the token cert chain for debugging purposes.
     */
    if (gVerboseLogging) {
-      gchar *chainx509;
-
       for (i = 0; i < numCerts; i++) {
-         chainx509 = CertVerify_CertToX509String(pemCertChain[i]);
+         gchar *chainx509 = CertVerify_CertToX509String(pemCertChain[i]);
          Debug("%s: Token chain cert #%d:\n%s", __FUNCTION__, i, chainx509);
          g_free(chainx509);
       }
@@ -225,12 +223,11 @@ ServiceVerifyAndCheckTrustCertChainForSubject(int numCerts,
     * Dump the store cert chain for debugging purposes.
     */
    if (gVerboseLogging) {
-      gchar *storex509;
-
       Debug("%s: %d certs in store for user %s\n",  __FUNCTION__,
             numStoreCerts, queryUserName);
       for (i = 0; i < numStoreCerts; i++) {
-         storex509 = CertVerify_CertToX509String(aList[i].pemCert);
+         gchar *storex509 = CertVerify_CertToX509String(aList[i].pemCert);
+
          Debug("%s: Store chain cert #%d:\n%s", __FUNCTION__, i, storex509);
          g_free(storex509);
       }
index 2817d90f9a2181a61925ad0a108993701a1345d3..28337d80b5304a0fe093c5604727795eb7bb9d0d 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
@@ -252,7 +252,6 @@ int
 VMBlockGetAttr(const char *path,        // IN: File to get attributes of.
                struct stat *statBuf)    // OUT: Where to put the attributes.
 {
-   int status;
    char target[PATH_MAX + 1];
    vmblockSpecialDirEntry *dirEntry;
    ASSERT(path != NULL);
@@ -273,7 +272,8 @@ VMBlockGetAttr(const char *path,        // IN: File to get attributes of.
       }
    }
    if (strncmp(path, REDIRECT_DIR, strlen(REDIRECT_DIR)) == 0) {
-      status = RealReadLink(path, target, sizeof target);
+      int status = RealReadLink(path, target, sizeof target);
+
       LOG(4, "%s: Called RealReadLink which returned: %d\n", __func__, status);
       if (status != 0) {
          return status;
@@ -675,8 +675,6 @@ VMBlockRead(const char *path,                 // IN: Must be control file.
             off_t offset,                     // IN: Ignored.
             struct fuse_file_info *fileInfo)  // IN: Ignored.
 {
-   char target[PATH_MAX+1];
-   char targetLink[PATH_MAX+1];
    const char redirectPrefix[] = REDIRECT_DIR "/";
    const char redirectPrefixLength = sizeof redirectPrefix - 1;
    const char notifyPrefix[] = NOTIFY_DIR "/";
@@ -696,6 +694,9 @@ VMBlockRead(const char *path,                 // IN: Must be control file.
    }
 
    if (strncmp(path, NOTIFY_DIR, strlen(NOTIFY_DIR)) == 0) {
+      char target[PATH_MAX+1];
+      char targetLink[PATH_MAX+1];
+
       strlcpy(target, redirectPrefix, sizeof target);
       strlcpy(target + redirectPrefixLength,
               relativePath,
index 5c56ce3cb5c12f3072f418763faa0da76b662637..c3167cac277d2e9ced37ab311c0cba257f1755f1 100644 (file)
@@ -322,12 +322,13 @@ HgfsGetAttrCache(const char* path,   //IN: Path of file or directory
 {
    HgfsAttrCache *tmp;
    int res = -1;
-   int diff;
 
    pthread_mutex_lock(&HgfsAttrCacheLock);
 
    tmp = (HgfsAttrCache *)g_hash_table_lookup(g_hash_table, path);
    if (tmp != NULL) {
+      int diff;
+
       LOG(4, ("cache hit. path = %s\n", tmp->path));
 
       diff = (HGFS_GET_TIME(time(NULL)) - tmp->changeTime) / 10000000;
index 14b68960d79258f105f0807074767ed8cd2bd4b4..e56d621dbb896395718f76d401dd698b2eaa1639 100644 (file)
@@ -1161,8 +1161,6 @@ HgfsPackSetattrRequest(const char *path,   // IN:  path to file
                        HgfsReq *req)       // IN/OUT: req packet
 {
    HgfsAttrV2 *attrV2;
-   HgfsAttr *attrV1;
-   HgfsAttrChanges *update;
    size_t reqBufferSize;
    size_t reqSize;
    ASSERT(req);
@@ -1297,10 +1295,11 @@ HgfsPackSetattrRequest(const char *path,   // IN:  path to file
    }
    case HGFS_OP_SETATTR: {
       int result;
+      HgfsAttr *attrV1;
       HgfsRequestSetattr *request;
+      HgfsAttrChanges *update;
 
       request = (HgfsRequestSetattr *)(HGFS_REQ_PAYLOAD(req));
-
       attrV1 = &request->attr;
       update = &request->update;