From 6e872d4bf18cc2f81560228ce3be2682540b77f8 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 30 Oct 2021 15:45:49 +0100 Subject: [PATCH] Fix potential sign issue. Signed-off-by: Andrea Odetti --- source/frontends/common2/utils.cpp | 7 +++++-- source/linux/context.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/frontends/common2/utils.cpp b/source/frontends/common2/utils.cpp index 98438566..36017de9 100644 --- a/source/frontends/common2/utils.cpp +++ b/source/frontends/common2/utils.cpp @@ -145,7 +145,10 @@ namespace common2 DWORD value; if (RegLoadValue(path.c_str(), name, TRUE, &value)) { - dest = value; + // DWORD and int have the same size + // but if they did not, this would be necessary + typedef std::make_signed::type signed_t; + dest = static_cast(value); } }; @@ -161,9 +164,9 @@ namespace common2 const std::string path = section + "\\geometry"; const auto saveValue = [&path](const char * name, const int source) { + // this seems to already do the right thing for negative numbers RegSaveValue(path.c_str(), name, TRUE, source); }; - saveValue("width", geometry.width); saveValue("height", geometry.height); saveValue("x", geometry.x); diff --git a/source/linux/context.cpp b/source/linux/context.cpp index d43c828b..24873f59 100644 --- a/source/linux/context.cpp +++ b/source/linux/context.cpp @@ -79,4 +79,4 @@ RegistryContext::RegistryContext(const std::shared_ptr & registry) RegistryContext::~RegistryContext() { Registry::instance.reset(); -} \ No newline at end of file +}