summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/include/common.h
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-28 06:53:37 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-28 06:53:37 +0000
commit0f1a22174fc7c6a0767617974640d521074174d5 (patch)
tree5d13587d08a95332518b3191b7440424f0f190c6 /util/libreboot-utils/include/common.h
parent55f0e6ac8e540cea24af64070bfc49a032729511 (diff)
libreboot-utils: unified error handling
i now use a singleton hook function per program: nvmutil, mkhtemp and lottery call this at the startup of your program: (void) errhook(exit_cleanup); then provide that function. make it static, so that each program has its own version. if you're writing a program that handles lots of files for example, and you want to do certain cleanup on exit (including error exit), this can be quite useful. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/include/common.h')
-rw-r--r--util/libreboot-utils/include/common.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/util/libreboot-utils/include/common.h b/util/libreboot-utils/include/common.h
index 652b8c08..9ec8a0e3 100644
--- a/util/libreboot-utils/include/common.h
+++ b/util/libreboot-utils/include/common.h
@@ -225,10 +225,12 @@ int fchmod(int fd, mode_t mode);
/* command table
*/
+typedef void (*func_t)(void);
+
struct commands {
size_t chk;
char *str;
- void (*run)(void);
+ func_t run;
int argc;
unsigned char arg_part;
unsigned char chksum_read;
@@ -488,12 +490,11 @@ int try_err(int loop_err, int errval);
*/
void usage(void);
-void err_no_cleanup(int stfu, int nvm_errval, const char *msg, ...);
-void b0rk(int nvm_errval, const char *msg, ...);
-int exit_cleanup(void);
+void err_exit(int nvm_errval, const char *msg, ...);
+func_t errhook(func_t ptr); /* hook function for cleanup on err */
const char *getnvmprogname(void);
-
-void err_mkhtemp(int stfu, int errval, const char *msg, ...);
+void no_op(void);
+void err_mkhtemp(int errval, const char *msg, ...);
/* libc hardening
*/