settings: Fix uninitialised use
PATCH v2 1/2 settings: Fix uninitialised use
__attribute__(cleanup) variables need to be initialised in situ.
In file included from ell/private.h:8,
from ell/settings.c:36:
In function 'auto_free',
inlined from 'l_settings_set_double' at ell/settings.c:1335:2:
./ell/util.h:265:9: warning: 'buf' may be used uninitialized [-Wmaybe-uninitialized]
265 | l_free(*p);
| ^~~~~~~~~~ell/settings.c: In function 'l_settings_set_double':ell/settings.c:1335:33: note: 'buf' was declared here
1335 | L_AUTO_FREE_VAR(char *, buf);
| ^~~
In function 'auto_free',
inlined from 'l_settings_set_float' at ell/settings.c:1381:2:./ell/util.h:265:9: warning: 'buf' may be used uninitialized [-Wmaybe-uninitialized]
265 | l_free(*p);
| ^~~~~~~~~~ell/settings.c: In function 'l_settings_set_float':ell/settings.c:1381:33: note: 'buf' was declared here
1381 | L_AUTO_FREE_VAR(char *, buf);
| ^~~
---
Changes since v1:
- Fix the fix to note create more warnings
ell/settings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ell/settings.c +2 -2
@@ -1332,7 +1332,7 @@ LIB_EXPORT bool l_settings_set_double(struct l_settings *settings, const char *group_name, const char *key, double in) { -L_AUTO_FREE_VAR (char *,buf ); +L_AUTO_FREE_VAR (char *,buf ) =NULL ; buf =l_strdup_printf ("%f" , in);
@@ -1378,7 +1378,7 @@ LIB_EXPORT bool l_settings_set_float(struct l_settings *settings, const char *group_name, const char *key, float in) { -L_AUTO_FREE_VAR (char *,buf ); +L_AUTO_FREE_VAR (char *,buf ) =NULL ; buf =l_strdup_printf ("%f" , (double )in);
Signature · 1 line
2.55.0
PATCH v2 2/2 cert: Fix uninitialised variable
In file included from ./ell/util.h:20,
from ell/private.h:8,
from ell/cert.c:18:In function '_l_l_free_cleanup',
inlined from 'cert_set_filter_by_validity' at ell/cert.c:618:33, inlined from 'l_certchain_verify' at ell/cert.c:729:20:./ell/util.h:257:21: warning: 'valid' may be used uninitialized [-Wmaybe-uninitialized]
257 | DEFINE_CLEANUP_FUNC(l_free);ell/cert.c: In function 'l_certchain_verify':ell/cert.c:618:40: note: 'valid' was declared here
618 | _auto_(l_free) struct l_cert **valid;
| ^~~~~
---
Changes since v1:
- None
ell/cert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ell/cert.c +1 -1
@@ -615,7 +615,7 @@ static struct l_cert **cert_set_filter_by_validity(struct l_queue *set, int *out_valid) {const struct l_queue_entry *entry; - _auto_(l_free) struct l_cert **valid; + _auto_(l_free) struct l_cert **valid = NULL; *out_total =l_queue_length (set); *out_valid =0 ;
Signature · 1 line
2.55.0