Proper initialization is required to be able to free the
structure after eg. failing log_config_read() which might
have either read some entries (and updated .begin/.end)
or have not read anything (keeping .begin/.end unchanged).
Change-Id: I3a2a2434488e13349746a85afcb4c81752609dd9
*/
static void __configure(void)
{
- struct log_config config;
+ struct log_config config = {.begin = NULL, .last = NULL};
if (log_config_read(&config) < 0)
- goto failure;
+ goto out;
dynamic_config = __dynamic_config_create(&config);
__configure_parameters(&config);
if (!__configure_backend(&config))
- goto failure;
+ goto out;
__configure_limiter(&config);
- log_config_free(&config);
- return;
-
-failure:
+out:
log_config_free(&config);
return;
}
return ret;
}
- struct log_config conf;
+ struct log_config conf = {.begin = NULL, .last = NULL};
ret = log_config_read(&conf);
if (ret < 0)
- return ret;
+ goto end;
const enum sorting_order sort_by = get_order_from_config(&conf);
int main()
{
const char * get;
- struct log_config config;
+ struct log_config config = {.begin = NULL, .last = NULL};
setenv("DLOG_CONFIG_PATH", "./non_existent_file", 1);
assert(log_config_read(&config) == -ENOENT);