Hi misc,

while compiling picolisp on openbsd, i encounter this warning:

gcc -c -O2 -m32 -pipe -falign-functions -fomit-frame-pointer
-fno-strict-aliasing -W -Wimplicit -Wreturn-type -Wunused -Wformat
-Wuninitialized -Wstrict-prototypes -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -D_OS='"OpenBSD"' net.c
net.c: In function `doHost':
net.c:116: warning: passing arg 2 of `inet_aton' from incompatible pointer type
net.c: In function `server':
net.c:130: warning: passing arg 2 of `inet_aton' from incompatible pointer type

the code in question is:

any doHost(any x) {
   struct in_addr in;
   struct hostent *p;

   x = evSym(cdr(x));
   {
      char nm[bufSize(x)];

      bufString(x, nm);
      if (inet_aton(nm, &in) && (p = gethostbyaddr((char*)&in,
sizeof(in), AF_INET)))
         return mkStr(p->h_name);
      return Nil;
   }
}

checking out the man pages for inet_aton(3), i didn't see anything
that would lead to the warning. so i tried to tweak the order of the
header files to reflect that of the man pages.

the diff to the source would look like:

e...@obsd $ diff -u net.c*
--- net.c       Thu Oct  7 01:05:22 2010
+++ net.c.orig  Thu Oct  7 01:02:58 2010
@@ -6,9 +6,9 @@

 #include <netdb.h>
 #include <sys/socket.h>
-#include <arpa/inet.h>
 #include <netinet/tcp.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>

compiling the source after changing the order of includes didn't
produce the warning.

is this really supposed to happen?

cheers,

/e

Reply via email to