]> pilppa.org Git - libplp.git/commitdiff
better error handling in case where the device specific config file is missing
authorMika Laitio <lamikr@pilppa.org>
Thu, 16 Jun 2011 18:59:03 +0000 (21:59 +0300)
committerMika Laitio <lamikr@pilppa.org>
Thu, 16 Jun 2011 18:59:03 +0000 (21:59 +0300)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/DataReader.cc

index 0e6ebf380fb2e335fb028956607abd8f430891d7..9731bce6170c6e007e2d4bda7042f6507ce1b5d9 100644 (file)
@@ -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;
 }