Skip to content

Commit

Permalink
ovsdb: Use new ovsdb_log_write_and_free().
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Pettit <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
justinpettit committed May 17, 2018
1 parent fac4786 commit 1d0dead
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
14 changes: 3 additions & 11 deletions ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,6 @@ print_and_free_json(struct json *json)
free(string);
}

static struct ovsdb_error *
write_and_free_json(struct ovsdb_log *log, struct json *json)
{
struct ovsdb_error *error = ovsdb_log_write(log, json);
json_destroy(json);
return error;
}

static void
check_ovsdb_error(struct ovsdb_error *error)
{
Expand Down Expand Up @@ -270,7 +262,7 @@ do_create(struct ovs_cmdl_context *ctx)
/* Create database file. */
check_ovsdb_error(ovsdb_log_open(db_file_name, OVSDB_MAGIC,
OVSDB_LOG_CREATE_EXCL, -1, &log));
check_ovsdb_error(write_and_free_json(log, json));
check_ovsdb_error(ovsdb_log_write_and_free(log, json));
check_ovsdb_error(ovsdb_log_commit_block(log));
ovsdb_log_close(log);
}
Expand Down Expand Up @@ -348,9 +340,9 @@ write_standalone_db(const char *file_name, const char *comment,
return error;
}

error = write_and_free_json(log, ovsdb_schema_to_json(db->schema));
error = ovsdb_log_write_and_free(log, ovsdb_schema_to_json(db->schema));
if (!error) {
error = write_and_free_json(log, ovsdb_to_txn_json(db, comment));
error = ovsdb_log_write_and_free(log, ovsdb_to_txn_json(db, comment));
}
ovsdb_log_close(log);

Expand Down
3 changes: 1 addition & 2 deletions tests/test-ovsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ do_log_io(struct ovs_cmdl_context *ctx)
}
} else if (!strncmp(command, "write:", 6)) {
struct json *json = parse_json(command + 6);
error = ovsdb_log_write(target, json);
json_destroy(json);
error = ovsdb_log_write_and_free(target, json);
} else if (!strcmp(command, "commit")) {
error = ovsdb_log_commit_block(target);
} else if (!strcmp(command, "replace_start")) {
Expand Down

0 comments on commit 1d0dead

Please sign in to comment.