MinGW make type warning in modbus-rtu.c #181

Closed
ghost opened this Issue Dec 11, 2013 · 0 comments

Comments

Projects
None yet
0 participants
@ghost

ghost commented Dec 11, 2013

when compiling the newest libmodbus master branch
with the newest MinGW (GCC 4.8.1) on Win7 via the steps:

autogen.sh
./configure
make

make warns:

modbus-rtu.c: In function '_modbus_rtu_send':
modbus-rtu.c:283:86: warning: signed and unsigned type in conditional expression [-Wsign-compare]
    return (WriteFile(ctx_rtu->w_ser.fd, req, req_length, &n_bytes, NULL)) ? n_bytes : -1;

it can be resolved by replacing in src/modbus-rtu.c the line

return (WriteFile(ctx_rtu->w_ser.fd, req, req_length, &n_bytes, NULL)) ? n_bytes : -1;

with

return (WriteFile(ctx_rtu->w_ser.fd, req, req_length, &n_bytes, NULL)) ? (ssize_t)n_bytes : -1;

@stephane stephane closed this in 5e93475 Dec 11, 2013

mk8 added a commit to mk8/libmodbus that referenced this issue Jan 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment