Skip to content

Commit

Permalink
modbus_read_input_registers: also guard debug output by context debug…
Browse files Browse the repository at this point in the history
… flag

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  • Loading branch information
mhei committed Dec 4, 2022
1 parent fa18d04 commit 0c4b419
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,10 +1343,12 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest)
}

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

0 comments on commit 0c4b419

Please # to comment.