cli: improve error logging for call command
[project/ubus.git] / libubus-req.c
index 74446f3fef51de83024d3d867d9c1b23f6d90a67..ae9d1925ecdf1845f5d536b50240216f9ef56fb4 100644 (file)
@@ -31,7 +31,7 @@ static void req_data_cb(struct ubus_request *req, int type, struct blob_attr *da
        if (!req->data_cb)
                return;
 
-       attr = ubus_parse_msg(data);
+       attr = ubus_parse_msg(data, blob_raw_len(data));
        if (!attr[UBUS_ATTR_DATA])
                return;
 
@@ -40,11 +40,9 @@ static void req_data_cb(struct ubus_request *req, int type, struct blob_attr *da
 
 static void __ubus_process_req_data(struct ubus_request *req)
 {
-       struct ubus_pending_data *data;
+       struct ubus_pending_data *data, *tmp;
 
-       while (!list_empty(&req->pending)) {
-               data = list_first_entry(&req->pending,
-                       struct ubus_pending_data, list);
+       list_for_each_entry_safe(data, tmp, &req->pending, list) {
                list_del(&data->list);
                if (!req->cancelled)
                        req_data_cb(req, data->type, data->data);
@@ -330,7 +328,7 @@ int ubus_notify(struct ubus_context *ctx, struct ubus_object *obj,
 
 static bool ubus_get_status(struct ubus_msghdr_buf *buf, int *ret)
 {
-       struct blob_attr **attrbuf = ubus_parse_msg(buf->data);
+       struct blob_attr **attrbuf = ubus_parse_msg(buf->data, blob_raw_len(buf->data));
 
        if (!attrbuf[UBUS_ATTR_STATUS])
                return false;
@@ -428,7 +426,8 @@ static void ubus_process_notify_status(struct ubus_request *req, int id, struct
        struct ubus_notify_request *nreq;
        struct blob_attr **tb;
        struct blob_attr *cur;
-       int rem, idx = 1;
+       size_t rem;
+       int idx = 1;
        int ret = 0;
 
        nreq = container_of(req, struct ubus_notify_request, req);
@@ -436,7 +435,7 @@ static void ubus_process_notify_status(struct ubus_request *req, int id, struct
 
        if (!id) {
                /* first id: ubusd's status message with a list of ids */
-               tb = ubus_parse_msg(buf->data);
+               tb = ubus_parse_msg(buf->data, blob_raw_len(buf->data));
                if (tb[UBUS_ATTR_SUBSCRIBERS]) {
                        blob_for_each_attr(cur, tb[UBUS_ATTR_SUBSCRIBERS], rem) {
                                if (!blob_check_type(blob_data(cur), blob_len(cur), BLOB_ATTR_INT32))