]> pilppa.com Git - libplpbus.git/commitdiff
added error checks to data parse methods
authorMika Laitio <lamikr@pilppa.org>
Sun, 12 Aug 2012 22:39:21 +0000 (01:39 +0300)
committerMika Laitio <lamikr@pilppa.org>
Sun, 12 Aug 2012 22:39:21 +0000 (01:39 +0300)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/plpbus/BusMessage.cc

index 1fbc724064dbf6fcb33070c6ce87319788d1503c..d592a6610e48273fd50843177044c394ec7078c4 100644 (file)
@@ -238,8 +238,9 @@ long BusMessage::get_long_parameter(string arg_name_param, int *err_flg) {
        seq             = (DataItemSequence *)_dataItemSeq;
        item            = get_dataitem_by_param_name(seq, arg_name_param);
        if (item != NULL) {
-               item->value >>= ret_val;
-               *err_flg        = PLP_OK;
+               if (item->value >>= ret_val) {
+                       *err_flg        = PLP_OK;
+               }
        }
        return ret_val;
 }
@@ -255,9 +256,10 @@ int BusMessage::get_int_parameter(string arg_name_param, int *err_flg) {
        seq             = (DataItemSequence *)_dataItemSeq;
        item            = get_dataitem_by_param_name(seq, arg_name_param);
        if (item != NULL) {
-               item->value >>= tmp;
-               ret_val =        (int)tmp;
-               *err_flg        = PLP_OK;
+               if (item->value >>= tmp) {
+                       ret_val         = (int)tmp;
+                       *err_flg        = PLP_OK;
+               }
        }
        return ret_val;
 }
@@ -272,8 +274,8 @@ double BusMessage::get_double_parameter(string arg_name_param, int *err_flg) {
        seq             = (DataItemSequence *)_dataItemSeq;
        item            = get_dataitem_by_param_name(seq, arg_name_param);
        if (item != NULL) {
-               item->value >>= ret_val;
-               *err_flg        = PLP_OK;
+               if (item->value >>= ret_val)
+                       *err_flg        = PLP_OK;
        }
        return ret_val;
 }
@@ -288,8 +290,8 @@ float BusMessage::get_float_parameter(string arg_name_param, int *err_flg) {
        seq             = (DataItemSequence *)_dataItemSeq;
        item            = get_dataitem_by_param_name(seq, arg_name_param);
        if (item != NULL) {
-               item->value >>= ret_val;
-               *err_flg        = PLP_OK;
+               if (item->value >>= ret_val)
+                       *err_flg        = PLP_OK;
        }
        return ret_val;
 }