Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(seria): Fix const placement and if statement
Browse files Browse the repository at this point in the history
The `const` prefix should be used for constant pointer of pointer here.
However, `const char **` is constant char instead.

The strncmp must be the condition of if statement here, but the if statement
is missing here which result the raw_message will always be false.
  • Loading branch information
howjmay committed May 15, 2019
1 parent 399f91e commit 12ccde7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions serializer/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ status_t ta_send_transfer_req_deserialize(const char* const obj,

json_result = cJSON_GetObjectItemCaseSensitive(json_obj, "message_format");
if (json_result != NULL) {
strncmp("trytes", json_result->valuestring, 6);
raw_message = false;
if (!strncmp("trytes", json_result->valuestring, 6)) {
raw_message = false;
}
}

json_result = cJSON_GetObjectItemCaseSensitive(json_obj, "message");
Expand Down Expand Up @@ -426,7 +427,7 @@ status_t ta_find_transactions_obj_res_serialize(
return ret;
}

status_t receive_mam_message_serialize(char** obj, const char** res) {
status_t receive_mam_message_serialize(char** obj, char** const res) {
status_t ret = SC_OK;
cJSON* json_root = cJSON_CreateObject();
if (json_root == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion serializer/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ status_t ta_find_transactions_obj_res_serialize(
* - SC_OK on success
* - non-zero on error
*/
status_t receive_mam_message_serialize(char** obj, const char** res);
status_t receive_mam_message_serialize(char** obj, char** const res);

/**
* @brief Serialze type of send_mam_res_t to JSON string
Expand Down

0 comments on commit 12ccde7

Please sign in to comment.