]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
configfile: Avoid allocating a buffer for the resource type.
authorFlorian Forster <octo@collectd.org>
Tue, 19 Dec 2023 13:18:30 +0000 (14:18 +0100)
committerFlorian Forster <octo@collectd.org>
Thu, 28 Dec 2023 08:08:20 +0000 (09:08 +0100)
Mostly to avoid an uninformed compiler warning ;)

src/daemon/configfile.c

index b9bf8d63717d960c2f201bbc0c3e8cc532b7436a..e41cfca587b2400b84fc6c12639c5834cf4d74ab 100644 (file)
@@ -337,13 +337,13 @@ static int format_config_value(strbuf_t *buf, oconfig_value_t v) {
 }
 
 static int dispatch_resource(oconfig_item_t *ci) {
-  char type[128] = {0};
-  int status = cf_util_get_string_buffer(ci, type, sizeof(type));
-  if (status != 0) {
-    return status;
+  if (ci->values_num != 1 || ci->values[0].type != OCONFIG_TYPE_STRING) {
+    ERROR("configfile: The \"%s\" option requires one string argument.",
+          ci->key);
+    return EINVAL;
   }
 
-  status = resource_attributes_init(type);
+  int status = resource_attributes_init(ci->values[0].value.string);
   if (status != 0) {
     return status;
   }