AVSystem / Anjay

C implementation of the client-side OMA LwM2M protocol
Other
188 stars 68 forks source link

'binding_str' may be used uninitialized warning #58

Closed AxelLin closed 2 years ago

AxelLin commented 2 years ago

Below line has build issue when compile with riscv32 gcc. https://github.com/AVSystem/Anjay/blob/master/src/modules/server/anjay_server_persistence.c#L286

anjay/deps/avs_commons/include_public/avsystem/commons/avs_log_impl.h:63:9: error: 'binding_str' may be used uninitialized in this function [-Werror=maybe-uninitialized] avs_loginternal##Variant##(Level, ModuleStr, FILE, LINE__, \ ^~~~~ anjay/src/modules/server/anjay_server_persistence.c:286:17: note: 'binding_str' was declared here const char *binding_str; ^~~

kFYatek commented 2 years ago

This is a false positive and thus harmless. The switch (binding) statement, in all cases, either sets binding_str or sets err = avs_errno(AVS_EBADMSG);, and the only usage of binding_str below is under if (avs_is_ok(err)) - the compiler is evidently not able to deduce the semantics of this check, hence the warning.

We will add some dummy initialization of this variable to silence this warning in future releases.