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);
static void ubus_process_pending_msg(struct uloop_timeout *timeout)
{
struct ubus_context *ctx = container_of(timeout, struct ubus_context, pending_timer);
- struct ubus_pending_msg *pending;
+ struct ubus_pending_msg *pending, *tmp;
+
+ list_for_each_entry_safe(pending, tmp, &ctx->pending, list) {
+ if (ctx->stack_depth)
+ break;
- while (!ctx->stack_depth && !list_empty(&ctx->pending)) {
- pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list);
list_del(&pending->list);
ubus_process_msg(ctx, &pending->hdr, -1);
free(pending);
void ubusd_event_cleanup_object(struct ubus_object *obj)
{
- struct event_source *ev;
+ struct event_source *ev, *tmp;
- while (!list_empty(&obj->events)) {
- ev = list_first_entry(&obj->events, struct event_source, list);
+ list_for_each_entry_safe(ev, tmp, &obj->events, list) {
ubusd_delete_event_source(ev);
}
}
static void ubus_unref_object_type(struct ubus_object_type *type)
{
- struct ubus_method *m;
+ struct ubus_method *m, *tmp;
if (--type->refcount > 0)
return;
- while (!list_empty(&type->methods)) {
- m = list_first_entry(&type->methods, struct ubus_method, list);
+ list_for_each_entry_safe(m, tmp, &type->methods, list) {
list_del(&m->list);
free(m);
}
void ubusd_proto_free_client(struct ubus_client *cl)
{
- struct ubus_object *obj;
+ struct ubus_object *obj, *tmp;
- while (!list_empty(&cl->objects)) {
- obj = list_first_entry(&cl->objects, struct ubus_object, list);
+ list_for_each_entry_safe(obj, tmp, &cl->objects, list) {
ubusd_free_object(obj);
}
+
ubus_msg_free(cl->retmsg);
blob_buf_free(&cl->b);