Browse code

bytecode: fixed a compiler issue and warnings

Kevin Lin authored on 2014/06/04 00:47:57
Showing 2 changed files
... ...
@@ -44,6 +44,9 @@
44 44
 #include "bytecode_api.h"
45 45
 #include "bytecode_api_impl.h"
46 46
 #include "builtin_bytecodes.h"
47
+#if HAVE_JSON
48
+#include "json.h"
49
+#endif
47 50
 
48 51
 #define MAX_BC 64
49 52
 #define BC_EVENTS_PER_SIG 2
... ...
@@ -1547,15 +1547,15 @@ int32_t cli_bcapi_json_is_active(struct cli_bc_ctx *ctx )
1547 1547
 static int32_t cli_bcapi_json_objs_init(struct cli_bc_ctx *ctx) {
1548 1548
 #if HAVE_JSON 
1549 1549
     unsigned n = ctx->njsonobjs + 1;
1550
-    json_object **j, jobjs = (json_object**)(ctx->jsonobjs);
1550
+    json_object **j, **jobjs = (json_object **)(ctx->jsonobjs);
1551 1551
     cli_ctx *cctx = (cli_ctx *)ctx->ctx;
1552 1552
 
1553
-    j = cli_realloc(jobjs, sizeof(*jobjs)*n);
1553
+    j = cli_realloc(jobjs, sizeof(json_object *)*n);
1554 1554
     if (!j) { /* memory allocation failure */
1555 1555
         cli_event_error_oom(EV, 0);
1556 1556
         return -1;
1557 1557
     }
1558
-    ctx->jsonobjs = j;
1558
+    ctx->jsonobjs = (void **)j;
1559 1559
     ctx->njsonobjs = n;
1560 1560
     j[n-1] = cctx->properties;    
1561 1561
 
... ...
@@ -1578,7 +1578,7 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in
1578 1578
 {
1579 1579
 #if HAVE_JSON
1580 1580
     unsigned n;
1581
-    json_object **j, *jobj, **jobjs = (json_object**)(ctx->jsonobjs);
1581
+    json_object **j, *jobj, **jobjs = (json_object **)(ctx->jsonobjs);
1582 1582
     char *namep;
1583 1583
 
1584 1584
     INIT_JSON_OBJS(ctx);
... ...
@@ -1608,13 +1608,13 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in
1608 1608
         return 0;
1609 1609
     }
1610 1610
 
1611
-    j = cli_realloc(jobjs, sizeof(*jobjs)*n);
1611
+    j = cli_realloc(jobjs, sizeof(json_object *)*n);
1612 1612
     if (!j) { /* memory allocation failure */
1613 1613
         free(namep);
1614 1614
         cli_event_error_oom(EV, 0);
1615 1615
         return -1;
1616 1616
     }
1617
-    ctx->jsonobjs = j;
1617
+    ctx->jsonobjs = (void **)j;
1618 1618
     ctx->njsonobjs = n;
1619 1619
     j[n-1] = jobj;
1620 1620
 
... ...
@@ -1631,7 +1631,7 @@ int32_t cli_bcapi_json_get_type(struct cli_bc_ctx *ctx, int32_t objid)
1631 1631
 {
1632 1632
 #if HAVE_JSON
1633 1633
     enum json_type type;
1634
-    json_object **jobjs = (json_object**)(ctx->jsonobjs);
1634
+    json_object **jobjs = (json_object **)(ctx->jsonobjs);
1635 1635
 
1636 1636
     INIT_JSON_OBJS(ctx);
1637 1637
     if (objid < 0 || objid >= ctx->njsonobjs) {
... ...
@@ -1669,7 +1669,7 @@ int32_t cli_bcapi_json_get_array_length(struct cli_bc_ctx *ctx, int32_t objid)
1669 1669
 {
1670 1670
 #if HAVE_JSON
1671 1671
     enum json_type type;
1672
-    json_object **jobjs = (json_object**)(ctx->jsonobjs);
1672
+    json_object **jobjs = (json_object **)(ctx->jsonobjs);
1673 1673
 
1674 1674
     INIT_JSON_OBJS(ctx);
1675 1675
     if (objid < 0 || objid >= ctx->njsonobjs) {
... ...
@@ -1695,7 +1695,7 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_
1695 1695
     enum json_type type;
1696 1696
     unsigned n;
1697 1697
     int length;
1698
-    json_object **j, *jarr = NULL, *jobj = NULL, **jobjs = (json_object**)(ctx->jsonobjs);
1698
+    json_object **j, *jarr = NULL, *jobj = NULL, **jobjs = (json_object **)(ctx->jsonobjs);
1699 1699
 
1700 1700
     INIT_JSON_OBJS(ctx);
1701 1701
     if (objid < 0 || objid >= ctx->njsonobjs) {
... ...
@@ -1721,12 +1721,12 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_
1721 1721
             return 0;
1722 1722
         }
1723 1723
 
1724
-        j = cli_realloc(jobjs, sizeof(*jobjs)*n);
1724
+        j = cli_realloc(jobjs, sizeof(json_object *)*n);
1725 1725
         if (!j) { /* memory allocation failure */
1726 1726
             cli_event_error_oom(EV, 0);
1727 1727
             return -1;
1728 1728
         }
1729
-        ctx->jsonobjs = j;
1729
+        ctx->jsonobjs = (void **)j;
1730 1730
         ctx->njsonobjs = n;
1731 1731
         j[n-1] = jobj;
1732 1732
 
... ...
@@ -1745,7 +1745,7 @@ int32_t cli_bcapi_json_get_string_length(struct cli_bc_ctx *ctx, int32_t objid)
1745 1745
 {
1746 1746
 #if HAVE_JSON
1747 1747
     enum json_type type;
1748
-    json_object *jobj, **jobjs = (json_object**)(ctx->jsonobjs);
1748
+    json_object *jobj, **jobjs = (json_object **)(ctx->jsonobjs);
1749 1749
     int32_t len;
1750 1750
     const char *jstr;
1751 1751
 
... ...
@@ -1779,7 +1779,7 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s
1779 1779
 {
1780 1780
 #if HAVE_JSON
1781 1781
     enum json_type type;
1782
-    json_object *jobj, **jobjs = (json_object**)(ctx->jsonobjs);
1782
+    json_object *jobj, **jobjs = (json_object **)(ctx->jsonobjs);
1783 1783
     int32_t len;
1784 1784
     const char *jstr;
1785 1785
 
... ...
@@ -1823,7 +1823,7 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s
1823 1823
 int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid)
1824 1824
 {
1825 1825
 #if HAVE_JSON
1826
-    json_object *jobj, **jobjs = (json_object**)(ctx->jsonobjs);
1826
+    json_object *jobj, **jobjs = (json_object **)(ctx->jsonobjs);
1827 1827
 
1828 1828
     INIT_JSON_OBJS(ctx);
1829 1829
     if (objid < 0 || objid >= ctx->njsonobjs) {
... ...
@@ -1842,7 +1842,7 @@ int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid)
1842 1842
 int32_t cli_bcapi_json_get_int(struct cli_bc_ctx *ctx, int32_t objid)
1843 1843
 {
1844 1844
 #if HAVE_JSON
1845
-    json_object *jobj, **jobjs = (json_object**)(ctx->jsonobjs);
1845
+    json_object *jobj, **jobjs = (json_object **)(ctx->jsonobjs);
1846 1846
 
1847 1847
     INIT_JSON_OBJS(ctx);
1848 1848
     if (objid < 0 || objid >= ctx->njsonobjs) {