Use getenv_is_true() in init_static_kenv()

A small example of how these functions can be used to simplify checks of
this nature.

Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26271
This commit is contained in:
Mitchell Horne 2020-09-21 15:44:23 +00:00
parent e32d47f32d
commit 624a7e1f4f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365947

View File

@ -253,7 +253,6 @@ sys_kenv(td, uap)
void void
init_static_kenv(char *buf, size_t len) init_static_kenv(char *buf, size_t len)
{ {
char *eval;
KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized")); KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
/* /*
@ -301,20 +300,17 @@ init_static_kenv(char *buf, size_t len)
* if the static environment has disabled the loader environment. * if the static environment has disabled the loader environment.
*/ */
kern_envp = static_env; kern_envp = static_env;
eval = kern_getenv("loader_env.disabled"); if (!getenv_is_true("loader_env.disabled")) {
if (eval == NULL || strcmp(eval, "1") != 0) {
md_envp = buf; md_envp = buf;
md_env_len = len; md_env_len = len;
md_env_pos = 0; md_env_pos = 0;
eval = kern_getenv("static_env.disabled"); if (getenv_is_true("static_env.disabled")) {
if (eval != NULL && strcmp(eval, "1") == 0) {
kern_envp[0] = '\0'; kern_envp[0] = '\0';
kern_envp[1] = '\0'; kern_envp[1] = '\0';
} }
} }
eval = kern_getenv("static_hints.disabled"); if (getenv_is_true("static_hints.disabled")) {
if (eval != NULL && strcmp(eval, "1") == 0) {
static_hints[0] = '\0'; static_hints[0] = '\0';
static_hints[1] = '\0'; static_hints[1] = '\0';
} }