]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Defined format specifier `%M' which behaves as `%m', but takes the
authorMartin Mares <mj@ucw.cz>
Tue, 2 May 2000 16:10:04 +0000 (16:10 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 2 May 2000 16:10:04 +0000 (16:10 +0000)
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.

lib/printf.c
proto/bgp/bgp.c
proto/rip/rip.c

index 64fcf728488d8b235d32ded796632b41fb0bd05c..a668aeafb579060f95e723953f96903312123da3 100644 (file)
@@ -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)
index 4a68f04b24934713d239e0ec662c31d10271939f..41081f265d92541f308cd5975124e94963a16973 100644 (file)
@@ -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:
index 2826de7f32c75e1ee85a6dceaef6840b571543b9..f9a4483536ddf571cb89dbfa89d8bcf7191bd44c 100644 (file)
@@ -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