]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
common: Improve coding style of `strsplit`.
authorFlorian Forster <octo@collectd.org>
Fri, 15 Dec 2023 08:44:52 +0000 (09:44 +0100)
committerFlorian Forster <octo@collectd.org>
Fri, 15 Dec 2023 08:44:52 +0000 (09:44 +0100)
* Combine declaration and initialization.

src/utils/common/common.c

index c1d0d14a6f1bb23e6334635ce23f621df6aa548f..7caa1f51ff1735981d868c4f83c72a1dbcdf9496 100644 (file)
@@ -350,13 +350,9 @@ int swrite(int fd, const void *buf, size_t count) {
 }
 
 int strsplit(char *string, char **fields, size_t size) {
-  size_t i;
-  char *ptr;
-  char *saveptr;
-
-  i = 0;
-  ptr = string;
-  saveptr = NULL;
+  size_t i = 0;
+  char *ptr = string;
+  char *saveptr = NULL;
   while ((fields[i] = strtok_r(ptr, " \t\r\n", &saveptr)) != NULL) {
     ptr = NULL;
     i++;