[ovs-dev] [PATCH 5/8] lib/jsonrpc: make use of ofpbuf_use_ds()

Andy Zhou azhou at nicira.com
Wed Aug 12 00:55:11 UTC 2015


Make use of ofpbuf_use_ds() to simplify code.

Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 lib/jsonrpc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index 282f3bb..b482777 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -240,7 +240,6 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
     struct json *json;
     struct ds ds = DS_EMPTY_INITIALIZER;
     size_t length;
-    char *s;
 
     if (rpc->status) {
         jsonrpc_msg_destroy(msg);
@@ -252,12 +251,10 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
     json = jsonrpc_msg_to_json(msg);
     json_to_ds(json, 0, &ds);
     length = ds.length;
-    s = ds_steal_cstr(&ds);
     json_destroy(json);
 
     buf = xmalloc(sizeof *buf);
-    ofpbuf_use(buf, s, length);
-    buf->size = length;
+    ofpbuf_use_ds(buf, &ds);
     list_push_back(&rpc->output, &buf->list_node);
     rpc->output_count++;
     rpc->backlog += length;
-- 
1.9.1




More information about the dev mailing list