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 Jun 19, 2018
1 parent 21e3cc6 commit d89f16e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,9 +1211,11 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb,
}

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 d89f16e

Please # to comment.