Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jun 2011 16:27:13 +0100
From:      "Klaus T. Aehlig" <aehlig@linta.de>
To:        freebsd-hackers@freebsd.org
Subject:   fdopendir prototype on 7.3-RELEASE amd64
Message-ID:  <20110601152713.GB51073@kta1c10.sesnet.soton.ac.uk>

next in thread | raw e-mail | index | archive | help

[Please CC me, as I'm not subscribed to this list]

Hallo,

while dealing with PR ports/157274 [1], I found that the following
program cause a segmentation fault on 7.3-RELEASE amd64, even though 
my understanding of the man page of fdopendir(3) says it should not.

#include <fcntl.h>
#include <sys/types.h>
#include <dirent.h>

int main(int argc, char **argv) {
  DIR *dirp;
  int fd;

  fd = open(".", O_RDONLY);
  dirp = fdopendir(fd);
  (void) readdir(dirp);

}

Compiling gives the warning "assignment makes pointer from integer without a cast"
refering to the line with the fdopendir call. Indeed, adding the prototype

extern DIR *fdopendir(int);

right after the #include lines solves this problem. Is my understanding of the 
man page that the above #include lines should suffice incorrect? Is this
problem known---or even fixed already?

I have reports that indicate that this problem also seems to exist on 7.3-RELEASE-p4 amd64
and 8.1-RELEASE i386. The above program does not segfault on my 8.2-STABLE amd64.

Any hints on the status of this observation are very welcome.

Best regards,
Klaus


[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/157274




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110601152713.GB51073>