summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2020-07-27 07:07:34 +0200
committerRafał Miłecki <rafal@milecki.pl>2020-08-05 08:24:19 +0200
commit628341fae41230627ff4055b248698bb6ed007a8 (patch)
treeab9eac66a19b51a8554d6697734b8782b22275ac
parent9d663e76bd3ac91b18633eb8f4f0bfc6996c5875 (diff)
ubus: use local "blob_buf" in uh_ubus_handle_request_object()
This follows two other functions logic: uh_ubus_send_request() and uh_ubus_allowed(). Thanks to this change global "buf" variable is used only for replies and doesn't require state tracking & reinitialization. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--ubus.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ubus.c b/ubus.c
index ddc2f05..062e973 100644
--- a/ubus.c
+++ b/ubus.c
@@ -194,7 +194,6 @@ static void uh_ubus_init_response(struct client *cl)
struct dispatch_ubus *du = &cl->dispatch.ubus;
struct json_object *obj = du->jsobj_cur, *obj2 = NULL;
- blob_buf_init(&buf, 0);
blobmsg_add_string(&buf, "jsonrpc", "2.0");
if (obj)
@@ -520,6 +519,7 @@ static void uh_ubus_handle_request_object(struct client *cl, struct json_object
struct dispatch_ubus *du = &cl->dispatch.ubus;
struct rpc_data data = {};
enum rpc_error err = ERROR_PARSE;
+ static struct blob_buf req;
uh_client_ref(cl);
@@ -527,11 +527,11 @@ static void uh_ubus_handle_request_object(struct client *cl, struct json_object
goto error;
du->jsobj_cur = obj;
- blob_buf_init(&buf, 0);
- if (!blobmsg_add_object(&buf, obj))
+ blob_buf_init(&req, 0);
+ if (!blobmsg_add_object(&req, obj))
goto error;
- if (!parse_json_rpc(&data, buf.head))
+ if (!parse_json_rpc(&data, req.head))
goto error;
if (!strcmp(data.method, "call")) {