From eb39bb7149ed9ed6f736976dcec4ff166249594e Mon Sep 17 00:00:00 2001 From: John Date: Sat, 24 Sep 2022 17:56:30 +0200 Subject: [PATCH] fix previous commit --- src/ebusd/main.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index f0115f84..7b69cde8 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -340,32 +340,36 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { s_configPath = arg; break; case 's': // --scanconfig[=ADDR] (ADDR=|full|) + { if (opt->pollInterval == 0) { argp_error(state, "scanconfig without polling may lead to invalid files included for certain products!"); return EINVAL; } - opt->scanConfig = true; + symbol_t initialScan = ESC; if (!arg || arg[0] == 0 || strcmp("none", arg) == 0) { - opt->initialScan = ESC; + // no further setting needed } else if (strcmp("full", arg) == 0) { - opt->initialScan = SYN; + initialScan = SYN; } else { - symbol_t address = (symbol_t)parseInt(arg, 16, 0x00, 0xff, &result); + auto address = (symbol_t)parseInt(arg, 16, 0x00, 0xff, &result); if (result != RESULT_OK || !isValidAddress(address)) { argp_error(state, "invalid initial scan address"); return EINVAL; } if (isMaster(address)) { - opt->initialScan = getSlaveAddress(address); + initialScan = getSlaveAddress(address); } else { - opt->initialScan = address; + initialScan = address; } } - if (opt->readOnly && opt->initialScan != ESC) { + if (opt->readOnly && initialScan != ESC) { argp_error(state, "cannot combine readonly with answer/generatesyn/initsend/scanconfig=*"); return EINVAL; } + opt->scanConfig = true; + opt->initialScan = initialScan; break; + } case O_CFGLNG: // --configlang=LANG opt->preferLanguage = arg; break; @@ -429,7 +433,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { // eBUS options: case 'a': // --address=31 { - symbol_t address = (symbol_t)parseInt(arg, 16, 0, 0xff, &result); + auto address = (symbol_t)parseInt(arg, 16, 0, 0xff, &result); if (result != RESULT_OK || !isMaster(address)) { argp_error(state, "invalid address"); return EINVAL; @@ -618,7 +622,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { case O_LOGLEV: // --loglevel=notice { LogLevel logLevel = parseLogLevel(arg); - if (opt->logLevel == ll_COUNT) { + if (logLevel == ll_COUNT) { argp_error(state, "invalid loglevel"); return EINVAL; }