[Spice-devel] [vdagent-win PATCH] log: rewrite log_version using config.h definitions
Christophe Fergeau
cfergeau at redhat.com
Mon Jul 24 12:37:36 UTC 2017
On Mon, Jul 24, 2017 at 01:06:17PM +0100, Frediano Ziglio wrote:
> Instead of having to get the version information from the
> executable resources get from the build configuration file.
> The same version is used to build the version information
> resource.
> This also remove a bug in log_version where "throw" statements
> were used to raise again a not existing exception on case
> of failures.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> common/vdlog.cpp | 31 ++-----------------------------
> 1 file changed, 2 insertions(+), 29 deletions(-)
>
> diff --git a/common/vdlog.cpp b/common/vdlog.cpp
> index c983127..93d8dba 100644
> --- a/common/vdlog.cpp
> +++ b/common/vdlog.cpp
> @@ -15,6 +15,7 @@
> along with this program. If not, see <http://www.gnu.org/licenses/>.
> */
>
> +#include "config.h"
> #include "vdcommon.h"
> #include "vdlog.h"
> #include <stdio.h>
> @@ -79,33 +80,5 @@ void VDLog::printf(const char* format, ...)
>
> void log_version()
> {
> - DWORD handle;
> - TCHAR module_fname[MAX_PATH];
> -
> - try {
> - if (!GetModuleFileName(NULL, module_fname, MAX_PATH)) {
> - throw;
> - }
> - DWORD version_inf_size = GetFileVersionInfoSize(module_fname, &handle);
> - if (version_inf_size == 0) {
> - throw;
> - }
> - std::vector<TCHAR> info_buf(version_inf_size);
> - if (!GetFileVersionInfo(module_fname, handle, version_inf_size, &info_buf[0])) {
> - throw;
> - }
> - UINT size;
> - VS_FIXEDFILEINFO* file_info;
> - if (!VerQueryValue(&info_buf[0], L"\\", (VOID**)&file_info, &size) ||
> - size < sizeof(VS_FIXEDFILEINFO)) {
> - throw;
> - }
> - vd_printf("%lu.%lu.%lu.%lu",
> - file_info->dwFileVersionMS >> 16,
> - file_info->dwFileVersionMS & 0x0ffff,
> - file_info->dwFileVersionLS >> 16,
> - file_info->dwFileVersionLS & 0x0ffff);
> - } catch (...) {
> - vd_printf("get version info failed");
> - }
> + vd_printf("%u.%u.%u.%u", RC_PRODUCTVERSION);
Feels a bit too magic to me with the , hidden inside a preprocessor
constant...
With a comment along the lines of the v1 suggestion,
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170724/15df719d/attachment.sig>
More information about the Spice-devel
mailing list