Skip to content

Commit

Permalink
Merge pull request eclipse-wakaama#390 from eclipse/fix_json
Browse files Browse the repository at this point in the history
Fix JSON serialization issues eclipse-wakaama#370 and eclipse-wakaama#371.
  • Loading branch information
dnav committed Sep 7, 2018
2 parents 3e038d3 + 311d754 commit 2ef18c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/er-coap-13/er-coap-13.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "er-coap-13.h"

#include "liblwm2m.h" /* for lwm2m_malloc() and lwm2m_free() */
#include "../liblwm2m.h" /* for lwm2m_malloc() and lwm2m_free() */

#define DEBUG 0
#if DEBUG
Expand Down
6 changes: 3 additions & 3 deletions core/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ static int prv_serializeValue(lwm2m_data_t * tlvP,
head = JSON_ITEM_STRING_BEGIN_SIZE;

res = utils_base64Encode(tlvP->value.asBuffer.buffer, tlvP->value.asBuffer.length, buffer+head, bufferLen - head);
if (res == 0) return -1;
if (tlvP->value.asBuffer.length != 0 && res == 0) return -1;
head += res;

if (bufferLen - head < JSON_ITEM_STRING_END_SIZE) return -1;
Expand Down Expand Up @@ -1414,7 +1414,7 @@ int json_serialize(lwm2m_uri_t * uriP,
int res;

res = prv_serializeData(targetP + index, NULL, 0, bufferJSON + head, PRV_JSON_BUFFER_SIZE - head);
if (res < 0) return 0;
if (res < 0) return res;
head += res;
}

Expand All @@ -1426,7 +1426,7 @@ int json_serialize(lwm2m_uri_t * uriP,
head = head + JSON_FOOTER_SIZE;

*bufferP = (uint8_t *)lwm2m_malloc(head);
if (*bufferP == NULL) return 0;
if (*bufferP == NULL) return -1;
memcpy(*bufferP, bufferJSON, head);

return head;
Expand Down
2 changes: 1 addition & 1 deletion examples/shared/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int connection_send(connection_t *connP,
port = saddr->sin6_port;
}

fprintf(stderr, "Sending %d bytes to [%s]:%hu\r\n", length, s, ntohs(port));
fprintf(stderr, "Sending %lu bytes to [%s]:%hu\r\n", length, s, ntohs(port));

output_buffer(stderr, buffer, length, 0);
#endif
Expand Down

0 comments on commit 2ef18c5

Please sign in to comment.