log: make valgrind less complain by freeing allocated memory
[project/ubox.git] / log / logd.c
index 8cebeb8..a4335ea 100644 (file)
@@ -55,11 +55,6 @@ client_close(struct ustream *s)
        free(cl);
 }
 
-static void
-client_notify_write(struct ustream *s, int bytes)
-{
-}
-
 static void client_notify_state(struct ustream *s)
 {
        client_close(s);
@@ -75,6 +70,7 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
        struct log_head *l;
        int count = 0;
        int fds[2];
+       int ret;
 
        if (msg) {
                blobmsg_parse(&read_policy, 1, &tb, blob_data(msg), blob_len(msg));
@@ -88,7 +84,6 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
        }
        ubus_request_set_fd(ctx, req, fds[0]);
        cl = calloc(1, sizeof(*cl));
-       cl->s.stream.notify_write = client_notify_write;
        cl->s.stream.notify_state = client_notify_state;
        cl->fd = fds[1];
        ustream_fd_init(&cl->s, cl->fd);
@@ -102,7 +97,9 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
                blobmsg_add_u32(&b, "source", l->source);
                blobmsg_add_u64(&b, "time", l->ts.tv_sec * 1000LL);
                l = log_list(count, l);
-               if (ustream_write(&cl->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false) <= 0)
+               ret = ustream_write(&cl->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false);
+               blob_buf_free(&b);
+               if (ret < 0)
                        break;
        }
        return 0;