mirror of
https://github.com/upa/mscp.git
synced 2026-02-21 14:44:48 +08:00
cleanup error message handling
The top-level funtion in a thread should print errors using priv_get_err(), while lower-level functions should set error messages using priv_set_err() except that error mesesages should be printed immediately, e.g., under walk_src_path().
This commit is contained in:
@@ -18,20 +18,15 @@ const char *strerrno(void)
|
||||
}
|
||||
|
||||
#define PRIV_ERR_BUFSIZ (1 << 12)
|
||||
static char priv_err_buf[PRIV_ERR_BUFSIZ], internal[PRIV_ERR_BUFSIZ];
|
||||
__thread char priv_err_buf[PRIV_ERR_BUFSIZ], internal[PRIV_ERR_BUFSIZ];
|
||||
|
||||
void priv_set_err(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
/* arguments may contains priv_err_buf. Thus, we build the
|
||||
* string in a internal buffer, and then copy it to
|
||||
* priv_err_buf. */
|
||||
memset(internal, 0, sizeof(internal));
|
||||
va_start(va, fmt);
|
||||
vsnprintf(internal, sizeof(internal), fmt, va);
|
||||
va_end(va);
|
||||
|
||||
snprintf(priv_err_buf, sizeof(priv_err_buf), "%s", internal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user