From a30f955d286e38b570f5e2ab59d5f096213e0328 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 25 Jul 2013 09:09:14 +0000 Subject: [PATCH] * gcc.xml (gcc-64): Fix example. --- winsup/doc/ChangeLog | 4 ++++ winsup/doc/gcc.xml | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index bd4eeefa9..ab97e59a1 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,7 @@ +2013-07-25 Corinna Vinschen + + * gcc.xml (gcc-64): Fix example. + 2013-07-25 Corinna Vinschen * gcc.xml (gcc-default: Rename from gcc-cons. Change title. diff --git a/winsup/doc/gcc.xml b/winsup/doc/gcc.xml index e15862638..7edf89f79 100644 --- a/winsup/doc/gcc.xml +++ b/winsup/doc/gcc.xml @@ -81,9 +81,10 @@ my_read (int fd, void *buffer, size_t bytes_to_read) a bad bug. The assumption that the size of ssize_t is the same as the size of DWORD is wrong for 64 bit. In fact, since sizeof(ssize_t) is 8, ReadFile -will write the number of read bytes into the upper 4 bytes of the variable -bytes_read. my_read will -return the wrong number of read bytes to the caller. +will write the number of read bytes into the lower 4 bytes of the variable +bytes_read, while the upper 4 bytes will contain an +undefined value. my_read will very likely return the +wrong number of read bytes to the caller. Here's the fixed version of my_read: @@ -97,7 +98,7 @@ my_read (int fd, void *buffer, size_t bytes_to_read) DWORD bytes_read; if (ReadFile (fh, buffer, bytes_to_read, &bytes_read, NULL)) - return bytes_read; + return (ssize_t) bytes_read; set_errno_from_get_last_error (); return -1; }