From d89f16e7de750f852907839f3f6bf841a7bcd99c Mon Sep 17 00:00:00 2001 From: Michael Heimpold Date: Tue, 19 Jun 2018 22:19:40 +0200 Subject: [PATCH] modbus_read_input_registers: also guard debug output by context debug flag Signed-off-by: Michael Heimpold --- src/modbus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modbus.c b/src/modbus.c index 286b327d..32fec24e 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -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; }