Skip to content

Commit

Permalink
Remove redundant register count check
Browse files Browse the repository at this point in the history
We have the same check already in exported functions modbus_read_registers
and modbus_read_input_registers which both calls out to the internal
static function read_registers.

So we can safely remove this redundant check in read_registers.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  • Loading branch information
mhei committed Jun 19, 2018
1 parent ddac0cf commit 21e3cc6
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,16 +1146,6 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb,
uint8_t req[_MIN_REQ_LENGTH];
uint8_t rsp[MAX_MESSAGE_LENGTH];

if (nb > MODBUS_MAX_READ_REGISTERS) {
if (ctx->debug) {
fprintf(stderr,
"ERROR Too many registers requested (%d > %d)\n",
nb, MODBUS_MAX_READ_REGISTERS);
}
errno = EMBMDATA;
return -1;
}

req_length = ctx->backend->build_request_basis(ctx, function, addr, nb, req);

rc = send_msg(ctx, req, req_length);
Expand Down

0 comments on commit 21e3cc6

Please # to comment.