payloads/nvramcui/nvramcui.c: Reformat code
Change-Id: If5b4ae7d9f9046e56ca098c0469b503130bc8707 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/61955 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@tutanota.com>
This commit is contained in:
parent
3fd719755d
commit
ae2c045733
|
@ -49,22 +49,19 @@ static void render_form(FORM *form)
|
||||||
wclear(der);
|
wclear(der);
|
||||||
wrefresh(der);
|
wrefresh(der);
|
||||||
delwin(der);
|
delwin(der);
|
||||||
copywin(inner_w, w, line, 0, 1, 1,
|
copywin(inner_w, w, line, 0, 1, 1, min(numlines, getmaxy(inner_w) - line), 68, 0);
|
||||||
min(numlines, getmaxy(inner_w) - line), 68, 0);
|
|
||||||
wmove(w, y + 1 - line, x + 1);
|
wmove(w, y + 1 - line, x + 1);
|
||||||
wrefresh(w);
|
wrefresh(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine number of options, and maximum option name length */
|
/* determine number of options, and maximum option name length */
|
||||||
static int count_cmos_options(struct cb_cmos_entries *option, int *numopts,
|
static int count_cmos_options(struct cb_cmos_entries *option, int *numopts, int *maxlength)
|
||||||
int *maxlength)
|
|
||||||
{
|
{
|
||||||
int n_opts = 0;
|
int n_opts = 0;
|
||||||
int max_l = 0;
|
int max_l = 0;
|
||||||
|
|
||||||
while (option) {
|
while (option) {
|
||||||
if ((option->config != 'r') &&
|
if ((option->config != 'r') && (strcmp("check_sum", (char *)option->name) != 0)) {
|
||||||
(strcmp("check_sum", (char *)option->name) != 0)) {
|
|
||||||
max_l = max(max_l, strlen((char *)option->name));
|
max_l = max(max_l, strlen((char *)option->name));
|
||||||
n_opts++;
|
n_opts++;
|
||||||
}
|
}
|
||||||
|
@ -81,12 +78,11 @@ static int count_cmos_options(struct cb_cmos_entries *option, int *numopts,
|
||||||
*maxlength = max_l;
|
*maxlength = max_l;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* walk over options, fetch details */
|
/* walk over options, fetch details */
|
||||||
static void cmos_walk_options(struct cb_cmos_option_table *opttbl,
|
static void cmos_walk_options(struct cb_cmos_option_table *opttbl, FIELD **fields, int numopts,
|
||||||
FIELD **fields, int numopts, int maxlength)
|
int maxlength)
|
||||||
{
|
{
|
||||||
struct cb_cmos_entries *option = first_cmos_entry(opttbl);
|
struct cb_cmos_entries *option = first_cmos_entry(opttbl);
|
||||||
int i;
|
int i;
|
||||||
|
@ -96,16 +92,13 @@ static void cmos_walk_options(struct cb_cmos_option_table *opttbl,
|
||||||
(strcmp("check_sum", (char *)option->name) == 0)) {
|
(strcmp("check_sum", (char *)option->name) == 0)) {
|
||||||
option = next_cmos_entry(option);
|
option = next_cmos_entry(option);
|
||||||
}
|
}
|
||||||
fields[2 * i] =
|
fields[2 * i] = new_field(1, strlen((char *)option->name), i * 2, 1, 0, 0);
|
||||||
new_field(1, strlen((char *)option->name), i * 2, 1, 0, 0);
|
|
||||||
set_field_buffer(fields[2 * i], 0, (char *)option->name);
|
set_field_buffer(fields[2 * i], 0, (char *)option->name);
|
||||||
field_opts_off(fields[2 * i], O_ACTIVE);
|
field_opts_off(fields[2 * i], O_ACTIVE);
|
||||||
|
|
||||||
fields[2 * i + 1] =
|
fields[2 * i + 1] = new_field(1, 40, i * 2, maxlength + 2, 0, 0);
|
||||||
new_field(1, 40, i * 2, maxlength + 2, 0, 0);
|
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int fail =
|
int fail = get_option_as_string(use_nvram, opttbl, &buf, (char *)option->name);
|
||||||
get_option_as_string(use_nvram, opttbl, &buf, (char *)option->name);
|
|
||||||
switch (option->config) {
|
switch (option->config) {
|
||||||
case 'h': {
|
case 'h': {
|
||||||
set_field_type(fields[2 * i + 1], TYPE_INTEGER, 0, 0,
|
set_field_type(fields[2 * i + 1], TYPE_INTEGER, 0, 0,
|
||||||
|
@ -130,8 +123,7 @@ static void cmos_walk_options(struct cb_cmos_option_table *opttbl,
|
||||||
|
|
||||||
while (cmos_enum) {
|
while (cmos_enum) {
|
||||||
numvals++;
|
numvals++;
|
||||||
cmos_enum = next_cmos_enum_of_id(
|
cmos_enum = next_cmos_enum_of_id(cmos_enum, option->config_id);
|
||||||
cmos_enum, option->config_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char **values = malloc(sizeof(char *) * (numvals + 1));
|
char **values = malloc(sizeof(char *) * (numvals + 1));
|
||||||
|
@ -142,13 +134,11 @@ static void cmos_walk_options(struct cb_cmos_option_table *opttbl,
|
||||||
while (cmos_enum) {
|
while (cmos_enum) {
|
||||||
values[cnt] = (char *)cmos_enum->text;
|
values[cnt] = (char *)cmos_enum->text;
|
||||||
cnt++;
|
cnt++;
|
||||||
cmos_enum = next_cmos_enum_of_id(
|
cmos_enum = next_cmos_enum_of_id(cmos_enum, option->config_id);
|
||||||
cmos_enum, option->config_id);
|
|
||||||
}
|
}
|
||||||
values[cnt] = NULL;
|
values[cnt] = NULL;
|
||||||
field_opts_off(fields[2 * i + 1], O_EDIT);
|
field_opts_off(fields[2 * i + 1], O_EDIT);
|
||||||
set_field_type(fields[2 * i + 1], TYPE_ENUM, values, 1,
|
set_field_type(fields[2 * i + 1], TYPE_ENUM, values, 1, 1);
|
||||||
1);
|
|
||||||
free(values); // copied by set_field_type
|
free(values); // copied by set_field_type
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +151,7 @@ static void cmos_walk_options(struct cb_cmos_option_table *opttbl,
|
||||||
// underline is non-trivial on VGA text
|
// underline is non-trivial on VGA text
|
||||||
set_field_back(fields[2 * i + 1], A_UNDERLINE);
|
set_field_back(fields[2 * i + 1], A_UNDERLINE);
|
||||||
#endif
|
#endif
|
||||||
field_opts_off(fields[2 * i + 1],
|
field_opts_off(fields[2 * i + 1], O_BLANK | O_AUTOSKIP | O_NULLOK);
|
||||||
O_BLANK | O_AUTOSKIP | O_NULLOK);
|
|
||||||
|
|
||||||
option = next_cmos_entry(option);
|
option = next_cmos_entry(option);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue