X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDeviceConfig.cc;h=70027925ebb045eace8e17ad0bed5fc0b4fc75bb;hb=af341b7dfafac0912f513879565ebd856aa77915;hp=066a22ca838a359c7698509da5eab8ff8367c29b;hpb=d01194ab9275bc97176071089edc2781bb4de51b;p=lib1wire.git diff --git a/src/DeviceConfig.cc b/src/DeviceConfig.cc index 066a22c..7002792 100644 --- a/src/DeviceConfig.cc +++ b/src/DeviceConfig.cc @@ -38,7 +38,7 @@ DeviceConfig::DeviceConfig(string device_id_param) { device_type = get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE); } else { - log_error("Could not read device config\n"); + log_error("Could not read device configuration.\n"); } } @@ -95,14 +95,19 @@ string DeviceConfig::get_cfg_value(string key) { section = uci_lookup_section(uci_handle->_ctx, uci_handle->_pkg, DEVICE_CONFIG__SECTION_NAME); if (section != NULL) { option = uci_lookup_option(uci_handle->_ctx, section, key.c_str()); - switch (option->type) { - case UCI_TYPE_STRING: - log_info("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string); - ret_val = option->v.string; - break; - default: - log_error("key: %s Failed to read parameter value\n", key.c_str()); - break; + if (option != NULL) { + switch (option->type) { + case UCI_TYPE_STRING: + log_info("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string); + ret_val = option->v.string; + break; + default: + log_error("key: %s Failed to read parameter value\n", key.c_str()); + break; + } + } + else { + log_error("key: %s Failed to read parameter value\n", key.c_str()); } } } @@ -153,15 +158,15 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { if (access(cfg_fl.c_str(), R_OK) == 0) { ctx = uci_alloc_context(); if (ctx != NULL) { - log_debug("uci_set_confdir: %s\n", cfg_dir.c_str()); + //log_debug("uci_set_confdir: %s\n", cfg_dir.c_str()); uci_set_confdir(ctx, cfg_dir.c_str()); err_flg = uci_load(ctx, cfg_fl.c_str(), &pkg); if (err_flg == UCI_OK) { - log_debug("Loaded device configuration: %s\n.", cfg_fl.c_str()); + //log_debug("Loaded device configuration: %s.\n", cfg_fl.c_str()); ret_val = new ConfigHandle(ctx, pkg); } else { - log_debug("Failed to load device configuration: %s, err code: %d\n.", cfg_fl.c_str(), UCI_OK); + log_debug("Failed to load device configuration: %s, err code: %d.\n", cfg_fl.c_str(), UCI_OK); set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, ""); uci_free_context(ctx); }