Skip to content

Commit

Permalink
libflux/event: rename event_decodef->event_unpack
Browse files Browse the repository at this point in the history
Rename flux_event_decodef() to flux_event_unpack()
per discussion in flux-framework#1094.

Update unit tests and users in libflux, libjsc,
barrier module, and broker.
  • Loading branch information
garlick committed Jul 10, 2017
1 parent c1c36c8 commit 8bdb894
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/broker/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ int shutdown_decode (const flux_msg_t *msg, double *grace, int *exitcode,
const char *s;
int rc = -1;

if (flux_event_decodef (msg, NULL, "{ s:s s:F s:i s:i}",
"reason", &s,
"grace", grace,
"rank", rank,
"exitcode", exitcode) < 0)
if (flux_event_unpack (msg, NULL, "{ s:s s:F s:i s:i}",
"reason", &s,
"grace", grace,
"rank", rank,
"exitcode", exitcode) < 0)
goto done;
snprintf (reason, reason_len, "%s", s);
rc = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/common/libflux/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ int flux_event_decode (const flux_msg_t *msg, const char **topic, const char **j
return rc;
}

static int flux_event_vdecodef (const flux_msg_t *msg, const char **topic,
const char *fmt, va_list ap)
static int flux_event_vunpack (const flux_msg_t *msg, const char **topic,
const char *fmt, va_list ap)
{
const char *ts;
int rc = -1;
Expand All @@ -92,14 +92,14 @@ static int flux_event_vdecodef (const flux_msg_t *msg, const char **topic,
return rc;
}

int flux_event_decodef (const flux_msg_t *msg, const char **topic,
const char *fmt, ...)
int flux_event_unpack (const flux_msg_t *msg, const char **topic,
const char *fmt, ...)
{
va_list ap;
int rc;

va_start (ap, fmt);
rc = flux_event_vdecodef (msg, topic, fmt, ap);
rc = flux_event_vunpack (msg, topic, fmt, ap);
va_end (ap);
return rc;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ int flux_event_decode (const flux_msg_t *msg, const char **topic,
* jansson unpack style variable arguments for decoding the JSON object
* payload directly. Returns 0 on success, or -1 on failure with errno set.
*/
int flux_event_decodef (const flux_msg_t *msg, const char **topic,
const char *fmt, ...);
int flux_event_unpack (const flux_msg_t *msg, const char **topic,
const char *fmt, ...);

/* Encode an event message.
* If json_str is non-NULL, it is copied to the message payload.
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int flux_heartbeat_decode (const flux_msg_t *msg, int *epoch)
const char *topic_str;
int rc = -1;

if (flux_event_decodef (msg, &topic_str, "{ s:i }", "epoch", epoch) < 0)
if (flux_event_unpack (msg, &topic_str, "{ s:i }", "epoch", epoch) < 0)
goto done;
if (strcmp (topic_str, "hb") != 0) {
errno = EPROTO;
Expand Down
4 changes: 2 additions & 2 deletions src/common/libflux/test/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ int main (int argc, char *argv[])
ok ((msg = flux_event_encodef ("foo.bar", "{s:i}", "foo", 42)) != NULL,
"flux_event_encodef packed payload object");
i = 0;
ok (flux_event_decodef (msg, &topic, "{s:i}", "foo", &i) == 0,
"flux_event_decodef unpacked payload object");
ok (flux_event_unpack (msg, &topic, "{s:i}", "foo", &i) == 0,
"flux_event_unpack unpacked payload object");
ok (i == 42 && topic != NULL && !strcmp (topic, "foo.bar"),
"unpacked payload matched packed");
flux_msg_destroy (msg);
Expand Down
4 changes: 2 additions & 2 deletions src/common/libjsc/jstatctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,12 @@ static void job_state_cb (flux_t *h, flux_msg_handler_t *w,
if (flux_msg_get_topic (msg, &topic) < 0)
goto done;

if (flux_event_decodef (msg, NULL, "{ s:I }", "lwj", &jobid) < 0) {
if (flux_event_unpack (msg, NULL, "{ s:I }", "lwj", &jobid) < 0) {
flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__);
goto done;
}

if (!flux_event_decodef (msg, NULL, "{ s:s }", "kvs_path", &kvs_path)) {
if (!flux_event_unpack (msg, NULL, "{ s:s }", "kvs_path", &kvs_path)) {
if (jscctx_add_jobid_path (getctx (h), jobid, kvs_path) < 0)
flux_log_error (h, "jscctx_add_jobid_path");
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/barrier/barrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ static void exit_event_cb (flux_t *h, flux_msg_handler_t *w,
const char *key;
flux_msg_t *req;

if (flux_event_decodef (msg, NULL, "{s:s s:i !}",
"name", &name,
"errnum", &errnum) < 0) {
if (flux_event_unpack (msg, NULL, "{s:s s:i !}",
"name", &name,
"errnum", &errnum) < 0) {
flux_log_error (h, "%s: decoding event", __FUNCTION__);
return;
}
Expand Down

0 comments on commit 8bdb894

Please sign in to comment.