X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDeviceConfig.cc;h=38941f3cb508dc52d5abaee2c4c46e7d91c5f133;hb=af4f692075c8e9530a19090725dc87a7ecfaebe9;hp=18870b7473bd1ab967dde5d1ba6d8113f7e94c91;hpb=591e8477b0cd8a038100ac67bed042404f544fde;p=libplp.git diff --git a/src/DeviceConfig.cc b/src/DeviceConfig.cc index 18870b7..38941f3 100644 --- a/src/DeviceConfig.cc +++ b/src/DeviceConfig.cc @@ -95,6 +95,7 @@ static bool set_config_value_to_section(ConfigHandle *cfg_handle, bool ret_val; ret_val = false; + err_flg = UCI_OK; if ((cfg_handle != NULL) && (cfg_handle->_ctx != NULL) && (cfg_handle->_pkg != NULL) && @@ -286,6 +287,8 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { struct uci_package *pkg; string cfg_fl; string cfg_dir; + int b_count; + char *fname; ConfigHandle *ret_val; ret_val = NULL; @@ -298,14 +301,11 @@ 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("confdir: %s, file: %s\n", cfg_dir.c_str(), cfg_fl.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()); - int b_count; - char *fname; - b_count = strlen(cfg_dir.c_str()) + strlen(cfg_fl.c_str()) + 10; fname = (char *)calloc(1, b_count); if (fname != NULL) { @@ -324,20 +324,20 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { } } else { - log_error("Failed to load device device configuration, memory allocation error.\n"); + log_error("Failed to load device configuration, memory allocation error.\n"); set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, ""); } } else { - log_error("Failed to load device device configuration, file does not exist: %s.\n", cfg_fl.c_str()); + log_error("Failed to load device configuration, file does not exist: %s.\n", cfg_fl.c_str()); } } return ret_val; } -DeviceConfig *DeviceConfig::get_device_config(string device_id) { +DeviceConfig *DeviceConfig::get_device_config(string device_id_param) { DeviceConfig *ret_val; - ret_val = new DeviceConfig(device_id); + ret_val = new DeviceConfig(device_id_param); return ret_val; }