]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
[collectd 6] src/daemon/plugin.c: work around missing stpcpy on solaris
authorLeonard Göhrs <l.goehrs@pengutronix.de>
Mon, 15 Aug 2022 06:32:08 +0000 (08:32 +0200)
committerMatthias Runge <mrunge@matthias-runge.de>
Mon, 27 Feb 2023 17:37:53 +0000 (18:37 +0100)
The CI tests on solaris failed due to missing stpcpy. Work around it using
memcpy and strlen.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
src/daemon/plugin.c

index 111dd88c4bc0db63557bc7d1f80f3777eab09bd0..9c32fb49ccda3594267d2e44cef5c3c40230145f 100644 (file)
@@ -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);