Skip to content

Commit

Permalink
wip: json: Rename json_parser_abort() as json_parser_hard_stop()
Browse files Browse the repository at this point in the history
Recently OVS adopted a policy of using the inclusive naming word list v1
[1, 2].

This patch addresses the name of the term abort within the scope of the
function json_parser_abort() by renaming it as json_parser_hard_stop().

As the renamed function are exported as an API to third-party code,
provide a legacy implementation using the old name for compatibility. As
a follow-up scheme to remove these over time may be developed.

[1] df5e5cf ("Documentation: Add section on inclusive language.")
[2] https://inclusivenaming.org/word-lists/

Signed-off-by: Simon Horman <[email protected]>
  • Loading branch information
Simon Horman committed Feb 2, 2024
1 parent 18b3567 commit 6ffe9f9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/openvswitch/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ struct json_parser *json_parser_create(int flags);
size_t json_parser_feed(struct json_parser *, const char *, size_t);
bool json_parser_is_done(const struct json_parser *);
struct json *json_parser_finish(struct json_parser *);
void json_parser_hard_stop(struct json_parser *);

/* Legacy function. Please use json_parser_hard_stop() instead. */
void json_parser_abort(struct json_parser *);

struct json *json_from_string(const char *string);
Expand Down
11 changes: 9 additions & 2 deletions lib/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,13 +1286,13 @@ json_parser_finish(struct json_parser *p)
p->error = NULL;
}

json_parser_abort(p);
json_parser_hard_stop(p);

return json;
}

void
json_parser_abort(struct json_parser *p)
json_parser_hard_stop(struct json_parser *p)
{
if (p) {
ds_destroy(&p->buffer);
Expand All @@ -1306,6 +1306,13 @@ json_parser_abort(struct json_parser *p)
}
}

/* Legacy function. Please use json_parser_hard_stop() instead. */
void
json_parser_abort(struct json_parser *p)
{
json_parser_hard_stop(p);
}

static struct json_parser_node *
json_parser_top(struct json_parser *p)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ jsonrpc_cleanup(struct jsonrpc *rpc)
stream_close(rpc->stream);
rpc->stream = NULL;

json_parser_abort(rpc->parser);
json_parser_hard_stop(rpc->parser);
rpc->parser = NULL;

ofpbuf_list_delete(&rpc->output);
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ parse_body(struct ovsdb_log *file, off_t offset, unsigned long int length,
chunk = MIN(length, sizeof input);
if (fread(input, 1, chunk, file->stream) != chunk) {
sha1_final(&ctx, sha1);
json_parser_abort(parser);
json_parser_hard_stop(parser);
return ovsdb_io_error(ferror(file->stream) ? errno : EOF,
"%s: error reading %lu bytes "
"starting at offset %lld",
Expand Down
2 changes: 1 addition & 1 deletion python/ovs/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ typedef struct {
static void
Parser_dealloc(json_ParserObject * p)
{
json_parser_abort(p->_parser);
json_parser_hard_stop(p->_parser);
Py_TYPE(p)->tp_free(p);
}

Expand Down

0 comments on commit 6ffe9f9

Please sign in to comment.