]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix miscellaneous Codacy warnings in deployPkg plugin code.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:36:59 +0000 (09:36 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:36:59 +0000 (09:36 -0800)
Multiple warnings "The scope of the variable can be reduced" reported by
the Codacy static analysis tool have been addressed.

open-vm-tools/libDeployPkg/linuxDeployment.c
open-vm-tools/libDeployPkg/processPosix.c
open-vm-tools/services/plugins/deployPkg/deployPkg.c
open-vm-tools/services/plugins/deployPkg/deployPkgLog.c

index 99463b50627488c353d3fc426d0c2cfad3ef7a77..063c0b7899d51fa7d3a5740581ba013ae833f3f7 100644 (file)
@@ -238,11 +238,10 @@ DeployPkg_SetProcessTimeout(uint16 timeout)
 NORETURN void
 Panic(const char *fmtstr, ...)
 {
-   va_list args;
-
    char *tmp = malloc(MAXSTRING);
 
    if (tmp != NULL) {
+      va_list args;
       va_start(args, fmtstr);
       Str_Vsnprintf(tmp, MAXSTRING, fmtstr, args);
       va_end(args);
index 92863030515abc9c6663c224c4366c251c90235d..7aa9c249fc684a9c2a4bf113e9f3e29147ba32d3 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2007-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2021 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
@@ -433,7 +433,6 @@ ProcessError
 Process_Destroy(ProcessHandle h)
 {
    ProcessInternal* p;
-   int i;
    p = (ProcessInternal*)h;
    if (p->stdoutFd >= 0) {
       close(p->stdoutFd);
@@ -444,6 +443,7 @@ Process_Destroy(ProcessHandle h)
    free(p->stdoutStr);
    free(p->stderrStr);
    if (p->args != NULL) {
+      int i;
       for (i = 0; p->args[i] != NULL; i++) {
          free(p->args[i]);
       }
index d7a84b421343a25261c3ae311b828a1893b95b7e..7805f59ee47b023e1b60d47ce9c5a446b54ca05f 100644 (file)
@@ -210,7 +210,6 @@ void
 DeployPkgExecDeploy(ToolsAppCtx *ctx,   // IN: app context
                     void *pkgName)      // IN: pkg file name
 {
-   char errMsg[2048];
    ToolsDeployPkgError ret;
    char *pkgNameStr = (char *) pkgName;
    Bool enableCust;
@@ -246,6 +245,7 @@ DeployPkgExecDeploy(ToolsAppCtx *ctx,   // IN: app context
       g_free(msg);
       vm_free(result);
    } else {
+      char errMsg[2048];
       /* Unpack the package and run the command. */
       ret = DeployPkgDeployPkgInGuest(ctx, pkgNameStr, errMsg, sizeof errMsg);
       if (ret != TOOLSDEPLOYPKG_ERROR_SUCCESS) {
index 84b39bab940412d3b9214640a3adfd6f9d9784e1..3b8f78243e75bb5785f2836d9e696a4916c5dd18 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2006-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2006-2021 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
@@ -154,9 +154,6 @@ DeployPkgLog_Log(int level,          // IN
                  ...)                // IN
 {
    va_list args;
-   gchar *tstamp;
-   const char *logLevel;
-   GLogLevelFlags glogLevel;
 
    if (fmtstr == NULL) {
       return;
@@ -165,6 +162,8 @@ DeployPkgLog_Log(int level,          // IN
    va_start(args, fmtstr);
 
    if (_file != NULL) {
+      const char *logLevel;
+      gchar *tstamp;
       size_t fmtstrLen = strlen(fmtstr);
       switch (level) {
          case log_debug:
@@ -193,6 +192,7 @@ DeployPkgLog_Log(int level,          // IN
       }
       g_free(tstamp);
    } else {
+      GLogLevelFlags glogLevel;
       switch (level) {
          case log_debug:
             glogLevel = G_LOG_LEVEL_DEBUG;