Fix potential sign issue.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-10-30 15:45:49 +01:00
parent e8bcb72771
commit 6e872d4bf1
2 changed files with 6 additions and 3 deletions

View file

@ -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<DWORD>::type signed_t;
dest = static_cast<signed_t>(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);

View file

@ -79,4 +79,4 @@ RegistryContext::RegistryContext(const std::shared_ptr<Registry> & registry)
RegistryContext::~RegistryContext()
{
Registry::instance.reset();
}
}