From 3db6d179e8ec408f3d37185dd836a631def4b959 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sat, 9 Jun 2018 15:52:29 +0000 Subject: [PATCH] stand: One more trivial consolidation (setting environment from howto) --- stand/common/boot.c | 10 ++++++++++ stand/common/bootstrap.h | 1 + stand/efi/loader/main.c | 6 ++---- stand/i386/libi386/bootinfo.c | 6 +----- stand/userboot/userboot/bootinfo.c | 6 +----- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/stand/common/boot.c b/stand/common/boot.c index 608c55da00b8..2781778b4622 100644 --- a/stand/common/boot.c +++ b/stand/common/boot.c @@ -174,6 +174,16 @@ bootenv_flags() return (howto); } +void +bootenv_set(int howto) +{ + int i; + + for (i = 0; howto_names[i].ev != NULL; i++) + if (howto & howto_names[i].mask) + setenv(howto_names[i].ev, "YES", 1); +} + static int autoboot(int timeout, char *prompt) { diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index f265bbafacc2..278b3ed6aebd 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -64,6 +64,7 @@ int parse(int *argc, char ***argv, const char *str); void autoboot_maybe(void); int getrootmount(char *rootdev); int bootenv_flags(void); +void bootenv_set(int); /* misc.c */ char *unargv(int argc, char *argv[]); diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 09ac1e0ccf1d..ab310bbf0e29 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -549,9 +548,8 @@ main(int argc, CHAR16 *argv[]) } } } - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + + bootenv_set(howto); /* * XXX we need fallback to this stuff after looking at the ConIn, ConOut and ConErr variables diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c index 21300f698e1e..0b69a9a21ec9 100644 --- a/stand/i386/libi386/bootinfo.c +++ b/stand/i386/libi386/bootinfo.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include "bootstrap.h" #include "libi386.h" #include "btxv86.h" @@ -130,11 +129,8 @@ bi_getboothowto(char *kargs) void bi_setboothowto(int howto) { - int i; - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + bootenv_set(howto); } /* diff --git a/stand/userboot/userboot/bootinfo.c b/stand/userboot/userboot/bootinfo.c index 6985c7716608..29a94af1752f 100644 --- a/stand/userboot/userboot/bootinfo.c +++ b/stand/userboot/userboot/bootinfo.c @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include "bootstrap.h" #include "libuserboot.h" @@ -131,11 +130,8 @@ bi_getboothowto(char *kargs) void bi_setboothowto(int howto) { - int i; - for (i = 0; howto_names[i].ev != NULL; i++) - if (howto & howto_names[i].mask) - setenv(howto_names[i].ev, "YES", 1); + bootenv_set(howto); } /*