From e32497210e9a5247149f3a299980fcd3a59c9982 Mon Sep 17 00:00:00 2001 From: Marco Varlese Date: Mon, 17 May 2021 10:45:39 +0200 Subject: [PATCH] Ensure -f option has precedence over settings file --- src/filehelper.c | 7 +++++-- src/phoebe.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/filehelper.c b/src/filehelper.c index f6c4961..4faf748 100644 --- a/src/filehelper.c +++ b/src/filehelper.c @@ -221,8 +221,11 @@ int readSettingsFromJsonFile(char *settingsFileName, app_settings_t *settings, &rates_filename)) { assert(sizeof(settings->rates_filename) > (long unsigned int)json_object_get_string_len(rates_filename)); - memcpy(settings->rates_filename, json_object_get_string(rates_filename), - json_object_get_string_len(rates_filename) + 1); + + if (strlen(settings->rates_filename) == 0) + memcpy(settings->rates_filename, + json_object_get_string(rates_filename), + json_object_get_string_len(rates_filename) + 1); write_adv_log("settings->rates_filename: %s\n", settings->rates_filename); diff --git a/src/phoebe.c b/src/phoebe.c index b523293..e5aaa98 100644 --- a/src/phoebe.c +++ b/src/phoebe.c @@ -292,6 +292,9 @@ int main(int argc, char **argv) { signal(SIGTERM, handleSigint); signal(SIGHUP, handleSighup); + bzero(&app_settings, sizeof(app_settings_t)); + bzero(&system_settings, sizeof(tuning_params_t)); + // set default verbosity setting before cmdline parsing, so // that it can be used before if (handleCommandLineArguments(argc, argv) == RET_FAIL)