diff options
author | Brad King <brad.king@kitware.com> | 2021-10-27 15:21:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-10-27 15:21:46 (GMT) |
commit | 848eeba483bef0cfeeef78ae77dc3c9a7327b8ea (patch) | |
tree | 3f8066f2905e9c1deb97f3f48db165edf8017289 /Source/kwsys/SystemInformation.cxx | |
parent | a956be484783a991dbda3b14f676538d5f0b17bd (diff) | |
parent | 6015a898d463fc321187ae346155654d55393a4c (diff) | |
download | CMake-848eeba483bef0cfeeef78ae77dc3c9a7327b8ea.zip CMake-848eeba483bef0cfeeef78ae77dc3c9a7327b8ea.tar.gz CMake-848eeba483bef0cfeeef78ae77dc3c9a7327b8ea.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream
* upstream-KWSys:
KWSys 2021-10-27 (e19a5668)
Diffstat (limited to 'Source/kwsys/SystemInformation.cxx')
-rw-r--r-- | Source/kwsys/SystemInformation.cxx | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index f2bf85f..ecb9bf3 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -1267,7 +1267,9 @@ public: private: void* GetRealAddress() const { - return (void*)((char*)this->Address - (char*)this->BinaryBaseAddress); + return reinterpret_cast<void*>( + static_cast<char*>(this->Address) - + static_cast<char*>(this->BinaryBaseAddress)); } std::string GetFileName(const std::string& path) const; @@ -2789,19 +2791,20 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() // ; ecx: middle 32 bits are the processor signature bits // ; edx: bottom 32 bits are the processor signature bits char sn[128]; - sprintf(sn, "%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x", - ((SerialNumber[1] & 0xff000000) >> 24), - ((SerialNumber[1] & 0x00ff0000) >> 16), - ((SerialNumber[1] & 0x0000ff00) >> 8), - ((SerialNumber[1] & 0x000000ff) >> 0), - ((SerialNumber[2] & 0xff000000) >> 24), - ((SerialNumber[2] & 0x00ff0000) >> 16), - ((SerialNumber[2] & 0x0000ff00) >> 8), - ((SerialNumber[2] & 0x000000ff) >> 0), - ((SerialNumber[3] & 0xff000000) >> 24), - ((SerialNumber[3] & 0x00ff0000) >> 16), - ((SerialNumber[3] & 0x0000ff00) >> 8), - ((SerialNumber[3] & 0x000000ff) >> 0)); + snprintf(sn, sizeof(sn), + "%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x-%.2x%.2x", + ((SerialNumber[1] & 0xff000000) >> 24), + ((SerialNumber[1] & 0x00ff0000) >> 16), + ((SerialNumber[1] & 0x0000ff00) >> 8), + ((SerialNumber[1] & 0x000000ff) >> 0), + ((SerialNumber[2] & 0xff000000) >> 24), + ((SerialNumber[2] & 0x00ff0000) >> 16), + ((SerialNumber[2] & 0x0000ff00) >> 8), + ((SerialNumber[2] & 0x000000ff) >> 0), + ((SerialNumber[3] & 0xff000000) >> 24), + ((SerialNumber[3] & 0x00ff0000) >> 16), + ((SerialNumber[3] & 0x0000ff00) >> 8), + ((SerialNumber[3] & 0x000000ff) >> 0)); this->ChipID.SerialNumber = sn; return true; @@ -3749,24 +3752,24 @@ long long SystemInformationImplementation::GetProcMemoryAvailable( ResourceLimitType rlim; ierr = GetResourceLimit(RLIMIT_DATA, &rlim); if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) { - memAvail = min((long long)rlim.rlim_cur / 1024, memAvail); + memAvail = min(static_cast<long long>(rlim.rlim_cur) / 1024, memAvail); } ierr = GetResourceLimit(RLIMIT_AS, &rlim); if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) { - memAvail = min((long long)rlim.rlim_cur / 1024, memAvail); + memAvail = min(static_cast<long long>(rlim.rlim_cur) / 1024, memAvail); } #elif defined(__APPLE__) struct rlimit rlim; int ierr; ierr = getrlimit(RLIMIT_DATA, &rlim); if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) { - memAvail = min((long long)rlim.rlim_cur / 1024, memAvail); + memAvail = min(static_cast<long long>(rlim.rlim_cur) / 1024, memAvail); } ierr = getrlimit(RLIMIT_RSS, &rlim); if ((ierr == 0) && (rlim.rlim_cur != RLIM_INFINITY)) { - memAvail = min((long long)rlim.rlim_cur / 1024, memAvail); + memAvail = min(static_cast<long long>(rlim.rlim_cur) / 1024, memAvail); } #endif @@ -4068,7 +4071,7 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) // install ours struct sigaction sa; - sa.sa_sigaction = (SigAction)StacktraceSignalHandler; + sa.sa_sigaction = static_cast<SigAction>(StacktraceSignalHandler); sa.sa_flags = SA_SIGINFO | SA_RESETHAND; # ifdef SA_RESTART sa.sa_flags |= SA_RESTART; @@ -4564,7 +4567,8 @@ bool SystemInformationImplementation::ParseSysCtl() this->AvailablePhysicalMemory = 0; vm_statistics_data_t vmstat; mach_msg_type_number_t count = HOST_VM_INFO_COUNT; - if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, + if (host_statistics(mach_host_self(), HOST_VM_INFO, + reinterpret_cast<host_info_t>(&vmstat), &count) == KERN_SUCCESS) { err = kw_sysctlbyname_int64("hw.pagesize", &tempInt64); if (err == 0) { @@ -5395,8 +5399,8 @@ bool SystemInformationImplementation::QueryOSInformation() } } - sprintf(operatingSystem, "%ls (Build %ld)", osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); + snprintf(operatingSystem, sizeof(operatingSystem), "%ls (Build %ld)", + osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } else # endif // VER_NT_WORKSTATION @@ -5439,9 +5443,10 @@ bool SystemInformationImplementation::QueryOSInformation() // Display version, service pack (if any), and build number. if (osvi.dwMajorVersion <= 4) { // NB: NT 4.0 and earlier. - sprintf(operatingSystem, "version %ld.%ld %ls (Build %ld)", - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); + snprintf(operatingSystem, sizeof(operatingSystem), + "version %ld.%ld %ls (Build %ld)", osvi.dwMajorVersion, + osvi.dwMinorVersion, osvi.szCSDVersion, + osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { // Windows XP and .NET server. @@ -5467,8 +5472,8 @@ bool SystemInformationImplementation::QueryOSInformation() } } else { // Windows 2000 and everything else. - sprintf(operatingSystem, "%ls (Build %ld)", osvi.szCSDVersion, - osvi.dwBuildNumber & 0xFFFF); + snprintf(operatingSystem, sizeof(operatingSystem), "%ls (Build %ld)", + osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } break; |