@@ -80,44 +80,54 @@ MessageDecoder::Status TimezoneCommandDownDecoder::decode(CborValue* iter, Messa
80
80
81
81
// Message is composed of 2 parameters, offset 32-bit signed integer and until 32-bit unsigned integer
82
82
// Get offset
83
- if (cbor_value_is_integer (iter)) {
84
- int64_t val = 0 ;
85
- if (cbor_value_get_int64 (iter, &val) == CborNoError) {
86
- setTz->params .offset = static_cast <int32_t >(val);
87
- }
83
+ if (!cbor_value_is_integer (iter)) {
84
+ return MessageDecoder::Status::Error;
85
+ }
86
+
87
+ int64_t val = 0 ;
88
+ if (cbor_value_get_int64 (iter, &val) != CborNoError) {
89
+ return MessageDecoder::Status::Error;
88
90
}
89
91
92
+ setTz->params .offset = static_cast <int32_t >(val);
93
+
90
94
// Next
91
95
if (cbor_value_advance (iter) != CborNoError) {
92
96
return MessageDecoder::Status::Error;
93
97
}
94
98
95
99
// Get until
96
- if (cbor_value_is_integer (iter)) {
97
- uint64_t val = 0 ;
98
- if (cbor_value_get_uint64 (iter, &val) == CborNoError) {
99
- setTz->params .until = static_cast <uint32_t >(val);
100
- }
100
+ if (!cbor_value_is_integer (iter)) {
101
+ return MessageDecoder::Status::Error;
101
102
}
102
103
104
+ uint64_t val1 = 0 ;
105
+ if (cbor_value_get_uint64 (iter, &val1) != CborNoError) {
106
+ return MessageDecoder::Status::Error;
107
+ }
108
+
109
+ setTz->params .until = static_cast <uint32_t >(val1);
110
+
103
111
return MessageDecoder::Status::Complete;
104
112
}
105
113
106
114
MessageDecoder::Status LastValuesUpdateCommandDecoder::decode (CborValue* iter, Message *msg) {
107
115
LastValuesUpdateCmd * setLv = (LastValuesUpdateCmd *) msg;
108
116
109
117
// Message is composed by a single parameter, a variable length byte array.
110
- if (cbor_value_is_byte_string (iter)) {
111
- // Cortex M0 is not able to assign a value to pointed memory that is not 32bit aligned
112
- // we use a support variable to cope with that
113
- size_t s;
114
- if (cbor_value_dup_byte_string (iter, &setLv->params .last_values , &s, NULL ) != CborNoError) {
115
- return MessageDecoder::Status::Error;
116
- }
118
+ if (!cbor_value_is_byte_string (iter)) {
119
+ return MessageDecoder::Status::Error;
120
+ }
117
121
118
- setLv->params .length = s;
122
+ // Cortex M0 is not able to assign a value to pointed memory that is not 32bit aligned
123
+ // we use a support variable to cope with that
124
+ size_t s;
125
+ if (cbor_value_dup_byte_string (iter, &setLv->params .last_values , &s, NULL ) != CborNoError) {
126
+ return MessageDecoder::Status::Error;
119
127
}
120
128
129
+ setLv->params .length = s;
130
+
121
131
return MessageDecoder::Status::Complete;
122
132
}
123
133
0 commit comments