Skip to content

Commit

Permalink
address review comments from @garlick
Browse files Browse the repository at this point in the history
  • Loading branch information
grondo committed May 16, 2018
1 parent 1267aec commit b3b8bf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/bindings/lua/jansson-lua.c
Expand Up @@ -48,8 +48,10 @@ int lua_is_json_null (lua_State *L, int index)

int json_object_to_lua (lua_State *L, json_t *o)
{
if (o == NULL)
if (o == NULL) {
lua_pushnil (L);
return (1);
}
switch (json_typeof (o)) {
case JSON_OBJECT:
json_object_to_lua_table (L, o);
Expand Down Expand Up @@ -171,7 +173,7 @@ int lua_value_to_json (lua_State *L, int i, json_t **valp)
return (-1);
}
*valp = o;
return (0);
return (o ? 0 : -1);
}

int lua_value_to_json_string (lua_State *L, int i, char **strp)
Expand Down Expand Up @@ -209,6 +211,8 @@ static json_t * lua_table_to_json_array (lua_State *L, int index)
{
int rc;
json_t *o = json_array ();
if (o == NULL)
return (NULL);
lua_pushnil (L);
while ((rc = lua_next (L, index))) {
json_t *val;
Expand All @@ -235,7 +239,8 @@ static json_t * lua_table_to_json (lua_State *L, int index)
if (lua_table_is_array (L, index))
return lua_table_to_json_array (L, index);

o = json_object ();
if (!(o = json_object ()))
return (NULL);
lua_pushnil (L);
while (lua_next (L, index)) {
json_t *val;
Expand Down
10 changes: 4 additions & 6 deletions src/bindings/lua/zmsg-lua.c
Expand Up @@ -67,12 +67,10 @@ struct zmsg_info * zmsg_info_create (flux_msg_t **msg, int typemask)
if (zi == NULL)
return (NULL);

if (flux_msg_get_topic (*msg, &topic) < 0 || !(zi->tag = strdup (topic))) {
free (zi);
return (NULL);
}
zi->msg = flux_msg_copy (*msg, true);
if (flux_msg_get_json (zi->msg, &json_str) < 0) {
if ((flux_msg_get_topic (*msg, &topic) < 0)
|| !(zi->tag = strdup (topic))
|| !(zi->msg = flux_msg_copy (*msg, true))
|| (flux_msg_get_json (zi->msg, &json_str) < 0)) {
zmsg_info_destroy (zi);
return (NULL);
}
Expand Down

0 comments on commit b3b8bf1

Please sign in to comment.