From: Florian Forster Date: Tue, 6 Sep 2016 08:54:49 +0000 (+0200) Subject: modbus plugin: Use "struct sockaddr_storage" instead of "struct sockaddr". X-Git-Tag: collectd-5.7.0~108 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5b81c5fd3f3c3d1d169a37a2ef30ff53ac195d50;p=collectd.git modbus plugin: Use "struct sockaddr_storage" instead of "struct sockaddr". "struct sockaddr" may be an opaque type. --- 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; }