]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Use RPCI_UNKNOWN_COMMAND macro instead of hardcoded 'Unknown command" string.
authorOliver Kurth <okurth@vmware.com>
Mon, 4 May 2020 18:54:13 +0000 (11:54 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 4 May 2020 18:54:13 +0000 (11:54 -0700)
At few places in the code, the result from the RPC channel send APIs
is explicitly compared with a harcoded "Unknown command" string.  We already
have a well defined macro for that.  Changed the code to re-use the macro
wherever possible.

open-vm-tools/libappmonitor/vmGuestAppMonitorLib.c
open-vm-tools/libguestlib/vmGuestLib.c

index b8ce9f65e57f7acbf4c3187cf397abe0e77e8144..b450245e0d8b4b8b064c9cb7d501a09951393536 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2009-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2009-2020 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
@@ -58,6 +58,7 @@
 #include "vmguestappmonitorlib_version.h"
 #include "vm_version.h"
 #include "embed_version.h"
+#include "vmware/guestrpc/tclodefs.h"
 #include "vmware/tools/guestrpc.h"
 
 VM_EMBED_VERSION(VMGUESTAPPMONITORLIB_VERSION_STRING);
@@ -362,8 +363,8 @@ RunGuestAppMonitorCmd(const char *cmd)
    if (!RpcChannel_Send(gChan, cmd, strlen(cmd), &reply, &replyLen)) {
       Debug("Failed to run %s command: %s\n", cmd, reply ? reply : "NULL");
 
-      if (Str_Strncmp(reply, "Unknown command",
-                      sizeof "Unknown command") == 0) {
+      if (Str_Strncmp(reply, RPCI_UNKNOWN_COMMAND,
+                      sizeof RPCI_UNKNOWN_COMMAND) == 0) {
          /* Host does not support application monitoring */
          rc = VMGUESTAPPMONITORLIB_ERROR_NOT_SUPPORTED;
       } else {
@@ -429,8 +430,8 @@ RunGuestAppMonitorCmdWithResult(const char *cmd,
    if (!RpcChannel_Send(gChan, cmd, strlen(cmd), &reply, &replyLen)) {
       Debug("Failed to run %s command: %s\n", cmd,  reply ? reply : "NULL");
 
-      if (Str_Strncmp(reply, "Unknown command",
-                      sizeof "Unknown command") == 0) {
+      if (Str_Strncmp(reply, RPCI_UNKNOWN_COMMAND,
+                      sizeof RPCI_UNKNOWN_COMMAND) == 0) {
          /* Host does not support application monitoring */
          rc = VMGUESTAPPMONITORLIB_ERROR_NOT_SUPPORTED;
       } else {
index 5cf0c811a026d5f690c0f9d5fc17e8999e4db8c5..8227c46221e96bd050512ee6c9f9a7200afc8843 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2005-2016,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2005-2016,2019-2020 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
@@ -27,6 +27,7 @@
 #include "vmGuestLib.h"
 #include "vmGuestLibInt.h"
 #include "str.h"
+#include "vmware/guestrpc/tclodefs.h"
 #include "vmware/tools/guestrpc.h"
 #include "vmcheck.h"
 #include "util.h"
@@ -402,8 +403,9 @@ VMGuestLibUpdateInfo(VMGuestLibHandle handle) // IN
       Debug("Failed to retrieve info: %s\n", reply ? reply : "NULL");
 
       if (hostVersion == 2 ||
-          Str_Strncmp(reply, "Unknown command", sizeof "Unknown command") == 0) {
-         /* 
+          Str_Strncmp(reply, RPCI_UNKNOWN_COMMAND,
+                      sizeof RPCI_UNKNOWN_COMMAND) == 0) {
+         /*
           * Host does not support this feature. Older (v2) host would return
           * "Unsupported version" if it doesn't recognize the requested version.
           *