Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

cclient: fix warnings #1177

Merged
merged 1 commit into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cclient/api/extended/get_account_data.c
Expand Up @@ -107,7 +107,7 @@ retcode_t iota_client_get_account_data(iota_client_service_t const* const serv,
ret_code = iota_client_get_balances(serv, balances_req, balances_res);
if (!ret_code) {
// count all balances
for (int i = 0; i < get_balances_res_balances_num(balances_res); i++) {
for (size_t i = 0; i < get_balances_res_balances_num(balances_res); i++) {
out_account->balance += get_balances_res_balances_at(balances_res, i);
}
}
Expand Down
4 changes: 2 additions & 2 deletions cclient/response/get_balances.c
Expand Up @@ -34,7 +34,7 @@ void get_balances_res_free(get_balances_res_t** res) {

size_t get_balances_res_balances_num(get_balances_res_t const* const res) { return utarray_len(res->balances); }

uint64_t get_balances_res_balances_at(get_balances_res_t const* const res, int const index) {
uint64_t get_balances_res_balances_at(get_balances_res_t const* const res, size_t const index) {
return *(uint64_t*)utarray_eltptr(res->balances, index);
}

Expand All @@ -47,4 +47,4 @@ retcode_t get_balances_res_balances_add(get_balances_res_t* const res, uint64_t
}
utarray_push_back(res->balances, &value);
return RC_OK;
}
}
4 changes: 2 additions & 2 deletions cclient/response/get_balances.h
Expand Up @@ -94,7 +94,7 @@ size_t get_balances_res_balances_num(get_balances_res_t const* const res);
* @param[in] index An index of the balance list.
* @return The balance to the corresponding index.
*/
uint64_t get_balances_res_balances_at(get_balances_res_t const* const res, int const index);
uint64_t get_balances_res_balances_at(get_balances_res_t const* const res, size_t const index);

/**
* @brief Adds a balance to the response object.
Expand All @@ -111,4 +111,4 @@ retcode_t get_balances_res_balances_add(get_balances_res_t* const res, uint64_t

#endif // CCLIENT_RESPONSE_GET_BALANCES_H

/** @} */
/** @} */
2 changes: 1 addition & 1 deletion cclient/response/get_inclusion_states.c
Expand Up @@ -26,7 +26,7 @@ retcode_t get_inclusion_states_res_states_add(get_inclusion_states_res_t* res, i
return RC_OK;
}

bool get_inclusion_states_res_states_at(get_inclusion_states_res_t* in, int index) {
bool get_inclusion_states_res_states_at(get_inclusion_states_res_t* in, size_t index) {
int* b = (int*)utarray_eltptr(in->states, index);
if (b != NULL) {
return (*b > 0) ? true : false;
Expand Down
4 changes: 2 additions & 2 deletions cclient/response/get_inclusion_states.h
Expand Up @@ -65,7 +65,7 @@ void get_inclusion_states_res_free(get_inclusion_states_res_t** res);
* @param[in] index An index of the list.
* @return Boolean. <b>True</b> means the transaction was confirmed, otherwise <b>false</b>.
*/
bool get_inclusion_states_res_states_at(get_inclusion_states_res_t* res, int index);
bool get_inclusion_states_res_states_at(get_inclusion_states_res_t* res, size_t index);

/**
* @brief Gets the size of the states list.
Expand All @@ -81,4 +81,4 @@ size_t get_inclusion_states_res_states_count(get_inclusion_states_res_t* res);

#endif // CCLIENT_RESPONSE_GET_INCLUSION_STATES_H

/** @} */
/** @} */
2 changes: 1 addition & 1 deletion cclient/response/get_neighbors.c
Expand Up @@ -61,7 +61,7 @@ retcode_t get_neighbors_res_add_neighbor(get_neighbors_res_t* res, char const* c
return RC_OK;
}

neighbor_info_t* get_neighbors_res_neighbor_at(get_neighbors_res_t* res, int index) {
neighbor_info_t* get_neighbors_res_neighbor_at(get_neighbors_res_t* res, size_t index) {
if (!res) {
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion cclient/response/get_neighbors.h
Expand Up @@ -102,7 +102,7 @@ static inline size_t get_neighbors_res_num(get_neighbors_res_t* res) { return ut
* @param[in] index An index of the neighbor list.
* @return A pointer to a neighbor object.
*/
neighbor_info_t* get_neighbors_res_neighbor_at(get_neighbors_res_t* res, int index);
neighbor_info_t* get_neighbors_res_neighbor_at(get_neighbors_res_t* res, size_t index);

/**
* @brief Adds a neighbor to the response.
Expand Down
8 changes: 5 additions & 3 deletions cclient/response/get_transactions_to_approve.h
Expand Up @@ -63,7 +63,8 @@ static inline void get_transactions_to_approve_res_set_branch(get_transactions_t
* @param[in] res The response object.
* @return A pointer to the branch transaction hash.
*/
static inline flex_trit_t* const get_transactions_to_approve_res_branch(get_transactions_to_approve_res_t* const res) {
static inline flex_trit_t const* get_transactions_to_approve_res_branch(
get_transactions_to_approve_res_t const* const res) {
return res->branch;
}

Expand All @@ -84,7 +85,8 @@ static inline void get_transactions_to_approve_res_set_trunk(get_transactions_to
* @param[in] res The response object.
* @return A pointer to the trunk transaction hash.
*/
static inline flex_trit_t* const get_transactions_to_approve_res_trunk(get_transactions_to_approve_res_t* const res) {
static inline flex_trit_t const* get_transactions_to_approve_res_trunk(
get_transactions_to_approve_res_t const* const res) {
return res->trunk;
}

Expand All @@ -94,4 +96,4 @@ static inline flex_trit_t* const get_transactions_to_approve_res_trunk(get_trans

#endif // CCLIENT_RESPONSE_GET_TRANSACTIONS_TO_APPROVE_H

/** @} */
/** @} */
8 changes: 4 additions & 4 deletions cclient/serialization/json/helpers.c
Expand Up @@ -168,7 +168,7 @@ retcode_t json_get_uint8(cJSON const* const json_obj, char const* const obj_name
return RC_CCLIENT_JSON_KEY;
}

if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && json_value->valueint <= UINT8_MAX) {
if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && (uint8_t)json_value->valueint <= UINT8_MAX) {
*num = (uint8_t)json_value->valueint;
} else {
log_error(json_logger_id, "[%s:%d] %s not number\n", __func__, __LINE__, STR_CCLIENT_JSON_PARSE);
Expand All @@ -185,7 +185,7 @@ retcode_t json_get_uint16(cJSON const* const json_obj, char const* const obj_nam
return RC_CCLIENT_JSON_KEY;
}

if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && json_value->valueint <= UINT16_MAX) {
if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && (uint16_t)json_value->valueint <= UINT16_MAX) {
*num = (uint16_t)json_value->valueint;
} else {
log_error(json_logger_id, "[%s:%d] %s not number\n", __func__, __LINE__, STR_CCLIENT_JSON_PARSE);
Expand All @@ -202,7 +202,7 @@ retcode_t json_get_uint32(cJSON const* const json_obj, char const* const obj_nam
return RC_CCLIENT_JSON_KEY;
}

if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && json_value->valueint <= UINT32_MAX) {
if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && (uint32_t)json_value->valueint <= UINT32_MAX) {
*num = (uint32_t)json_value->valueint;
} else {
log_error(json_logger_id, "[%s:%d] %s not number\n", __func__, __LINE__, STR_CCLIENT_JSON_PARSE);
Expand All @@ -219,7 +219,7 @@ retcode_t json_get_uint64(cJSON const* const json_obj, char const* const obj_nam
return RC_CCLIENT_JSON_KEY;
}

if (cJSON_IsNumber(json_value)) {
if (cJSON_IsNumber(json_value) && json_value->valueint >= 0 && (uint64_t)json_value->valueint <= UINT64_MAX) {
*num = (uint64_t)json_value->valuedouble;
} else {
log_error(json_logger_id, "[%s:%d] %s not number\n", __func__, __LINE__, STR_CCLIENT_JSON_PARSE);
Expand Down