* gcc.xml (gcc-64): Fix example.
This commit is contained in:
		| @@ -1,3 +1,7 @@ | |||||||
|  | 2013-07-25  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
|  | 	* gcc.xml (gcc-64): Fix example. | ||||||
|  |  | ||||||
| 2013-07-25  Corinna Vinschen  <corinna@vinschen.de> | 2013-07-25  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* gcc.xml (gcc-default: Rename from gcc-cons.  Change title. | 	* gcc.xml (gcc-default: Rename from gcc-cons.  Change title. | ||||||
|   | |||||||
| @@ -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 | 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 | of DWORD is wrong for 64 bit.  In fact, since | ||||||
| <function>sizeof(ssize_t)</function> is 8, <function>ReadFile</function> | <function>sizeof(ssize_t)</function> is 8, <function>ReadFile</function> | ||||||
| will write the number of read bytes into the upper 4 bytes of the variable | will write the number of read bytes into the lower 4 bytes of the variable | ||||||
| <literal>bytes_read</literal>.  <function>my_read</function> will | <literal>bytes_read</literal>, while the upper 4 bytes will contain an | ||||||
| return the wrong number of read bytes to the caller.</para> | undefined value.  <function>my_read</function> will very likely return the | ||||||
|  | wrong number of read bytes to the caller.</para> | ||||||
|  |  | ||||||
| <para>Here's the fixed version of <function>my_read</function>:</para> | <para>Here's the fixed version of <function>my_read</function>:</para> | ||||||
|  |  | ||||||
| @@ -97,7 +98,7 @@ my_read (int fd, void *buffer, size_t bytes_to_read) | |||||||
|   DWORD bytes_read; |   DWORD bytes_read; | ||||||
|  |  | ||||||
|   if (ReadFile (fh, buffer, bytes_to_read, &bytes_read, NULL)) |   if (ReadFile (fh, buffer, bytes_to_read, &bytes_read, NULL)) | ||||||
|     return bytes_read; |     return (ssize_t) bytes_read; | ||||||
|   set_errno_from_get_last_error (); |   set_errno_from_get_last_error (); | ||||||
|   return -1; |   return -1; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user