treewide: Use regexp to replace usage of unsetenv with os_unset_option.

unsetenv\((.*)\);
=>
os_unset_option($1);

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Antonio Ospite <antonio.ospite@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38640>
This commit is contained in:
Yonggang Luo
2025-11-27 21:15:14 +08:00
committed by Marge Bot
parent d277dfdd76
commit 1825715623
4 changed files with 28 additions and 28 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ public:
void unset_envvars()
{
for (auto &envvar : envvars)
unsetenv(envvar.first.c_str());
os_unset_option(envvar.first.c_str());
envvars.clear();
}
@@ -212,7 +212,7 @@ GfxStreamVulkanMapper* GfxStreamVulkanMapper::getInstance(std::optional<DeviceId
// HACK: Need equivalents on Windows
#if DETECT_OS_LINUX
unsetenv(VK_DRIVER_FILES);
os_unset_option(VK_DRIVER_FILES);
#endif
sVkMapper = std::make_unique<GfxStreamVulkanMapper>();
if (!sVkMapper->initialize(*deviceIdOpt)) {
+16 -16
View File
@@ -192,13 +192,13 @@ test_disk_cache_create(void *mem_ctx, const char *cache_dir_name,
EXPECT_EQ(cache->type, DISK_CACHE_NONE) << "disk_cache_create with MESA_SHADER_CACHE_DISABLE set";
disk_cache_destroy(cache);
unsetenv("MESA_SHADER_CACHE_DISABLE");
os_unset_option("MESA_SHADER_CACHE_DISABLE");
#ifdef SHADER_CACHE_DISABLE_BY_DEFAULT
/* With SHADER_CACHE_DISABLE_BY_DEFAULT, ensure that with
* MESA_SHADER_CACHE_DISABLE set to nothing, disk_cache_create returns NO-OP cache.
*/
unsetenv("MESA_SHADER_CACHE_DISABLE");
os_unset_option("MESA_SHADER_CACHE_DISABLE");
cache = disk_cache_create("test", driver_id, 0);
EXPECT_EQ(cache->type, DISK_CACHE_NONE)
<< "disk_cache_create with MESA_SHADER_CACHE_DISABLE unset "
@@ -212,8 +212,8 @@ test_disk_cache_create(void *mem_ctx, const char *cache_dir_name,
/* For the first real disk_cache_create() clear these environment
* variables to test creation of cache in home directory.
*/
unsetenv("MESA_SHADER_CACHE_DIR");
unsetenv("XDG_CACHE_HOME");
os_unset_option("MESA_SHADER_CACHE_DIR");
os_unset_option("XDG_CACHE_HOME");
cache = disk_cache_create("test", driver_id, 0);
EXPECT_NE(cache, nullptr) << "disk_cache_create with no environment variables";
@@ -849,7 +849,7 @@ TEST_F(Cache, Database)
test_put_big_sized_entry_to_empty_cache(driver_id);
setenv("MESA_DISK_CACHE_DATABASE", "false", 1);
unsetenv("MESA_DISK_CACHE_DATABASE_NUM_PARTS");
os_unset_option("MESA_DISK_CACHE_DATABASE_NUM_PARTS");
err = rmrf_local(CACHE_TEST_TMP);
EXPECT_EQ(err, 0) << "Removing " CACHE_TEST_TMP " again";
@@ -1054,7 +1054,7 @@ TEST_F(Cache, Combined)
/* Disable read-only cache. */
setenv("MESA_DISK_CACHE_COMBINE_RW_WITH_RO_FOZ", "false", 1);
unsetenv("MESA_DISK_CACHE_READ_ONLY_FOZ_DBS");
os_unset_option("MESA_DISK_CACHE_READ_ONLY_FOZ_DBS");
/* Create multi-file cache with disabled retrieval from the
* read-only cache. */
@@ -1075,9 +1075,9 @@ TEST_F(Cache, Combined)
disk_cache_destroy(cache_multifile);
unsetenv("MESA_DISK_CACHE_SINGLE_FILE");
unsetenv("MESA_DISK_CACHE_MULTI_FILE");
unsetenv("MESA_DISK_CACHE_DATABASE");
os_unset_option("MESA_DISK_CACHE_SINGLE_FILE");
os_unset_option("MESA_DISK_CACHE_MULTI_FILE");
os_unset_option("MESA_DISK_CACHE_DATABASE");
int err = rmrf_local(CACHE_TEST_TMP);
EXPECT_EQ(err, 0) << "Removing " CACHE_TEST_TMP " again";
@@ -1241,8 +1241,8 @@ TEST_F(Cache, List)
int err = rmrf_local(CACHE_TEST_TMP);
EXPECT_EQ(err, 0) << "Removing " CACHE_TEST_TMP " again";
unsetenv("MESA_DISK_CACHE_SINGLE_FILE");
unsetenv("MESA_DISK_CACHE_READ_ONLY_FOZ_DBS_DYNAMIC_LIST");
os_unset_option("MESA_DISK_CACHE_SINGLE_FILE");
os_unset_option("MESA_DISK_CACHE_READ_ONLY_FOZ_DBS_DYNAMIC_LIST");
#endif /* FOZ_DB_UTIL_DYNAMIC_LIST */
#endif /* ENABLE_SHADER_CACHE */
}
@@ -1342,8 +1342,8 @@ TEST_F(Cache, DatabaseMultipartEviction)
test_multipart_eviction(driver_id);
unsetenv("MESA_DISK_CACHE_DATABASE_NUM_PARTS");
unsetenv("MESA_DISK_CACHE_DATABASE");
os_unset_option("MESA_DISK_CACHE_DATABASE_NUM_PARTS");
os_unset_option("MESA_DISK_CACHE_DATABASE");
int err = rmrf_local(CACHE_TEST_TMP);
EXPECT_EQ(err, 0) << "Removing " CACHE_TEST_TMP " again";
@@ -1435,7 +1435,7 @@ TEST_F(Cache, DoNotDeleteNewCache)
struct stat st;
EXPECT_EQ(stat(cache_dir_name, &st), 0);
unsetenv("MESA_SHADER_CACHE_DIR");
os_unset_option("MESA_SHADER_CACHE_DIR");
rmdir(cache_dir_name);
rmdir(dir_name);
#endif
@@ -1472,7 +1472,7 @@ TEST_F(Cache, DoNotDeleteCacheWithNewMarker)
struct stat st;
EXPECT_EQ(stat(cache_dir_name, &st), 0);
unsetenv("MESA_SHADER_CACHE_DIR");
os_unset_option("MESA_SHADER_CACHE_DIR");
unlink(file_name);
rmdir(cache_dir_name);
rmdir(dir_name);
@@ -1515,7 +1515,7 @@ TEST_F(Cache, DeleteOldCache)
EXPECT_NE(stat(cache_dir_name, &st), 0);
EXPECT_EQ(errno, ENOENT);
unsetenv("MESA_SHADER_CACHE_DIR");
os_unset_option("MESA_SHADER_CACHE_DIR");
unlink(file_name);
rmdir(cache_dir_name);
rmdir(dir_name);
+10 -10
View File
@@ -45,15 +45,15 @@ xmlconfig_test::xmlconfig_test()
/* Unset variables from the envrionment to prevent user settings from
* impacting the tests.
*/
unsetenv("glsl_zero_init");
unsetenv("always_have_depth_buffer");
unsetenv("opt");
unsetenv("vblank_mode");
unsetenv("not_present");
unsetenv("mesa_b_option");
unsetenv("mesa_s_option");
unsetenv("mest_test_unknown_option");
unsetenv("mest_drirc_option");
os_unset_option("glsl_zero_init");
os_unset_option("always_have_depth_buffer");
os_unset_option("opt");
os_unset_option("vblank_mode");
os_unset_option("not_present");
os_unset_option("mesa_b_option");
os_unset_option("mesa_s_option");
os_unset_option("mest_test_unknown_option");
os_unset_option("mest_drirc_option");
options = {};
}
@@ -251,7 +251,7 @@ TEST_F(xmlconfig_test, drirc_env_override)
NULL, 0);
/* env var takes precedence over config files */
EXPECT_EQ(driQueryOptioni(&cache, "mesa_drirc_option"), 7);
unsetenv("mesa_drirc_option");
os_unset_option("mesa_drirc_option");
driDestroyOptionCache(&cache);
}