tag != RESPROTO_SEQUENCE_NO || type != MRP_MSG_FIELD_UINT32)
{
*pseqno = 0;
- return -1;
+ return false;
}
*pseqno = value.u32;
- return 0;
+ return true;
}
-int fetch_request(mrp_msg_t *msg, void **pcursor, uint16_t *preqtype)
+bool fetch_request(mrp_msg_t *msg, void **pcursor, uint16_t *preqtype)
{
uint16_t tag;
uint16_t type;
tag != RESPROTO_REQUEST_TYPE || type != MRP_MSG_FIELD_UINT16)
{
*preqtype = 0;
- return -1;
+ return false;
}
*preqtype = value.u16;
- return 0;
+ return true;
}
-int fetch_attribute_array(mrp_msg_t *msg, void **pcursor,
- size_t dim, mrp_res_attribute_t *arr)
+bool fetch_attribute_array(mrp_msg_t *msg, void **pcursor,
+ size_t dim, mrp_res_attribute_t *arr,
+ int *n_arr)
{
mrp_res_attribute_t *attr;
uint16_t tag;
mrp_msg_value_t value;
size_t size;
size_t i;
+ *n_arr = 0;
i = 0;
if (tag != RESPROTO_ATTRIBUTE_NAME ||
type != MRP_MSG_FIELD_STRING ||
i >= dim - 1) {
- return -1;
+ return false;
}
attr = arr + i++;
if (!mrp_msg_iterate(msg, pcursor, &tag, &type, &value, &size) ||
tag != RESPROTO_ATTRIBUTE_VALUE) {
- return -1;
+ return false;
}
switch (type) {
attr->floating = value.dbl;
break;
default:
- return -1;
+ return false;
}
}
memset(arr + i, 0, sizeof(mrp_res_attribute_t));
- return i;
+ *n_arr = i;
+
+ return TRUE;
}
dim = 0;
while (fetch_resource_name(msg, pcursor, &rdef[dim].name)) {
- int n_attrs = fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX+1,
- attrs);
+ int n_attrs = 0;
- if (n_attrs < 0)
+ if (!fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX+1,
+ attrs, &n_attrs))
goto failed;
if (!(rdef[dim].attrs = mrp_attribute_array_dup(n_attrs, attrs))) {
bool fetch_seqno(mrp_msg_t *msg, void **pcursor, uint32_t *pseqno);
-int fetch_request(mrp_msg_t *msg, void **pcursor, uint16_t *preqtype);
+bool fetch_request(mrp_msg_t *msg, void **pcursor, uint16_t *preqtype);
bool fetch_status(mrp_msg_t *msg, void **pcursor, int *pstatus);
-int fetch_attribute_array(mrp_msg_t *msg, void **pcursor,
- size_t dim, mrp_res_attribute_t *arr);
+bool fetch_attribute_array(mrp_msg_t *msg, void **pcursor,
+ size_t dim, mrp_res_attribute_t *arr,
+ int *n_arr);
bool fetch_resource_name(mrp_msg_t *msg, void **pcursor,
const char **pname);
mrp_res_info("data for '%s': %d", res->name, resid);
- n_attrs = fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX + 1, attrs);
-
- if (n_attrs < 0) {
+ if (!fetch_attribute_array(msg, pcursor, ATTRIBUTE_MAX + 1, attrs,
+ &n_attrs)) {
mrp_res_error("failed to read attributes from message");
goto ignore;
}
MRP_UNUSED(addr);
MRP_UNUSED(addrlen);
- if (fetch_seqno(msg, &cursor, &seqno) < 0 ||
- fetch_request(msg, &cursor, &req) < 0)
+ if (!fetch_seqno(msg, &cursor, &seqno) ||
+ !fetch_request(msg, &cursor, &req))
goto error;
mrp_res_info("received message %d for %p", req, cx);