]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
cmds: Quick fix to get "getval" to compile.
authorFlorian Forster <octo@google.com>
Wed, 29 Jul 2020 07:57:16 +0000 (09:57 +0200)
committerFlorian Forster <octo@google.com>
Wed, 29 Jul 2020 07:58:42 +0000 (09:58 +0200)
src/utils/cmds/getval.c

index f2586e126ba6e7077a790fdcb7ea421f2eb817e6..bf8c327ecb642d7f8a8664efcb7748110d1a5396 100644 (file)
@@ -90,9 +90,6 @@ cmd_status_t cmd_handle_getval(FILE *fh, char *buffer) {
   cmd_status_t status;
   cmd_t cmd;
 
-  gauge_t *values;
-  size_t values_num;
-
   const data_set_t *ds;
 
   if ((fh == NULL) || (buffer == NULL))
@@ -120,10 +117,10 @@ cmd_status_t cmd_handle_getval(FILE *fh, char *buffer) {
     return -1;
   }
 
-  values = NULL;
-  values_num = 0;
+  gauge_t value;
+  size_t values_num = 1;
   status =
-      uc_get_rate_by_name(cmd.cmd.getval.raw_identifier, &values, &values_num);
+      uc_get_rate_by_name(cmd.cmd.getval.raw_identifier, &value);
   if (status != 0) {
     cmd_error(CMD_ERROR, &err, "No such value.");
     cmd_destroy(&cmd);
@@ -135,7 +132,6 @@ cmd_status_t cmd_handle_getval(FILE *fh, char *buffer) {
           "but uc_get_rate_by_name returned %" PRIsz " values.",
           ds->type, ds->ds_num, values_num);
     cmd_error(CMD_ERROR, &err, "Error reading value from cache.");
-    sfree(values);
     cmd_destroy(&cmd);
     return CMD_ERROR;
   }
@@ -144,14 +140,13 @@ cmd_status_t cmd_handle_getval(FILE *fh, char *buffer) {
                   (values_num == 1) ? "" : "s");
   for (size_t i = 0; i < values_num; i++) {
     print_to_socket(fh, "%s=", ds->ds[i].name);
-    if (isnan(values[i])) {
+    if (isnan(value)) {
       print_to_socket(fh, "NaN\n");
     } else {
-      print_to_socket(fh, "%12e\n", values[i]);
+      print_to_socket(fh, "%12e\n", value);
     }
   }
 
-  sfree(values);
   cmd_destroy(&cmd);
 
   return CMD_OK;