Skip to content

Commit

Permalink
Merge pull request #15 from RCSN/bugfix/fixed_build_waring_for_ses
Browse files Browse the repository at this point in the history
modbus: fixed some warnings for some compiltion IDE such as ses
  • Loading branch information
loogg authored Jan 28, 2024
2 parents 50bda72 + f8b5eae commit c2af9ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/agile_modbus_rtu.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static int agile_modbus_rtu_build_response_basis(agile_modbus_sft_t *sft, uint8_
*/
static int agile_modbus_rtu_prepare_response_tid(const uint8_t *req, int *req_length)
{
(void)req;
(*req_length) -= AGILE_MODBUS_RTU_CHECKSUM_LENGTH;
/* No TID */
return 0;
Expand Down Expand Up @@ -203,7 +204,7 @@ static int agile_modbus_rtu_check_integrity(agile_modbus_t *ctx, uint8_t *msg, c
{
uint16_t crc_calculated;
uint16_t crc_received;

(void)ctx;
crc_calculated = agile_modbus_rtu_crc16(msg, msg_length - 2);
crc_received = (msg[msg_length - 2] << 8) | msg[msg_length - 1];

Expand All @@ -228,6 +229,8 @@ static int agile_modbus_rtu_pre_check_confirmation(agile_modbus_t *ctx, const ui
{
/* Check responding slave is the slave we requested (except for broacast
* request) */
(void)ctx;
(void)rsp_length;
if (req[0] != rsp[0] && req[0] != AGILE_MODBUS_BROADCAST_ADDRESS)
return -1;

Expand Down
5 changes: 5 additions & 0 deletions src/agile_modbus_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ static int agile_modbus_tcp_build_response_basis(agile_modbus_sft_t *sft, uint8_
*/
static int agile_modbus_tcp_prepare_response_tid(const uint8_t *req, int *req_length)
{
(void)req_length;
return (req[0] << 8) + req[1];
}

Expand Down Expand Up @@ -142,6 +143,8 @@ static int agile_modbus_tcp_send_msg_pre(uint8_t *req, int req_length)
*/
static int agile_modbus_tcp_check_integrity(agile_modbus_t *ctx, uint8_t *msg, const int msg_length)
{
(void)ctx;
(void)msg;
return msg_length;
}

Expand All @@ -156,6 +159,8 @@ static int agile_modbus_tcp_check_integrity(agile_modbus_t *ctx, uint8_t *msg, c
static int agile_modbus_tcp_pre_check_confirmation(agile_modbus_t *ctx, const uint8_t *req,
const uint8_t *rsp, int rsp_length)
{
(void)ctx;
(void)rsp_length;
/* Check transaction ID */
if (req[0] != rsp[0] || req[1] != rsp[1])
return -1;
Expand Down
4 changes: 2 additions & 2 deletions util/agile_modbus_slave_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int write_registers(agile_modbus_t *ctx, struct agile_modbus_slave_info *
int nb = 0;
const agile_modbus_slave_util_map_t *maps = NULL;
int nb_maps = 0;

(void)ctx;
switch (function) {
case AGILE_MODBUS_FC_WRITE_SINGLE_COIL:
case AGILE_MODBUS_FC_WRITE_MULTIPLE_COILS: {
Expand Down Expand Up @@ -247,7 +247,7 @@ static int mask_write_register(agile_modbus_t *ctx, struct agile_modbus_slave_in
int address = slave_info->address;
const agile_modbus_slave_util_map_t *maps = slave_util->tab_registers;
int nb_maps = slave_util->nb_registers;

(void)ctx;
if (maps == NULL)
return 0;

Expand Down

0 comments on commit c2af9ac

Please sign in to comment.