Merge branch 'collectd-5.8'
[collectd.git] / src / utils_cmds.c
index 31a9a6f..88fdfc7 100644 (file)
@@ -72,7 +72,7 @@ static cmd_status_t cmd_split(char *buffer, size_t *ret_len, char ***ret_fields,
   fields = malloc((estimate + 1) * sizeof(*fields));
   if (fields == NULL) {
     cmd_error(CMD_ERROR, err, "malloc failed.");
-    return (CMD_ERROR);
+    return CMD_ERROR;
   }
 
 #define END_FIELD()                                                            \
@@ -130,7 +130,7 @@ static cmd_status_t cmd_split(char *buffer, size_t *ret_len, char ***ret_fields,
       if (string[1] == '\0') {
         free(fields);
         cmd_error(CMD_PARSE_ERROR, err, "Backslash at end of string.");
-        return (CMD_PARSE_ERROR);
+        return CMD_PARSE_ERROR;
       }
 
       /* un-escape the next character; skip backslash */
@@ -148,7 +148,7 @@ static cmd_status_t cmd_split(char *buffer, size_t *ret_len, char ***ret_fields,
   if (in_quotes) {
     free(fields);
     cmd_error(CMD_PARSE_ERROR, err, "Unterminated quoted string.");
-    return (CMD_PARSE_ERROR);
+    return CMD_PARSE_ERROR;
   }
 
 #undef NEW_FIELD
@@ -161,7 +161,7 @@ static cmd_status_t cmd_split(char *buffer, size_t *ret_len, char ***ret_fields,
     *ret_fields = fields;
   else
     free(fields);
-  return (CMD_OK);
+  return CMD_OK;
 } /* int cmd_split */
 
 /*
@@ -206,8 +206,7 @@ cmd_status_t cmd_parsev(size_t argc, char **argv, cmd_t *ret_cmd,
         cmd_parse_getval(argc - 1, argv + 1, &ret_cmd->cmd.getval, opts, err);
   } else if (strcasecmp("LISTVAL", command) == 0) {
     ret_cmd->type = CMD_LISTVAL;
-    status =
-        cmd_parse_listval(argc - 1, argv + 1, &ret_cmd->cmd.listval, opts, err);
+    status = cmd_parse_listval(argc - 1, argv + 1, opts, err);
   } else if (strcasecmp("PUTVAL", command) == 0) {
     ret_cmd->type = CMD_PUTVAL;
     status =
@@ -215,12 +214,12 @@ cmd_status_t cmd_parsev(size_t argc, char **argv, cmd_t *ret_cmd,
   } else {
     ret_cmd->type = CMD_UNKNOWN;
     cmd_error(CMD_UNKNOWN_COMMAND, err, "Unknown command `%s'.", command);
-    return (CMD_UNKNOWN_COMMAND);
+    return CMD_UNKNOWN_COMMAND;
   }
 
   if (status != CMD_OK)
     ret_cmd->type = CMD_UNKNOWN;
-  return (status);
+  return status;
 } /* cmd_status_t cmd_parsev */
 
 cmd_status_t cmd_parse(char *buffer, cmd_t *ret_cmd, const cmd_options_t *opts,
@@ -234,7 +233,7 @@ cmd_status_t cmd_parse(char *buffer, cmd_t *ret_cmd, const cmd_options_t *opts,
 
   status = cmd_parsev(fields_num, fields, ret_cmd, opts, err);
   free(fields);
-  return (status);
+  return status;
 } /* cmd_status_t cmd_parse */
 
 void cmd_destroy(cmd_t *cmd) {
@@ -252,7 +251,6 @@ void cmd_destroy(cmd_t *cmd) {
     cmd_destroy_getval(&cmd->cmd.getval);
     break;
   case CMD_LISTVAL:
-    cmd_destroy_listval(&cmd->cmd.listval);
     break;
   case CMD_PUTVAL:
     cmd_destroy_putval(&cmd->cmd.putval);
@@ -267,7 +265,7 @@ cmd_status_t cmd_parse_option(char *field, char **ret_key, char **ret_value,
   if (field == NULL) {
     errno = EINVAL;
     cmd_error(CMD_ERROR, err, "Invalid argument to cmd_parse_option.");
-    return (CMD_ERROR);
+    return CMD_ERROR;
   }
   key = value = field;
 
@@ -276,7 +274,7 @@ cmd_status_t cmd_parse_option(char *field, char **ret_key, char **ret_value,
     value++;
   if ((value[0] != '=') || (value == key)) {
     /* Whether this is a fatal error is up to the caller. */
-    return (CMD_NO_OPTION);
+    return CMD_NO_OPTION;
   }
   *value = '\0';
   value++;
@@ -286,7 +284,7 @@ cmd_status_t cmd_parse_option(char *field, char **ret_key, char **ret_value,
   if (ret_value != NULL)
     *ret_value = value;
 
-  return (CMD_OK);
+  return CMD_OK;
 } /* cmd_status_t cmd_parse_option */
 
 void cmd_error_fh(void *ud, cmd_status_t status, const char *format,
@@ -301,9 +299,8 @@ void cmd_error_fh(void *ud, cmd_status_t status, const char *format,
   vsnprintf(buf, sizeof(buf), format, ap);
   buf[sizeof(buf) - 1] = '\0';
   if (fprintf(fh, "%i %s\n", code, buf) < 0) {
-    char errbuf[1024];
     WARNING("utils_cmds: failed to write to file-handle #%i: %s", fileno(fh),
-            sstrerror(errno, errbuf, sizeof(errbuf)));
+            STRERRNO);
     return;
   }