[PATCH 7/8] comm: Introduce comm_addr_to_string
Ian Jackson
ijackson at chiark.greenend.org.uk
Wed May 14 21:00:27 BST 2014
Convenience function for calling addr_to_string. Use it where
appropriate.
No functional change.
Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
secnet.h | 5 +++++
site.c | 4 ++--
util.c | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/secnet.h b/secnet.h
index 58624a7..6fc52a0 100644
--- a/secnet.h
+++ b/secnet.h
@@ -341,6 +341,11 @@ struct comm_if {
comm_addr_to_string_fn *addr_to_string;
};
+static inline const char *comm_addr_to_string(const struct comm_addr *ca)
+{
+ return ca->comm->addr_to_string(ca->comm->st, ca);
+}
+
/* LOG interface */
#define LOG_MESSAGE_BUFLEN 1023
diff --git a/site.c b/site.c
index 7156149..6fd4afb 100644
--- a/site.c
+++ b/site.c
@@ -1933,14 +1933,14 @@ static void transport_peers_debug(struct site *st, transport_peers *dst,
i++, (argp+=stride?stride:sizeof(*args))) {
const struct comm_addr *ca=(void*)argp;
slog(st, LOG_PEER_ADDRS, " args: addrs[%d]=%s",
- i, ca->comm->addr_to_string(ca->comm->st,ca));
+ i, comm_addr_to_string(ca));
}
for (i=0; i<dst->npeers; i++) {
struct timeval diff;
timersub(tv_now,&dst->peers[i].last,&diff);
const struct comm_addr *ca=&dst->peers[i].addr;
slog(st, LOG_PEER_ADDRS, " peers: addrs[%d]=%s T-%ld.%06ld",
- i, ca->comm->addr_to_string(ca->comm->st,ca),
+ i, comm_addr_to_string(ca),
(unsigned long)diff.tv_sec, (unsigned long)diff.tv_usec);
}
}
diff --git a/util.c b/util.c
index 9a20420..3bfa6bb 100644
--- a/util.c
+++ b/util.c
@@ -394,7 +394,7 @@ void send_nak(const struct comm_addr *dest, uint32_t our_index,
if (logwhy)
Message(M_INFO,"%s: %08"PRIx32"<-%08"PRIx32": %08"PRIx32":"
" %s; sending NAK\n",
- dest->comm->addr_to_string(dest->comm->st,dest),
+ comm_addr_to_string(dest),
our_index, their_index, msgtype, logwhy);
dest->comm->sendmsg(dest->comm->st, buf, dest);
}
--
1.7.10.4
More information about the sgo-software-discuss
mailing list