[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fdopen on MSVC
From: |
Eric Blake |
Subject: |
Re: fdopen on MSVC |
Date: |
Mon, 26 Sep 2011 16:30:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14 |
On 09/26/2011 04:17 PM, Bruno Haible wrote:
Paolo Bonzini asked:
* modules/fclose-tests (Depends-on): Add fdopen.
* modules/fflush-tests (Depends-on): Likewise.
* modules/fgetc-tests (Depends-on): Likewise.
* modules/fputc-tests (Depends-on): Likewise.
* modules/fread-tests (Depends-on): Likewise.
* modules/freopen-tests (Depends-on): Likewise.
* modules/fseeko-tests (Depends-on): Likewise.
* modules/ftello-tests (Depends-on): Likewise.
* modules/fwrite-tests (Depends-on): Likewise.
Why?
These tests (test-fgetc.c etc.) call fdopen (-1, "r"), which is supposed
to return NULL / EBADF. But -- see doc/posix-functions/fdopen.texi --
this call crashes on MSVC 9, and the gnulib 'fdopen' module provides the
workaround (through an invalid parameter handler that prevents the crash).
If fdopen(-1,"r") returns anything besides NULL in the first place, then
that is a bug in fdopen(). It looks like you are doing some bogus
testing in these various files:
/* Test that fclose() sets errno if the stream was constructed with
an invalid file descriptor. */
{
FILE *fp = fdopen (-1, "r");
if (fp != NULL)
{
errno = 0;
ASSERT (fclose (fp) == EOF);
ASSERT (errno == EBADF);
}
}
since fp should be NULL at this point, and thus a compliant system won't
be testing fclose() behavior in the first place.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org