Browse Source

Fix compilation on OpenBSD

In modbus-tcp.c:
- Needed to include <signal.h>
- Added Jay's fix for __OpenBSD__
- SIGPIPE ignore handler needs to return a pointer instead of an integer.

Patch provided bu Barry Grumbine and Jason Oster.
Stéphane Raimbault 14 years ago
parent
commit
018bd41edf
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/modbus-tcp.c

+ 3 - 2
src/modbus-tcp.c

@@ -20,6 +20,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <signal.h>
 #include <sys/types.h>
 
 #if defined(_WIN32)
@@ -32,7 +33,7 @@
 # include <sys/socket.h>
 # include <sys/ioctl.h>
 
-#if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
 # define OS_BSD
 # include <netinet/in_systm.h>
 #endif
@@ -434,7 +435,7 @@ modbus_t* modbus_new_tcp(const char *ip, int port)
     if (sigaction(SIGPIPE, &sa, NULL) < 0) {
         /* The debug flag can't be set here... */
         fprintf(stderr, "Coud not install SIGPIPE handler.\n");
-        return -1;
+        return NULL;
     }
 #endif