Skip to content

Commit

Permalink
lib/jsonrpc: make use of ofpbuf_use_ds()
Browse files Browse the repository at this point in the history
Make use of ofpbuf_use_ds() to simplify code.

Signed-off-by: Andy Zhou <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
azhou-nicira committed Sep 1, 2015
1 parent 71cc59f commit 2db0218
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 2db0218

Please sign in to comment.