]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
capabilities plugin: remove warning about "leaking" a pointer to a local variable.
authorFlorian Forster <octo@collectd.org>
Tue, 28 Nov 2023 13:50:36 +0000 (14:50 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 29 Nov 2023 20:56:20 +0000 (21:56 +0100)
```
src/capabilities.c: In function 'cap_http_handler':
src/capabilities.c:209:23: error: storing the address of local variable '({anonymous})' in '*connection_state' [-Werror=dangling-pointer=]
  209 |     *connection_state = &(int){44};
      |     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
src/capabilities.c:209:31: note: '({anonymous})' declared here
  209 |     *connection_state = &(int){44};
      |                               ^
src/capabilities.c:209:31: note: 'connection_state' declared here
```

src/capabilities.c

index a3a31c1aec197bc5f912d348e1f3ded5d105abb3..c108d145d98c83a478c7e81ddd61bb488ee31031 100644 (file)
@@ -206,7 +206,7 @@ static MHD_RESULT cap_http_handler(void *cls, struct MHD_Connection *connection,
    * round. The docs are not very specific on the issue. */
   if (*connection_state == NULL) {
     /* set to a random non-NULL pointer. */
-    *connection_state = &(int){44};
+    *connection_state = (void *)1;
     return MHD_YES;
   }
   DEBUG(CAP_PLUGIN ": formatted response: %s", g_cap_json);