From 18257156238daea60d65810f4d31e6d0930b46e9 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 27 Nov 2025 21:15:14 +0800 Subject: [PATCH] treewide: Use regexp to replace usage of unsetenv with os_unset_option. unsetenv\((.*)\); => os_unset_option($1); Signed-off-by: Yonggang Luo Reviewed-by: Antonio Ospite Part-of: --- src/amd/vulkan/tests/helpers.h | 2 +- .../vulkan-mapper/GfxStreamVulkanMapper.cpp | 2 +- src/util/tests/cache_test.cpp | 32 +++++++++---------- src/util/tests/xmlconfig.cpp | 20 ++++++------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/amd/vulkan/tests/helpers.h b/src/amd/vulkan/tests/helpers.h index 5fc2ffce8c0..22ac95b2769 100644 --- a/src/amd/vulkan/tests/helpers.h +++ b/src/amd/vulkan/tests/helpers.h @@ -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(); } diff --git a/src/gfxstream/guest/platform/kumquat/vulkan-mapper/GfxStreamVulkanMapper.cpp b/src/gfxstream/guest/platform/kumquat/vulkan-mapper/GfxStreamVulkanMapper.cpp index 685e59cf617..e3e8b6f4b7b 100644 --- a/src/gfxstream/guest/platform/kumquat/vulkan-mapper/GfxStreamVulkanMapper.cpp +++ b/src/gfxstream/guest/platform/kumquat/vulkan-mapper/GfxStreamVulkanMapper.cpp @@ -212,7 +212,7 @@ GfxStreamVulkanMapper* GfxStreamVulkanMapper::getInstance(std::optional(); if (!sVkMapper->initialize(*deviceIdOpt)) { diff --git a/src/util/tests/cache_test.cpp b/src/util/tests/cache_test.cpp index b0914b4a8a9..897d1e1fa89 100644 --- a/src/util/tests/cache_test.cpp +++ b/src/util/tests/cache_test.cpp @@ -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); diff --git a/src/util/tests/xmlconfig.cpp b/src/util/tests/xmlconfig.cpp index 8d081dc1895..49400a91554 100644 --- a/src/util/tests/xmlconfig.cpp +++ b/src/util/tests/xmlconfig.cpp @@ -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); }