summaryrefslogtreecommitdiffstats
path: root/isisd/isis_misc.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-06-12 17:11:21 +0200
committerDavid Lamparter <equinox@diac24.net>2019-06-12 19:35:43 +0200
commitc7179009cf1713db55d48e6ab1275ac00be555ac (patch)
treedfe1a531ec549f2d5b2585e4300a5bb8853d4a2b /isisd/isis_misc.c
parentzebra: fix stats printing formats (diff)
downloadfrr-c7179009cf1713db55d48e6ab1275ac00be555ac.tar.xz
frr-c7179009cf1713db55d48e6ab1275ac00be555ac.zip
lib: use snprintfrr() in "hidden" printfs
We need to be calling snprintfrr() instead of snprintf() in places that wrap snprintf in some user-exposed way; otherwise the extensions won't be available for those functions. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'isisd/isis_misc.c')
-rw-r--r--isisd/isis_misc.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 0a42adea3..d4c38efaf 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -23,6 +23,7 @@
#include <zebra.h>
+#include "printfrr.h"
#include "stream.h"
#include "vty.h"
#include "hash.h"
@@ -511,42 +512,14 @@ void zlog_dump_data(void *data, int len)
return;
}
-static char *qasprintf(const char *format, va_list ap)
-{
- va_list aq;
- va_copy(aq, ap);
-
- int size = 0;
- char *p = NULL;
-
- size = vsnprintf(p, size, format, ap);
-
- if (size < 0) {
- va_end(aq);
- return NULL;
- }
-
- size++;
- p = XMALLOC(MTYPE_TMP, size);
-
- size = vsnprintf(p, size, format, aq);
- va_end(aq);
-
- if (size < 0) {
- XFREE(MTYPE_TMP, p);
- return NULL;
- }
-
- return p;
-}
-
void log_multiline(int priority, const char *prefix, const char *format, ...)
{
+ char shortbuf[256];
va_list ap;
char *p;
va_start(ap, format);
- p = qasprintf(format, ap);
+ p = asnprintfrr(MTYPE_TMP, shortbuf, sizeof(shortbuf), format, ap);
va_end(ap);
if (!p)
@@ -558,16 +531,18 @@ void log_multiline(int priority, const char *prefix, const char *format, ...)
zlog(priority, "%s%s", prefix, line);
}
- XFREE(MTYPE_TMP, p);
+ if (p != shortbuf)
+ XFREE(MTYPE_TMP, p);
}
void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
{
+ char shortbuf[256];
va_list ap;
char *p;
va_start(ap, format);
- p = qasprintf(format, ap);
+ p = asnprintfrr(MTYPE_TMP, shortbuf, sizeof(shortbuf), format, ap);
va_end(ap);
if (!p)
@@ -579,7 +554,8 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
vty_out(vty, "%s%s\n", prefix, line);
}
- XFREE(MTYPE_TMP, p);
+ if (p != shortbuf)
+ XFREE(MTYPE_TMP, p);
}
void vty_out_timestr(struct vty *vty, time_t uptime)