summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 55ef277)
raw | patch | inline | side by side (parent: 55ef277)
author | Florian Forster <octo@collectd.org> | |
Sun, 6 Nov 2016 09:21:35 +0000 (10:21 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 6 Nov 2016 18:24:19 +0000 (19:24 +0100) |
The previous version failed on FreeBSD with:
modbus.c: In function 'mb_read_data':
modbus.c:476:21: error: storage size of 'sockaddr' isn't known
struct sockaddr sockaddr;
^
modbus.c: In function 'mb_read_data':
modbus.c:476:21: error: storage size of 'sockaddr' isn't known
struct sockaddr sockaddr;
^
src/modbus.c | patch | blob | history |
diff --git a/src/modbus.c b/src/modbus.c
index c04b308d81728e74f4621737b64fb394eb47430d..cf126b5ae3b6e967dd560c07b8a0e805ed9c37ef 100644 (file)
--- a/src/modbus.c
+++ b/src/modbus.c
**/
#include "collectd.h"
+
#include "common.h"
-#include "plugin.h"
#include "configfile.h"
-
-#include <netdb.h>
+#include "plugin.h"
#include <modbus.h>
+#include <netdb.h>
+#include <sys/socket.h>
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
}
else if (host->conntype == MBCONN_TCP)
{
- struct sockaddr sockaddr;
- socklen_t saddrlen = sizeof (sockaddr);
-
- status = getpeername (modbus_get_socket (host->connection),
- &sockaddr, &saddrlen);
- if (status != 0)
+ if (getpeername (modbus_get_socket (host->connection),
+ (void *) &(struct sockaddr_storage) {0},
+ &(socklen_t) {sizeof(struct sockaddr_storage)}) != 0)
status = errno;
}