From 2300d0a2a9c78c72c67596eb129cf7bf86bf300b Mon Sep 17 00:00:00 2001 From: Alex Hermann Date: Thu, 29 Oct 2020 15:16:20 +0100 Subject: [PATCH] kex: Let the RPC server do printf as it may have optimizations Some RPC server implementations may print directly to the output buffer, so this eliminates a string copy. --- src/modules/kex/core_stats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/modules/kex/core_stats.c b/src/modules/kex/core_stats.c index 1ebd235752b..a1f14a7dc6c 100644 --- a/src/modules/kex/core_stats.c +++ b/src/modules/kex/core_stats.c @@ -492,15 +492,13 @@ static void rpc_stats_get_statistics(rpc_t* rpc, void* ctx) static void rpc_fetch_add_stat(rpc_t* rpc, void* ctx, void* hst, char* g, char* n, unsigned long val, int numeric) { char nbuf[128]; - char vbuf[32]; int res; snprintf(nbuf, 127, "%s.%s", g, n); if (numeric) { res = rpc->struct_add(hst, "d", nbuf, val); } else { - snprintf(vbuf, 31, "%lu", val); - res = rpc->struct_add(hst, "s", nbuf, vbuf); + res = rpc->struct_printf(hst, nbuf, "%lu", val); } if (res<0) {