Florian Obser(flor...@openbsd.org) on 2017.07.11 19:27:54 +0000: > from bgpd. > > OK?
ok > benno, is this the right way to do it? I kinda lost track on your > log merging efforts... yes thats ok. I neglected rtadvd a bit. > diff --git log.c log.c > index 357ef35b79c..08afcebcac0 100644 > --- log.c > +++ log.c > @@ -135,26 +135,44 @@ log_debug(const char *emsg, ...) > } > } > > -void > -fatal(const char *emsg) > +static void > +vfatalc(int code, const char *emsg, va_list ap) > { > - if (emsg == NULL) > - logit(LOG_CRIT, "fatal in %s: %s", log_procname, > - strerror(errno)); > + static char s[BUFSIZ]; > + const char *sep; > + > + if (emsg != NULL) { > + (void)vsnprintf(s, sizeof(s), emsg, ap); > + sep = ": "; > + } else { > + s[0] = '\0'; > + sep = ""; > + } > + if (code) > + logit(LOG_CRIT, "fatal in %s: %s%s%s", > + log_procname, s, sep, strerror(code)); > else > - if (errno) > - logit(LOG_CRIT, "fatal in %s: %s: %s", > - log_procname, emsg, strerror(errno)); > - else > - logit(LOG_CRIT, "fatal in %s: %s", > - log_procname, emsg); > + logit(LOG_CRIT, "fatal in %s%s%s", log_procname, sep, s); > +} > + > +void > +fatal(const char *emsg, ...) > +{ > + va_list ap; > > + va_start(ap, emsg); > + vfatalc(errno, emsg, ap); > + va_end(ap); > exit(1); > } > > void > -fatalx(const char *emsg) > +fatalx(const char *emsg, ...) > { > - errno = 0; > - fatal(emsg); > + va_list ap; > + > + va_start(ap, emsg); > + vfatalc(0, emsg, ap); > + va_end(ap); > + exit(1); > } > diff --git log.h log.h > index 479c21f34ed..660c3e89735 100644 > --- log.h > +++ log.h > @@ -37,9 +37,9 @@ void log_info(const char *, ...) > __attribute__((__format__ (printf, 1, 2))); > void log_debug(const char *, ...) > __attribute__((__format__ (printf, 1, 2))); > -void fatal(const char *) __dead > - __attribute__((__format__ (printf, 1, 0))); > -void fatalx(const char *) __dead > - __attribute__((__format__ (printf, 1, 0))); > +__dead void fatal(const char *, ...) > + __attribute__((__format__ (printf, 1, 2))); > +__dead void fatalx(const char *, ...) > + __attribute__((__format__ (printf, 1, 2))); > > #endif /* LOG_H */ > > -- > I'm not entirely sure you are real. >