ci: enable unit testing
[project/ubus.git] / cli.c
diff --git a/cli.c b/cli.c
index 1949a171a5c4bfeb31867a607531bb61af3246fd..f566279b4f6d1b54de85985518365167731cba13 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -47,7 +47,7 @@ static const char *format_type(void *priv, struct blob_attr *attr)
                [BLOBMSG_TYPE_TABLE] = "\"Table\"",
        };
        const char *type = NULL;
-       int typeid;
+       size_t typeid;
 
        if (blob_id(attr) != BLOBMSG_TYPE_INT32)
                return NULL;
@@ -65,7 +65,7 @@ static void receive_list_result(struct ubus_context *ctx, struct ubus_object_dat
 {
        struct blob_attr *cur;
        char *s;
-       int rem;
+       size_t rem;
 
        if (simple_output || !verbose) {
                printf("%s\n", obj->path);
@@ -159,7 +159,7 @@ struct cli_listen_data {
        bool timed_out;
 };
 
-static void listen_timeout(struct uloop_timeout *timeout)
+static void ubus_cli_listen_timeout(struct uloop_timeout *timeout)
 {
        struct cli_listen_data *data = container_of(timeout, struct cli_listen_data, timeout);
        data->timed_out = true;
@@ -169,7 +169,7 @@ static void listen_timeout(struct uloop_timeout *timeout)
 static void do_listen(struct ubus_context *ctx, struct cli_listen_data *data)
 {
        memset(data, 0, sizeof(*data));
-       data->timeout.cb = listen_timeout;
+       data->timeout.cb = ubus_cli_listen_timeout;
        uloop_init();
        ubus_add_uloop(ctx);
        if (listen_timeout)
@@ -472,7 +472,7 @@ ubus_cli_monitor_cb(struct ubus_context *ctx, uint32_t seq, struct blob_attr *ms
        bool send;
        char *data;
 
-       blob_parse(msg, tb, policy, UBUS_MONITOR_MAX);
+       blob_parse_untrusted(msg, blob_raw_len(msg), tb, policy, UBUS_MONITOR_MAX);
 
        if (!tb[UBUS_MONITOR_CLIENT] ||
            !tb[UBUS_MONITOR_PEER] ||
@@ -520,7 +520,7 @@ static int ubus_cli_monitor(struct ubus_context *ctx, int argc, char **argv)
 
 static int add_monitor_type(const char *type)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i < ARRAY_SIZE(monitor_types); i++) {
                if (!monitor_types[i] || strcmp(monitor_types[i], type) != 0)
@@ -575,9 +575,10 @@ int main(int argc, char **argv)
 {
        const char *progname, *ubus_socket = NULL;
        struct ubus_context *ctx;
-       char *cmd;
        int ret = 0;
-       int i, ch;
+       char *cmd;
+       size_t i;
+       int ch;
 
        progname = argv[0];