[ntp:hackers] mvsnprintf() and msnprintf() handle %m like msyslog()

Dave Hart hart at ntp.org
Fri Dec 17 03:59:15 UTC 2010

libntp now sports a slightly decomposed msyslog(), implemented in
terms of a new mvsnprintf() which handles substituting %m in the
format with strerror(errno) before calling vsnprintf().  There is also
a msnprintf() clone of snprintf(), also using mvsnprintf() internally.

if (-1 == ...) {
    msnprintf(strbuf, sizeof(strbuf), "%s: you figure it out: %m",
    record_clock_stats(&peer->sin, strbuf);
    DPRINTF(1, ("%s\n", strbuf));
    msyslog(LOG_ERR, "%s\n", strbuf);

That's a bit extreme.  BTW, msyslog() now sends its output to
stdout/stderr as well as the [sys]log, if debug > 0 or the program
requests it, as sntp does and other utils probably should.

Dave Hart

More information about the hackers mailing list