Fix tests compiler warnings from bool conversions
authorCharles Giessen <charles@lunarg.com>
Sat, 19 Feb 2022 20:47:32 +0000 (13:47 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
While set_env_var did return a boolean, this caused odd performance warnings
on old compilers and wasn't being used by the tests.

tests/framework/test_util.cpp
tests/framework/test_util.h
tests/loader_phys_dev_inst_ext_tests.cpp

index e5666ba18445230c1b9e4705702f3cdaef43443e..5c1bbcf5712aa60910846ab83fa8beb144a1c13a 100644 (file)
@@ -57,15 +57,13 @@ void print_error_message(LSTATUS status, const char* function_name, std::string
     LocalFree(lpMsgBuf);
 }
 
-bool set_env_var(std::string const& name, std::string const& value) {
-    bool ret = SetEnvironmentVariableA(name.c_str(), value.c_str());
-    if (ret == false) {
+void set_env_var(std::string const& name, std::string const& value) {
+    BOOL ret = SetEnvironmentVariableA(name.c_str(), value.c_str());
+    if (ret == 0) {
         print_error_message(ERROR_SETENV_FAILED, "SetEnvironmentVariableA");
-        return true;
     }
-    return false;
 }
-bool remove_env_var(std::string const& name) { return SetEnvironmentVariableA(name.c_str(), nullptr); }
+void remove_env_var(std::string const& name) { SetEnvironmentVariableA(name.c_str(), nullptr); }
 #define ENV_VAR_BUFFER_SIZE 4096
 std::string get_env_var(std::string const& name, bool report_failure) {
     std::string value;
@@ -84,8 +82,8 @@ std::string get_env_var(std::string const& name, bool report_failure) {
 }
 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 
-bool set_env_var(std::string const& name, std::string const& value) { return setenv(name.c_str(), value.c_str(), 1); }
-bool remove_env_var(std::string const& name) { return unsetenv(name.c_str()); }
+void set_env_var(std::string const& name, std::string const& value) { setenv(name.c_str(), value.c_str(), 1); }
+void remove_env_var(std::string const& name) { unsetenv(name.c_str()); }
 std::string get_env_var(std::string const& name, bool report_failure) {
     char* ret = getenv(name.c_str());
     if (ret == nullptr) {
index ccf605bcc505904a91d56eaeb6280b50da67ccfa..f8dd6ba7497846c1c09e10421623fc5595434cbe 100644 (file)
  */
 
 #if defined(WIN32)
-bool set_env_var(std::string const& name, std::string const& value);
-bool remove_env_var(std::string const& name);
+void set_env_var(std::string const& name, std::string const& value);
+void remove_env_var(std::string const& name);
 #define ENV_VAR_BUFFER_SIZE 4096
 std::string get_env_var(std::string const& name, bool report_failure = true);
 
 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
-bool set_env_var(std::string const& name, std::string const& value);
-bool remove_env_var(std::string const& name);
+void set_env_var(std::string const& name, std::string const& value);
+void remove_env_var(std::string const& name);
 std::string get_env_var(std::string const& name, bool report_failure = true);
 #endif
 
index 4e836de410817e0b01e0ec3273bb8bf2fd4c88b0..ea60bc6be807b95ac7fb7c298b0605a45e76c714 100644 (file)
@@ -1425,7 +1425,7 @@ static uint32_t FillInRandomQueueFamilyData(std::vector<MockQueueFamilyPropertie
         props[i].properties.minImageTransferGranularity.width = (rand() % 30) + 1;
         props[i].properties.minImageTransferGranularity.height = (rand() % 30) + 1;
         props[i].properties.minImageTransferGranularity.depth = (rand() % 30) + 1;
-        props[i].support_present = (rand() % 2);
+        props[i].support_present = rand() % 2 == 0;
     }
     return static_cast<uint32_t>(props.size());
 }