mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 07:20:10 +01:00
util,vulkan,llvmpipe: Use os_get_option_dup instead getenv
Use os_get_option_dup in src/gallium/auxiliary/gallivm/lp_bld_misc.cpp src/util/tests/process_test.c because the string is going to be modified. Use os_get_option_dup in device_select_layer.c are because the string is being assigned to a struct member (protection for the future), and also because the consecutive usages (protection for the present). Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Acked-by: Antonio Ospite <antonio.ospite@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38128>
This commit is contained in:
parent
a8e8422170
commit
2eee9b79e8
3 changed files with 6 additions and 7 deletions
|
|
@ -119,7 +119,7 @@ void lp_bld_init_native_targets()
|
|||
llvm::InitializeNativeTargetDisassembler();
|
||||
#if MESA_DEBUG
|
||||
{
|
||||
char *env_llc_options = getenv("GALLIVM_LLC_OPTIONS");
|
||||
char *env_llc_options = os_get_option_dup("GALLIVM_LLC_OPTIONS");
|
||||
if (env_llc_options) {
|
||||
char *option;
|
||||
char *options[64] = {(char *) "llc"}; // Warning without cast
|
||||
|
|
@ -135,6 +135,7 @@ void lp_bld_init_native_targets()
|
|||
}
|
||||
LLVMParseCommandLineOptions(n + 1, options, NULL);
|
||||
}
|
||||
free(env_llc_options);
|
||||
}
|
||||
#endif
|
||||
lp_run_atexit_for_destructors();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
/* A collection of unit tests for u_process.c */
|
||||
|
||||
#include "util/detect_os.h"
|
||||
#include "util/os_misc.h"
|
||||
#include "util/u_process.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -88,13 +89,12 @@ test_util_get_process_exec_path (void)
|
|||
return;
|
||||
}
|
||||
posixify_path(path);
|
||||
char* build_path = getenv("BUILD_FULL_PATH");
|
||||
char* build_path = os_get_option_dup("BUILD_FULL_PATH");
|
||||
if (!build_path) {
|
||||
fprintf(stderr, "BUILD_FULL_PATH environment variable should be set\n");
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
build_path = strdup(build_path);
|
||||
posixify_path(build_path);
|
||||
#ifdef __CYGWIN__
|
||||
int i = strlen(build_path) - 4;
|
||||
|
|
|
|||
|
|
@ -157,12 +157,10 @@ device_select_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
|
||||
info->debug = debug_get_bool_option("MESA_VK_DEVICE_SELECT_DEBUG", false) ||
|
||||
debug_get_bool_option("DRI_PRIME_DEBUG", false);
|
||||
info->selection = getenv("MESA_VK_DEVICE_SELECT");
|
||||
info->dri_prime = getenv("DRI_PRIME");
|
||||
info->selection = os_get_option_dup("MESA_VK_DEVICE_SELECT");
|
||||
info->dri_prime = os_get_option_dup("DRI_PRIME");
|
||||
info->force_default_device =
|
||||
debug_get_bool_option("MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE", false);
|
||||
info->selection = info->selection ? strdup(info->selection) : NULL;
|
||||
info->dri_prime = info->dri_prime ? strdup(info->dri_prime) : NULL;
|
||||
|
||||
#define DEVSEL_GET_CB(func) \
|
||||
info->func = (PFN_vk##func)info->GetInstanceProcAddr(*pInstance, "vk" #func)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue