Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

environment: Move local variable to inner scope #391

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,16 @@ std::string ENVIRONMENT::get_distname()
std::string dist_name;

#ifdef _WIN32
LONG rc;
DWORD dwSize;
HKEY hKey;
char *regVal;

std::ostringstream vstr;
vstr << "Windows";

OSVERSIONINFOEX osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *)&osvi) != 0)
{
LONG rc;
HKEY hKey;

switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
Expand All @@ -227,13 +225,15 @@ std::string ENVIRONMENT::get_distname()
0, KEY_READ | KEY_WOW64_64KEY, &hKey );
if( rc == ERROR_SUCCESS )
{
DWORD dwSize;

// read size of ProductName
rc = RegQueryValueEx( hKey, "ProductName",
nullptr, nullptr, nullptr, &dwSize );
if( rc == ERROR_SUCCESS && dwSize > 0 )
{
// get buffer
regVal = (char *)malloc( dwSize );
char* regVal = (char *)malloc( dwSize );
if( regVal != nullptr )
{
// read ProductName
Expand All @@ -255,7 +255,7 @@ std::string ENVIRONMENT::get_distname()
if( rc == ERROR_SUCCESS && dwSize > 0 )
{
// get buffer
regVal = (char *)malloc( dwSize );
char* regVal = (char *)malloc( dwSize );
if( regVal != nullptr )
{
// read CSDVersion
Expand Down