From: Mika Laitio Date: Sun, 12 Aug 2012 22:39:21 +0000 (+0300) Subject: added error checks to data parse methods X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=b0d18f2b84f652e012471b8339bf81b12d731d6e;p=libplpbus.git added error checks to data parse methods Signed-off-by: Mika Laitio --- diff --git a/src/plpbus/BusMessage.cc b/src/plpbus/BusMessage.cc index 1fbc724..d592a66 100644 --- a/src/plpbus/BusMessage.cc +++ b/src/plpbus/BusMessage.cc @@ -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; }