mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user