From c24c1cce4b01eb013de533c04f80722d738743f6 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 4 Dec 2017 14:39:31 -0700 Subject: [PATCH] rpc: only dump [Rpc] section if config is set The config_text callback should only add a [Rpc] section if an address is configured. This avoids printing out a bogus configuration file section with "Listen (null)". Change-Id: Ibb734f6faab4c2587203623eee8a193f9a7207ba Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/390328 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Dariusz Stojaczyk Reviewed-by: Ben Walker --- lib/event/rpc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/event/rpc.c b/lib/event/rpc.c index ce0f5979c..a11bdad88 100644 --- a/lib/event/rpc.c +++ b/lib/event/rpc.c @@ -98,10 +98,17 @@ spdk_rpc_finish(void) void spdk_rpc_config_text(FILE *fp) { + const char *listen_addr; + + listen_addr = rpc_get_listen_addr(); + if (listen_addr == NULL) { + return; + } + fprintf(fp, "\n" "[Rpc]\n" " # Listen address for the RPC service.\n" " # May be an IP address or an absolute path to a Unix socket.\n" - " Listen %s\n", rpc_get_listen_addr()); + " Listen %s\n", listen_addr); }