From: Martin Schwenke Date: Tue, 19 Jul 2022 01:53:15 +0000 (+1000) Subject: ctdb-protocol: Add separator argument to ctdb_connection_to_buf() X-Git-Tag: tevent-0.13.0~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec5f6425b70672af591df3113962c636d8f65005;p=thirdparty%2Fsamba.git ctdb-protocol: Add separator argument to ctdb_connection_to_buf() Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 28631c8de61..fe757658f48 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -497,8 +497,11 @@ bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1, return (ctdb_sock_addr_cmp(addr1, addr2) == 0); } -int ctdb_connection_to_buf(char *buf, size_t buflen, - struct ctdb_connection *conn, bool client_first) +int ctdb_connection_to_buf(char *buf, + size_t buflen, + struct ctdb_connection *conn, + bool client_first, + const char *sep) { char server[64], client[64]; int ret; @@ -516,9 +519,9 @@ int ctdb_connection_to_buf(char *buf, size_t buflen, } if (! client_first) { - ret = snprintf(buf, buflen, "%s %s", server, client); + ret = snprintf(buf, buflen, "%s%s%s", server, sep, client); } else { - ret = snprintf(buf, buflen, "%s %s", client, server); + ret = snprintf(buf, buflen, "%s%s%s", client, sep, server); } if (ret < 0 || (size_t)ret >= buflen) { return ENOSPC; @@ -540,7 +543,7 @@ char *ctdb_connection_to_string(TALLOC_CTX *mem_ctx, return NULL; } - ret = ctdb_connection_to_buf(out, len, conn, client_first); + ret = ctdb_connection_to_buf(out, len, conn, client_first, " "); if (ret != 0) { talloc_free(out); return NULL; @@ -666,8 +669,11 @@ char *ctdb_connection_list_to_string( char buf[128]; int ret; - ret = ctdb_connection_to_buf(buf, sizeof(buf), - &conn_list->conn[i], client_first); + ret = ctdb_connection_to_buf(buf, + sizeof(buf), + &conn_list->conn[i], + client_first, + " "); if (ret != 0) { talloc_free(out); return NULL; diff --git a/ctdb/protocol/protocol_util.h b/ctdb/protocol/protocol_util.h index b01db8e9934..2bdbb0c2ad0 100644 --- a/ctdb/protocol/protocol_util.h +++ b/ctdb/protocol/protocol_util.h @@ -55,8 +55,11 @@ bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1, bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1, const ctdb_sock_addr *addr2); -int ctdb_connection_to_buf(char *buf, size_t buflen, - struct ctdb_connection * conn, bool client_first); +int ctdb_connection_to_buf(char *buf, + size_t buflen, + struct ctdb_connection * conn, + bool client_first, + const char *sep); char *ctdb_connection_to_string(TALLOC_CTX *mem_ctx, struct ctdb_connection * conn, bool client_first);