From 5b81c5fd3f3c3d1d169a37a2ef30ff53ac195d50 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 6 Sep 2016 10:54:49 +0200 Subject: [PATCH] modbus plugin: Use "struct sockaddr_storage" instead of "struct sockaddr". "struct sockaddr" may be an opaque type. --- src/modbus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modbus.c b/src/modbus.c index 93fd54a5..82213d2c 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -470,11 +470,11 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ } else if (host->conntype == MBCONN_TCP) { - struct sockaddr sockaddr; - socklen_t saddrlen = sizeof (sockaddr); - + /* getpeername() is used only to determine if the socket is connected, not + * because we're really interested in the peer's IP address. */ status = getpeername (modbus_get_socket (host->connection), - &sockaddr, &saddrlen); + (struct sockaddr *) &(struct sockaddr_storage) { 0 }, + &(socklen_t) { sizeof (struct sockaddr_storage) }); if (status != 0) status = errno; } -- 2.11.0