diff options
author | Martin Mares <mj@ucw.cz> | 2000-05-02 18:10:04 +0200 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-05-02 18:10:04 +0200 |
commit | 53943a002265d8e2b6a887eaa497a01840675693 (patch) | |
tree | 66897b24d24a3840d880c11f89a208981c23bf9e | |
parent | 85368cd4b7244535f6ce56a27f6d22ddfa2bf4e6 (diff) | |
download | bird-53943a002265d8e2b6a887eaa497a01840675693.tar bird-53943a002265d8e2b6a887eaa497a01840675693.zip |
Defined format specifier `%M' which behaves as `%m', but takes the
error code as an argument.
Use it in socket hooks where we really shouldn't rely on errno containing
the right value or even existing.
-rw-r--r-- | lib/printf.c | 3 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 5 | ||||
-rw-r--r-- | proto/rip/rip.c | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/printf.c b/lib/printf.c index 64fcf72..a668aea 100644 --- a/lib/printf.c +++ b/lib/printf.c @@ -198,6 +198,9 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args) case 'm': s = strerror(errno); goto str; + case 'M': + s = strerror(va_arg(args, int)); + goto str; case 's': s = va_arg(args, char *); if (!s) diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 4a68f04..41081f2 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -158,7 +158,10 @@ bgp_sock_err(sock *sk, int err) struct bgp_conn *conn = sk->data; struct bgp_proto *p = conn->bgp; - BGP_TRACE(D_EVENTS, "Connection closed (socket error %d)", err); + if (err) + BGP_TRACE(D_EVENTS, "Connection lost (%M)", err); + else + BGP_TRACE(D_EVENTS, "Connection closed"); switch (conn->state) { case BS_CONNECT: diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 2826de7..f9a4483 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -75,7 +75,7 @@ rip_tx_err( sock *s, int err ) { struct rip_connection *c = s->data; struct proto *p = c->proto; - log( L_ERR "Unexpected error at rip transmit: %m" ); + log( L_ERR "Unexpected error at rip transmit: %M", err ); } static int |