Skip to content

Commit

Permalink
Merge pull request #832 from morrone/json_object_pointer
Browse files Browse the repository at this point in the history
Remove JSON typedef, just use json_object *
  • Loading branch information
grondo authored Oct 4, 2016
2 parents 323aa53 + 37ae2b3 commit dc58fcb
Show file tree
Hide file tree
Showing 61 changed files with 477 additions and 448 deletions.
4 changes: 2 additions & 2 deletions doc/man3/treduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void forward (flux_reduce_t *r, int batchnum, void *arg)
flux_rpc_t *rpc;

while ((item = flux_reduce_pop (r))) {
JSON out = Jnew ();
json_object *out = Jnew ();
Jadd_int (out, "batchnum", batchnum);
Jadd_str (out, "nodeset", item);
rpc = flux_rpc (ctx->h, "treduce.forward", Jtostr (out),
Expand Down Expand Up @@ -77,7 +77,7 @@ void forward_cb (flux_t h, flux_msg_handler_t *w,
{
struct context *ctx = arg;
const char *json_str, *nodeset_str;
JSON in = NULL;
json_object *in = NULL;
int batchnum;
char *item;

Expand Down
4 changes: 2 additions & 2 deletions doc/man3/trpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
void get_rank (flux_rpc_t *rpc)
{
const char *json_str;
JSON o;
json_object *o;
const char *rank;

if (flux_rpc_get (rpc, NULL, &json_str) < 0)
Expand All @@ -20,7 +20,7 @@ int main (int argc, char **argv)
{
flux_t h;
flux_rpc_t *rpc;
JSON o = Jnew();
json_object *o = Jnew();

if (!(h = flux_open (NULL, 0)))
log_err_exit ("flux_open");
Expand Down
4 changes: 2 additions & 2 deletions doc/man3/trpc_then.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
void get_rank (flux_rpc_t *rpc, void *arg)
{
const char *json_str;
JSON o;
json_object *o;
const char *rank;

if (flux_rpc_get (rpc, NULL, &json_str) < 0)
Expand All @@ -21,7 +21,7 @@ int main (int argc, char **argv)
{
flux_t h;
flux_rpc_t *rpc;
JSON o = Jnew ();
json_object *o = Jnew ();

Jadd_str (o, "name", "rank");
if (!(h = flux_open (NULL, 0)))
Expand Down
4 changes: 2 additions & 2 deletions doc/man3/trpc_then_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
void get_rank (flux_rpc_t *rpc, void *arg)
{
const char *json_str;
JSON o;
json_object *o;
const char *rank;
uint32_t nodeid;

Expand All @@ -21,7 +21,7 @@ int main (int argc, char **argv)
{
flux_t h;
flux_rpc_t *rpc;
JSON o = Jnew();
json_object *o = Jnew();

Jadd_str (o, "name", "rank");
if (!(h = flux_open (NULL, 0)))
Expand Down
48 changes: 24 additions & 24 deletions src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,14 +1727,14 @@ static int terminate_subprocesses_by_uuid (ctx_t *ctx, char *id)
return (0);
}

static JSON subprocess_json_info (struct subprocess *p)
static json_object *subprocess_json_info (struct subprocess *p)
{
int i;
char buf [MAXPATHLEN];
const char *cwd;
char *sender = NULL;
JSON o = Jnew ();
JSON a = Jnew_ar ();
json_object *o = Jnew ();
json_object *a = Jnew_ar ();

Jadd_int (o, "pid", subprocess_pid (p));
for (i = 0; i < subprocess_get_argc (p); i++) {
Expand All @@ -1758,15 +1758,15 @@ static int cmb_ps_cb (zmsg_t **zmsg, void *arg)
{
struct subprocess *p;
ctx_t *ctx = arg;
JSON out = Jnew ();
JSON procs = Jnew_ar ();
json_object *out = Jnew ();
json_object *procs = Jnew_ar ();
int rc;

Jadd_int (out, "rank", ctx->rank);

p = subprocess_manager_first (ctx->sm);
while (p) {
JSON o = subprocess_json_info (p);
json_object *o = subprocess_json_info (p);
/* Avoid shortjson here so we don't take an unnecessary
* reference to 'o'.
*/
Expand Down Expand Up @@ -1814,8 +1814,8 @@ static int cmb_attrget_cb (zmsg_t **zmsg, void *arg)
ctx_t *ctx = arg;
const char *json_str, *name, *val;
int flags;
JSON in = NULL;
JSON out = Jnew ();
json_object *in = NULL;
json_object *out = Jnew ();
int rc = -1;

if (flux_request_decode (*zmsg, NULL, &json_str) < 0)
Expand Down Expand Up @@ -1846,7 +1846,7 @@ static int cmb_attrset_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
const char *json_str, *name, *val = NULL;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

if (flux_request_decode (*zmsg, NULL, &json_str) < 0)
Expand Down Expand Up @@ -1879,8 +1879,8 @@ static int cmb_attrlist_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
const char *name;
JSON out = Jnew ();
JSON array = Jnew_ar ();
json_object *out = Jnew ();
json_object *array = Jnew_ar ();
int rc = -1;

if (flux_request_decode (*zmsg, NULL, NULL) < 0)
Expand All @@ -1904,7 +1904,7 @@ static int cmb_attrlist_cb (zmsg_t **zmsg, void *arg)
static int cmb_rusage_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
JSON out = NULL;
json_object *out = NULL;
int rc = -1;

if (getrusage_json (RUSAGE_THREAD, &out) < 0)
Expand Down Expand Up @@ -2029,7 +2029,7 @@ static int cmb_lsmod_cb (zmsg_t **zmsg, void *arg)
static int cmb_lspeer_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
JSON out = overlay_lspeer_encode (ctx->overlay);
json_object *out = overlay_lspeer_encode (ctx->overlay);
int rc = flux_respond (ctx->h, *zmsg, 0, Jtostr (out));
zmsg_destroy (zmsg);
Jput (out);
Expand All @@ -2039,7 +2039,7 @@ static int cmb_lspeer_cb (zmsg_t **zmsg, void *arg)
static int cmb_ping_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
JSON inout = NULL;
json_object *inout = NULL;
const char *json_str;
char *s = NULL;
char *route = NULL;
Expand Down Expand Up @@ -2068,7 +2068,7 @@ static int cmb_ping_cb (zmsg_t **zmsg, void *arg)
static int cmb_reparent_cb (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
JSON in = NULL;
json_object *in = NULL;
const char *uri;
const char *json_str;
bool recycled = false;
Expand All @@ -2092,7 +2092,7 @@ static int cmb_reparent_cb (zmsg_t **zmsg, void *arg)

static int cmb_panic_cb (zmsg_t **zmsg, void *arg)
{
JSON in = NULL;
json_object *in = NULL;
const char *s = NULL;
const char *json_str;
int rc = -1;
Expand Down Expand Up @@ -2129,7 +2129,7 @@ static int cmb_dmesg_clear_cb (zmsg_t **zmsg, void *arg)
ctx_t *ctx = arg;
const char *json_str;
int seq;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

if (flux_request_decode (*zmsg, NULL, &json_str) < 0)
Expand All @@ -2154,8 +2154,8 @@ static void cmb_dmesg (const flux_msg_t *msg, void *arg)
const char *buf;
int len;
int seq;
JSON in = NULL;
JSON out = NULL;
json_object *in = NULL;
json_object *out = NULL;
bool follow;
int rc = -1;

Expand Down Expand Up @@ -2233,7 +2233,7 @@ static int cmb_sub_cb (zmsg_t **zmsg, void *arg)
ctx_t *ctx = arg;
const char *json_str;
char *uuid = NULL;
JSON in = NULL;
json_object *in = NULL;
const char *topic;
int rc = -1;

Expand Down Expand Up @@ -2266,7 +2266,7 @@ static int cmb_unsub_cb (zmsg_t **zmsg, void *arg)
ctx_t *ctx = arg;
const char *json_str;
char *uuid = NULL;
JSON in = NULL;
json_object *in = NULL;
const char *topic;
int rc = -1;

Expand Down Expand Up @@ -2297,7 +2297,7 @@ static int cmb_unsub_cb (zmsg_t **zmsg, void *arg)
static int cmb_seq (zmsg_t **zmsg, void *arg)
{
ctx_t *ctx = arg;
JSON out = NULL;
json_object *out = NULL;
int rc = sequence_request_handler (ctx->seq, (flux_msg_t *) *zmsg, &out);

if (flux_respond (ctx->h, *zmsg, rc < 0 ? errno : 0, Jtostr (out)) < 0)
Expand All @@ -2311,7 +2311,7 @@ static int cmb_seq (zmsg_t **zmsg, void *arg)
static int cmb_heaptrace_start_cb (zmsg_t **zmsg, void *arg)
{
const char *json_str, *filename;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

if (flux_request_decode (*zmsg, NULL, &json_str) < 0)
Expand All @@ -2338,7 +2338,7 @@ static int cmb_heaptrace_start_cb (zmsg_t **zmsg, void *arg)
static int cmb_heaptrace_dump_cb (zmsg_t **zmsg, void *arg)
{
const char *json_str, *reason;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

if (flux_request_decode (*zmsg, NULL, &json_str) < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/broker/content-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ static void content_backing_request (flux_t h, flux_msg_handler_t *w,
content_cache_t *cache = arg;
const char *json_str;
const char *name;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;
bool backing;

Expand Down Expand Up @@ -735,7 +735,7 @@ static void content_stats_request (flux_t h, flux_msg_handler_t *w,
const flux_msg_t *msg, void *arg)
{
content_cache_t *cache = arg;
JSON out = Jnew ();
json_object *out = Jnew ();
int rc = -1;

if (flux_request_decode (msg, NULL, NULL) < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/broker/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static void join_request (flux_t h, flux_msg_handler_t *w,
hello_t *hello = arg;
const char *json_str;
int count, batch;
JSON in = NULL;
json_object *in = NULL;

if (flux_request_decode (msg, NULL, &json_str) < 0)
log_err_exit ("hello: flux_request_decode");
Expand Down Expand Up @@ -281,7 +281,7 @@ static void r_forward (flux_reduce_t *r, int batch, void *arg)
flux_rpc_t *rpc;
hello_t *hello = arg;
int count = (uintptr_t)flux_reduce_pop (r);
JSON in = Jnew ();
json_object *in = Jnew ();

assert (batch == 0);
assert (count > 0);
Expand Down
6 changes: 3 additions & 3 deletions src/broker/modservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void ping_cb (flux_t h, flux_msg_handler_t *w,
{
module_t *p = arg;
const char *json_str;
JSON o = NULL;
json_object *o = NULL;
char *route = NULL;
char *route_plus_uuid = NULL;
int rc = -1;
Expand Down Expand Up @@ -125,7 +125,7 @@ static void stats_get_cb (flux_t h, flux_msg_handler_t *w,
const flux_msg_t *msg, void *arg)
{
flux_msgcounters_t mcs;
JSON out = Jnew ();
json_object *out = Jnew ();

flux_get_msgcounters (h, &mcs);
Jadd_int (out, "#request (tx)", mcs.request_tx);
Expand Down Expand Up @@ -159,7 +159,7 @@ static void stats_clear_request_cb (flux_t h, flux_msg_handler_t *w,
static void rusage_cb (flux_t h, flux_msg_handler_t *w,
const flux_msg_t *msg, void *arg)
{
JSON out = NULL;
json_object *out = NULL;
int rc = -1;

if (getrusage_json (RUSAGE_THREAD, &out) < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/broker/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ void overlay_set_idle_warning (overlay_t *ov, int heartbeats)

json_object *overlay_lspeer_encode (overlay_t *ov)
{
JSON out = Jnew ();
json_object *out = Jnew ();
const char *uuid;
child_t *child;

FOREACH_ZHASH (ov->children, uuid, child) {
JSON o = Jnew ();
json_object *o = Jnew ();
Jadd_int (o, "idle", ov->epoch - child->lastseen);
Jadd_obj (out, uuid, o); /* takes ref on 'o' */
Jput (o);
Expand Down
12 changes: 7 additions & 5 deletions src/broker/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ static int seq_cmp_and_set (seqhash_t *s, const char *name,
return (0);
}

static int handle_seq_destroy (seqhash_t *s, JSON in, JSON *outp)
static int handle_seq_destroy (seqhash_t *s, json_object *in,
json_object **outp)
{
const char *name;
if (!Jget_str (in, "name", &name)) {
Expand All @@ -147,7 +148,7 @@ static int handle_seq_destroy (seqhash_t *s, JSON in, JSON *outp)
return (0);
}

static int handle_seq_set (seqhash_t *s, JSON in, JSON *outp)
static int handle_seq_set (seqhash_t *s, json_object *in, json_object **outp)
{
const char *name;
int64_t old, v;
Expand All @@ -168,7 +169,7 @@ static int handle_seq_set (seqhash_t *s, JSON in, JSON *outp)
return (0);
}

static int handle_seq_fetch (seqhash_t *s, JSON in, JSON *outp)
static int handle_seq_fetch (seqhash_t *s, json_object *in, json_object **outp)
{
const char *name;
bool create = false;
Expand Down Expand Up @@ -202,11 +203,12 @@ static int handle_seq_fetch (seqhash_t *s, JSON in, JSON *outp)
return (0);
}

int sequence_request_handler (seqhash_t *s, const flux_msg_t *msg, JSON *outp)
int sequence_request_handler (seqhash_t *s, const flux_msg_t *msg,
json_object **outp)
{
const char *json_str, *topic;
const char *method;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

*outp = NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/broker/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef struct seq_struct seqhash_t;
seqhash_t *sequence_hash_create (void);
void sequence_hash_destroy (seqhash_t *seq);

int sequence_request_handler (seqhash_t *seq, const flux_msg_t *msg, JSON *op);
int sequence_request_handler (seqhash_t *seq, const flux_msg_t *msg,
json_object **op);

#endif /* BROKER_SEQUENCE_H */

Expand Down
4 changes: 2 additions & 2 deletions src/broker/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ flux_msg_t *shutdown_vencode (double grace, int exitcode, int rank,
const char *fmt, va_list ap)
{
flux_msg_t *msg;
JSON out = Jnew ();
json_object *out = Jnew ();
char reason[REASON_MAX];

vsnprintf (reason, sizeof (reason), fmt, ap);
Expand Down Expand Up @@ -184,7 +184,7 @@ int shutdown_decode (const flux_msg_t *msg, double *grace, int *exitcode,
int *rank, char *reason, int reason_len)
{
const char *json_str, *s;
JSON in = NULL;
json_object *in = NULL;
int rc = -1;

if (flux_event_decode (msg, NULL, &json_str) < 0
Expand Down
Loading

0 comments on commit dc58fcb

Please sign in to comment.