This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
FreeBSD port (17): fseek test
- From: Bruno Haible <bruno at clisp dot org>
- To: libc-alpha at sources dot redhat dot com
- Date: Thu, 11 Jul 2002 14:24:35 +0200 (CEST)
- Subject: FreeBSD port (17): fseek test
Hi,
In the glibc/FreeBSD port, off_t is a 64-bit signed integer type (like
in the native FreeBSD libc). But the test stdio-common/tst-fseek.c
assumes that sizeof (size_t) == sizeof (off_t). Which is not guaranteed
by standards. In my case,
(off_t) -(sizeof (outstr) - 1) = 0x00000000FFFFFFF2.
but the desired argument to fseek is
(off_t) -((int) sizeof (outstr) - 1) = 0xFFFFFFFFFFFFFFF2.
2002-07-06 Bruno Haible <bruno@clisp.org>
* stdio-common/tst-fseek.c (main): Don't assume that off_t and size_t
have the same size. Avoid direct cast from size_t to off_t.
diff -r -c3 glibc-20020627.bak/stdio-common/tst-fseek.c glibc-20020627/stdio-common/tst-fseek.c
--- glibc-20020627.bak/stdio-common/tst-fseek.c Fri Feb 22 21:30:10 2002
+++ glibc-20020627/stdio-common/tst-fseek.c Fri Jul 5 01:17:06 2002
@@ -171,7 +171,7 @@
#endif
/* Go back to the beginning of the file: relative. */
- if (fseek (fp, -(sizeof (outstr) - 1), SEEK_CUR) != 0)
+ if (fseek (fp, -((int) sizeof (outstr) - 1), SEEK_CUR) != 0)
{
puts ("fseek(fp, 0, SEEK_SET) failed");
result = 1;
@@ -199,7 +199,7 @@
#ifdef USE_IN_LIBIO
/* Now with fseeko. */
- if (fseeko (fp, -(sizeof (outstr) - 1), SEEK_CUR) != 0)
+ if (fseeko (fp, -((int) sizeof (outstr) - 1), SEEK_CUR) != 0)
{
puts ("fseeko(fp, 0, SEEK_SET) failed");
result = 1;
@@ -227,7 +227,7 @@
#endif
/* Go back to the beginning of the file: from the end. */
- if (fseek (fp, -(sizeof (outstr) - 1), SEEK_END) != 0)
+ if (fseek (fp, -((int) sizeof (outstr) - 1), SEEK_END) != 0)
{
puts ("fseek(fp, 0, SEEK_SET) failed");
result = 1;
@@ -255,7 +255,7 @@
#ifdef USE_IN_LIBIO
/* Now with fseeko. */
- if (fseeko (fp, -(sizeof (outstr) - 1), SEEK_END) != 0)
+ if (fseeko (fp, -((int) sizeof (outstr) - 1), SEEK_END) != 0)
{
puts ("fseeko(fp, 0, SEEK_SET) failed");
result = 1;