mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: guard against running twice
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1189,9 +1189,29 @@ cmd_helper_cat128(void) {
|
|||||||
void
|
void
|
||||||
check_cmd(void (*fn)(void), const char *name)
|
check_cmd(void (*fn)(void), const char *name)
|
||||||
{
|
{
|
||||||
|
unsigned long i;
|
||||||
|
|
||||||
if (x->cmd[x->i].run != fn)
|
if (x->cmd[x->i].run != fn)
|
||||||
err(ECANCELED, "Running %s, but cmd %s is set",
|
err(ECANCELED, "Running %s, but cmd %s is set",
|
||||||
name, x->cmd[x->i].str);
|
name, x->cmd[x->i].str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In addition to making sure we ran
|
||||||
|
* the right command, we now disable
|
||||||
|
* all commands from running again
|
||||||
|
*
|
||||||
|
* the _nop function will just call
|
||||||
|
* err() immediately
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (i = 0; i < items(x->cmd); i++)
|
||||||
|
x->cmd[i].run = cmd_helper_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_helper_err(void)
|
||||||
|
{
|
||||||
|
err(ECANCELED, "Erroneously running command twice");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ void cat(unsigned long nff);
|
|||||||
void cat_buf(unsigned char *b);
|
void cat_buf(unsigned char *b);
|
||||||
|
|
||||||
void check_cmd(void (*fn)(void), const char *name);
|
void check_cmd(void (*fn)(void), const char *name);
|
||||||
|
void cmd_helper_err(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* After command processing, write
|
* After command processing, write
|
||||||
|
|||||||
Reference in New Issue
Block a user