From: Florian Forster Date: Tue, 28 Nov 2023 13:50:36 +0000 (+0100) Subject: capabilities plugin: remove warning about "leaking" a pointer to a local variable. X-Git-Tag: 6.0.0-rc0~42^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63d3efd2fce649465f6112a55a6659a44d252676;p=thirdparty%2Fcollectd.git capabilities plugin: remove warning about "leaking" a pointer to a local variable. ``` 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 ``` --- diff --git a/src/capabilities.c b/src/capabilities.c index a3a31c1ae..c108d145d 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -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);