Skip to content

Commit

Permalink
libflux/message: rename set_jsonf->pack
Browse files Browse the repository at this point in the history
Rename flux_msg_set_jsonf() to flux_msg_pack()
per discussion in flux-framework#1094.

Update unit tests.
  • Loading branch information
garlick committed Jul 13, 2017
1 parent 419250d commit 0d3368c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/common/libflux/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ int flux_msg_vset_jsonf (flux_msg_t *msg, const char *fmt, va_list ap)
return rc;
}

int flux_msg_set_jsonf (flux_msg_t *msg, const char *fmt, ...)
int flux_msg_pack (flux_msg_t *msg, const char *fmt, ...)
{
va_list ap;
int rc;
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool flux_msg_has_payload (const flux_msg_t *msg);
* encoding/decoding the JSON object payload directly from/to its members.
*/
int flux_msg_set_json (flux_msg_t *msg, const char *json_str);
int flux_msg_set_jsonf (flux_msg_t *msg, const char *fmt, ...);
int flux_msg_pack (flux_msg_t *msg, const char *fmt, ...);
int flux_msg_vset_jsonf (flux_msg_t *msg, const char *fmt, va_list ap);

int flux_msg_get_json (const flux_msg_t *msg, const char **json_str);
Expand Down
16 changes: 8 additions & 8 deletions src/common/libflux/test/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ void check_payload_json_formatted (void)
"flux_msg_get_jsonf fails with EPROTO with no payload");

errno = 0;
ok (flux_msg_set_jsonf (msg, "[i,i,i]", 1,2,3) < 0 && errno == EINVAL,
"flux_msg_set_jsonf array fails with EINVAL");
ok (flux_msg_pack (msg, "[i,i,i]", 1,2,3) < 0 && errno == EINVAL,
"flux_msg_pack array fails with EINVAL");
errno = 0;
ok (flux_msg_set_jsonf (msg, "i", 3.14) < 0 && errno == EINVAL,
"flux_msg_set_jsonf scalar fails with EINVAL");
ok (flux_msg_set_jsonf (msg, "{s:i, s:s}", "foo", 42, "bar", "baz") == 0,
"flux_msg_set_jsonf object works");
ok (flux_msg_pack (msg, "i", 3.14) < 0 && errno == EINVAL,
"flux_msg_pack scalar fails with EINVAL");
ok (flux_msg_pack (msg, "{s:i, s:s}", "foo", 42, "bar", "baz") == 0,
"flux_msg_pack object works");
i = 0;
s = NULL;
ok (flux_msg_get_jsonf (msg, "{s:i, s:s}", "foo", &i, "bar", &s) == 0,
Expand All @@ -193,8 +193,8 @@ void check_payload_json_formatted (void)
"decoded content matches encoded content");

/* reset payload */
ok (flux_msg_set_jsonf (msg, "{s:i, s:s}", "foo", 43, "bar", "smurf") == 0,
"flux_msg_set_jsonf can replace JSON object payload");
ok (flux_msg_pack (msg, "{s:i, s:s}", "foo", 43, "bar", "smurf") == 0,
"flux_msg_pack can replace JSON object payload");
i = 0;
s = NULL;
ok (flux_msg_get_jsonf (msg, "{s:i, s:s}", "foo", &i, "bar", &s) == 0,
Expand Down

0 comments on commit 0d3368c

Please sign in to comment.