lib: make prefix2str simpler to use, and use it in zclient
Returning the buffer allows using it in the logging functions
in easier way. This also makes the API consistent with sockunion.
Add also PREFIX_STRLEN to be the generic buffer length required
for any prefix string representation.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/lib/zclient.c b/lib/zclient.c
index 1e05d6d..71da87c 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -808,11 +808,11 @@
else if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER))
{
/* carp interfaces on OpenBSD with 0.0.0.0/0 as "peer" */
- char buf[BUFSIZ];
- prefix2str (ifc->address, buf, sizeof(buf));
+ char buf[PREFIX_STRLEN];
zlog_warn("warning: interface %s address %s "
"with peer flag set, but no peer address!",
- ifp->name, buf);
+ ifp->name,
+ prefix2str (ifc->address, buf, sizeof buf));
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
}
}