From: Mika Laitio Date: Thu, 16 Jun 2011 18:59:03 +0000 (+0300) Subject: better error handling in case where the device specific config file is missing X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=commitdiff_plain;h=1f4c845decad23299609aa00ee97ba1c61a1f027 better error handling in case where the device specific config file is missing Signed-off-by: Mika Laitio --- diff --git a/src/DataReader.cc b/src/DataReader.cc index 0e6ebf3..9731bce 100644 --- a/src/DataReader.cc +++ b/src/DataReader.cc @@ -441,14 +441,19 @@ string DataReader::get_device_id() { } /** - * Read device type from the device specific config file + * Read device type from the device specific config file. + * + * @rerurn string representing device type. + * In the case of error, an empty string is returned. */ string DataReader::get_device_type() { string ret_val; if (device_config == NULL) { device_config = DeviceConfig::get_device_config(device_id); - ret_val = device_config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE); + } + if (device_config != NULL) { + ret_val = device_config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE); } return ret_val; }