dlog_logger: cleanup config line handling 56/288056/1
authorMichal Bloch <m.bloch@samsung.com>
Wed, 8 Feb 2023 12:54:09 +0000 (13:54 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 9 Feb 2023 17:57:08 +0000 (18:57 +0100)
 * remove needless setting to NULL (already NULL and would leak otherwise).
 * remove a needless void cast (just makes the code less type safe)
 * remove a needless conditional-but-not-really removal wrapper (proper API exists for this)

Change-Id: Iebc4f3cd76c5aa7973f16dca9c33575e0c21445a
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logger/logger.c

index 0f8394e..a7c048d 100644 (file)
@@ -1030,7 +1030,7 @@ void save_logfile_config(char const *key, char const *value, void *userdata)
                return;
 
        struct logger_config_data *data = (struct logger_config_data *)userdata;
-       void *cmd = (void *)strdup(value);
+       char *cmd = strdup(value);
        if (cmd)
                list_add(&data->logfile_configs, cmd);
        //ignore errors
@@ -1155,7 +1155,6 @@ int prepare_config_data(struct logger_config_data *data)
                 * This will result in daemon quitting. Hopefully we will either reenable some of these
                 * in the future or at least make it exit more gracefully (TODO), but for now this is ok. */
                g_backend.use_logger_by_default = false;
-               data->logfile_configs = NULL;
                goto end;
        } else {
                ret = -ENOENT;
@@ -1173,7 +1172,6 @@ int prepare_config_data(struct logger_config_data *data)
                        data->buffers[buf_id].sort_by = sort_by;
                }
        }
-       data->logfile_configs = NULL;
        log_config_foreach(&conf, save_logfile_config, data);
 
        data->default_format = get_default_format_from_config(&conf);
@@ -1183,19 +1181,12 @@ end:
        return ret;
 }
 
-static bool cond_string_free(void *ptr, void *user_data)
-{
-       (void) user_data;
-       free(ptr);
-       return true;
-}
-
 #ifndef UNIT_TEST
 static
 #endif
 void free_config_data(struct logger_config_data *data)
 {
-       list_remove_if(&data->logfile_configs, NULL, cond_string_free);
+       list_clear_free_contents(&data->logfile_configs);
        free(data->dynamic_config_dir);
        qos_free(data->qos);
        free(data->first_time_file_path);