summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/etc/etc.c5
-rw-r--r--ext/md5/depend2
-rw-r--r--ext/socket/socket.c20
-rw-r--r--ext/socket/sockport.h2
4 files changed, 21 insertions, 8 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index e5f69f9285c..049b94ec8f9 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -10,6 +10,11 @@
#include "ruby.h"
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#ifdef HAVE_GETPWENT
#include <pwd.h>
#endif
diff --git a/ext/md5/depend b/ext/md5/depend
index c99f78ee90c..14427861f88 100644
--- a/ext/md5/depend
+++ b/ext/md5/depend
@@ -1,2 +1,2 @@
-md5c.o: md5c.c md5.h
+md5c.o: md5c.c md5.h $(topdir)/config.h
md5init.o: md5init.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h md5.h
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index bbd50577413..cadadd2b6c8 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -15,6 +15,11 @@
#include "rubysig.h"
#include <stdio.h>
#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#ifndef NT
#include <sys/socket.h>
#include <netinet/in.h>
@@ -538,7 +543,7 @@ ip_addrsetup(host, port)
portp = 0;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
portp = pbuf;
}
else {
@@ -726,7 +731,7 @@ open_inet(class, h, serv, type)
host = NULL;
}
if (FIXNUM_P(serv)) {
- snprintf(pbuf, sizeof(pbuf), "%d", FIX2UINT(serv));
+ snprintf(pbuf, sizeof(pbuf), "%ld", FIX2UINT(serv));
portp = pbuf;
}
else {
@@ -1748,7 +1753,7 @@ sock_s_getaddrinfo(argc, argv)
pptr = NULL;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
pptr = pbuf;
}
else {
@@ -1788,7 +1793,7 @@ sock_s_getnameinfo(argc, argv)
int argc;
VALUE *argv;
{
- VALUE sa, af, host, port, flags;
+ VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags;
static char hbuf[1024], pbuf[1024];
char *hptr, *pptr;
int fl;
@@ -1824,6 +1829,10 @@ sock_s_getnameinfo(argc, argv)
host = RARRAY(sa)->ptr[2];
}
}
+ else {
+ rb_raise(rb_eArgError, "array size should be 3 or 4, %d given",
+ RARRAY(sa)->len);
+ }
if (NIL_P(host)) {
hptr = NULL;
}
@@ -1837,7 +1846,7 @@ sock_s_getnameinfo(argc, argv)
pptr = NULL;
}
else if (!NIL_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port));
pptr = pbuf;
}
else {
@@ -1872,7 +1881,6 @@ sock_s_getnameinfo(argc, argv)
fl = NUM2INT(flags);
}
- gotsap:
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) {
diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h
index 99bec91a1a2..1639fcf8285 100644
--- a/ext/socket/sockport.h
+++ b/ext/socket/sockport.h
@@ -37,7 +37,7 @@
# define SET_SIN_LEN(si,len) (si)->sin_len = (len)
#else
# define SIN_LEN(si) sizeof(struct sockaddr_in)
-# define SET_SIN_LEN(si,len) (len)
+# define SET_SIN_LEN(si,len)
#endif
#endif