From: Oliver Kurth Date: Mon, 4 May 2020 18:54:13 +0000 (-0700) Subject: Use RPCI_UNKNOWN_COMMAND macro instead of hardcoded 'Unknown command" string. X-Git-Tag: stable-11.2.0~221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5f0d8d38bfedc576b9fec40b579a0d5f6c85688;p=thirdparty%2Fopen-vm-tools.git Use RPCI_UNKNOWN_COMMAND macro instead of hardcoded 'Unknown command" string. 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. --- diff --git a/open-vm-tools/libappmonitor/vmGuestAppMonitorLib.c b/open-vm-tools/libappmonitor/vmGuestAppMonitorLib.c index b8ce9f65e..b450245e0 100644 --- a/open-vm-tools/libappmonitor/vmGuestAppMonitorLib.c +++ b/open-vm-tools/libappmonitor/vmGuestAppMonitorLib.c @@ -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 { diff --git a/open-vm-tools/libguestlib/vmGuestLib.c b/open-vm-tools/libguestlib/vmGuestLib.c index 5cf0c811a..8227c4622 100644 --- a/open-vm-tools/libguestlib/vmGuestLib.c +++ b/open-vm-tools/libguestlib/vmGuestLib.c @@ -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. *