This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix pread


Hi!

$ cat foo.c
#define _XOPEN_SOURCE 600
#define _FILE_OFFSET_BITS 64
#include <unistd.h>
$ gcc -D_FORTIFY_SOURCE=2 -O2 -c foo.c
In file included from /usr/include/unistd.h:1052,
                 from foo.c:3:
/usr/include/bits/unistd.h:55: error: conflicting types for `pread'
/usr/include/unistd.h:341: error: previous declaration of `pread' was here

Surprisingly, many __USE_FILE_OFFSET64 REDIRECTs use __off64_t rather than
__off_t.  This patch fixes this by adjusting posix/bits/unistd.h to match
unistd.h, but maybe better would be to change all the REDIRECTs to use
__off_t.

2005-03-20  Jakub Jelinek  <jakub@redhat.com>

	* posix/bits/unistd.h (pread) [__USE_FILE_OFFSET64]: Use __off64_t
	instead of __off_t for last argument.
	* debug/Makefile (tests): Add tst-lfschk{1,2,3}.
	* debug/tst-lfschk1.c: New test.
	* debug/tst-lfschk2.c: New test.
	* debug/tst-lfschk3.c: New test.

--- libc/posix/bits/unistd.h.jj	2005-03-19 08:36:13.000000000 +0100
+++ libc/posix/bits/unistd.h	2005-03-20 08:00:07.000000000 +0100
@@ -58,7 +58,7 @@ pread (int __fd, void *__buf, size_t __n
 }
 # else
 extern __always_inline __wur ssize_t
-pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
+pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
 {
   if (__bos0 (__buf) != (size_t) -1
       && (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
--- libc/debug/tst-lfschk1.c.jj	2005-03-20 07:51:34.000000000 +0100
+++ libc/debug/tst-lfschk1.c	2005-03-20 07:51:17.000000000 +0100
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk1.c"
--- libc/debug/tst-lfschk2.c.jj	2005-03-20 07:51:34.000000000 +0100
+++ libc/debug/tst-lfschk2.c	2005-03-20 07:51:41.000000000 +0100
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk2.c"
--- libc/debug/tst-lfschk3.c.jj	2005-03-20 07:51:34.000000000 +0100
+++ libc/debug/tst-lfschk3.c	2005-03-20 07:51:45.000000000 +0100
@@ -0,0 +1,2 @@
+#define _FILE_OFFSET_BITS 64
+#include "tst-chk3.c"
--- libc/debug/Makefile.jj	2005-03-01 10:34:26.000000000 +0100
+++ libc/debug/Makefile	2005-03-20 07:52:18.000000000 +0100
@@ -54,7 +54,7 @@ CFLAGS-recv_chk.c = -fexceptions -fasync
 CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
 
 tests = backtrace-tst tst-chk1 tst-chk2 tst-chk3 \
-	test-strcpy_chk test-stpcpy_chk
+	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk
 
 extra-libs = libSegFault libpcprofile
 extra-libs-others = $(extra-libs)


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]