Skip to content

Commit

Permalink
drop error_notty()
Browse files Browse the repository at this point in the history
  • Loading branch information
garlick committed Feb 5, 2024
1 parent b96e1af commit 792a626
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
24 changes: 4 additions & 20 deletions src/libcommon/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "error.h"

static char *err_prog = NULL; /* basename of calling program */
static bool err_ttyvalid = true; /* use stderr until told otherwise */

#define ERROR_BUFLEN 1024

Expand All @@ -38,14 +37,6 @@ void err_init(char *prog)
err_prog = p ? p + 1 : prog;
}

/*
* Accessor function for syslog_enable.
*/
void err_notty(void)
{
err_ttyvalid = false;
}

/* helper for err, err_exit */
static void _verr(bool errno_valid, const char *fmt, va_list ap)
{
Expand All @@ -55,17 +46,10 @@ static void _verr(bool errno_valid, const char *fmt, va_list ap)
assert(err_prog != NULL);

vsnprintf(buf, ERROR_BUFLEN, fmt, ap); /* overflow ignored on purpose */
if (errno_valid) {
if (err_ttyvalid)
fprintf(stderr, "%s: %s: %s\n", err_prog, buf, strerror(er));
else
syslog(LOG_ERR, "%s: %s", buf, strerror(er));
} else {
if (err_ttyvalid)
fprintf(stderr, "%s: %s\n", err_prog, buf);
else
syslog(LOG_ERR, "%s", buf);
}
if (errno_valid)
fprintf(stderr, "%s: %s: %s\n", err_prog, buf, strerror(er));
else
fprintf(stderr, "%s: %s\n", err_prog, buf);
}

/*
Expand Down
1 change: 0 additions & 1 deletion src/libcommon/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <stdarg.h>

void err_init(char *prog);
void err_notty(void);
void err_exit(bool errno_valid, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
void err(bool errno_valid, const char *fmt, ...)
Expand Down

0 comments on commit 792a626

Please sign in to comment.