From: Leonard Göhrs Date: Mon, 15 Aug 2022 06:32:08 +0000 (+0200) Subject: [collectd 6] src/daemon/plugin.c: work around missing stpcpy on solaris X-Git-Tag: 6.0.0-rc0~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e79c4aef839e2c9493345715dd0375e3d34ec21e;p=thirdparty%2Fcollectd.git [collectd 6] src/daemon/plugin.c: work around missing stpcpy on solaris The CI tests on solaris failed due to missing stpcpy. Work around it using memcpy and strlen. Signed-off-by: Leonard Göhrs --- diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 111dd88c4..9c32fb49c 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -1602,6 +1602,9 @@ EXPORT int plugin_unregister_read(const char *name) /* {{{ */ } /* }}} int plugin_unregister_read */ EXPORT void plugin_log_available_writers(void) { + const char *sep = "' , '"; + size_t sep_len = strlen(sep); + pthread_mutex_lock(&write_queue.lock); if (write_queue.threads == NULL) { @@ -1615,7 +1618,7 @@ EXPORT void plugin_log_available_writers(void) { piv = piv->next) { total_len += strlen(piv->name); if (piv->next != NULL) { - total_len += 5; + total_len += sep_len; } } @@ -1630,12 +1633,18 @@ EXPORT void plugin_log_available_writers(void) { for (write_queue_thread_t *piv = write_queue.threads; piv != NULL; piv = piv->next) { - cursor = stpcpy(cursor, piv->name); + size_t name_len = strlen(piv->name); + memcpy(cursor, piv->name, name_len); + cursor += name_len; + if (piv->next != NULL) { - cursor = stpcpy(cursor, "' , '"); + memcpy(cursor, sep, sep_len); + cursor += sep_len; } } + *cursor = '\0'; + pthread_mutex_unlock(&write_queue.lock); INFO("Available write targets: ['%s']", str);