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 Oct 31, 2024
1 parent bb13443 commit 7b1409c
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,17 +1335,6 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb, uint16_
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 7b1409c

Please sign in to comment.