]> sourceware.org Git - glibc.git/commitdiff
[BZ #309]
authorUlrich Drepper <drepper@redhat.com>
Tue, 10 Aug 2004 04:38:50 +0000 (04:38 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 10 Aug 2004 04:38:50 +0000 (04:38 +0000)
Update.
* libio/bits/stdio.h (fread_unlocked): Add a couple of (size_t)
casts to handle funny calls with floating point argument values
and signed values correctly and without warning.
(fwrite_unlocked): Likewise.  [BZ #309]

ChangeLog
libio/bits/stdio.h

index 0f4bcc6ff5a9aaaaba784786eb93841ee5bbe2dd..bc7b579b2b2830464c60c40e3bb4b9fb34f184ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2004-08-09  Ulrich Drepper  <drepper@redhat.com>
 
+       * libio/bits/stdio.h (fread_unlocked): Add a couple of (size_t)
+       casts to handle funny calls with floating point argument values
+       and signed values correctly and without warning.
+       (fwrite_unlocked): Likewise.  [BZ #309]
+
        * malloc/memusage.c (me): Use creat64, not creat.
        * malloc/memusagestat.c: Fix handling of very large sizes.  [BZ #285]
        Patch by Guy Maor <guymaor@yahoo.com>.
index 14ebd7e276fa0bc8148b6bee5cc940755c33fd6b..e602dbd826d618e0b1df4e904c74462cbd0d4ff5 100644 (file)
@@ -1,5 +1,5 @@
 /* Optimizing macros and inline functions for stdio functions.
-   Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2000, 2001, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -129,20 +129,23 @@ ferror_unlocked (FILE *__stream) __THROW
 /* Perform some simple optimizations.  */
 # define fread_unlocked(ptr, size, n, stream) \
   (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n)    \
-                  && (size_t) ((size) * (n)) <= 8 && (size) != 0)            \
+                  && (size_t) (size) * (size_t) (n) <= 8                     \
+                  && (size_t) (size) != 0)                                   \
                  ? ({ char *__ptr = (char *) (ptr);                          \
                       FILE *__stream = (stream);                             \
                       size_t __cnt;                                          \
-                      for (__cnt = (size) * (n); __cnt > 0; --__cnt)         \
+                      for (__cnt = (size_t) (size) * (size_t) (n);           \
+                           __cnt > 0; --__cnt)                               \
                         {                                                    \
                           int __c = _IO_getc_unlocked (__stream);            \
                           if (__c == EOF)                                    \
                             break;                                           \
                           *__ptr++ = __c;                                    \
                         }                                                    \
-                      ((size_t) ((size) * (n)) - __cnt) / (size); })         \
-                 : (((__builtin_constant_p (size) && (size) == 0)            \
-                     || (__builtin_constant_p (n) && (n) == 0))              \
+                      ((size_t) (size) * (size_t) (n) - __cnt)               \
+                       / (size_t) (size); })                                 \
+                 : (((__builtin_constant_p (size) && (size_t) (size) == 0)   \
+                     || (__builtin_constant_p (n) && (size_t) (n) == 0))     \
                        /* Evaluate all parameters once.  */                  \
                     ? ((void) (ptr), (void) (stream), (void) (size),         \
                        (void) (n), 0)                                        \
@@ -150,18 +153,21 @@ ferror_unlocked (FILE *__stream) __THROW
 
 # define fwrite_unlocked(ptr, size, n, stream) \
   (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n)    \
-                  && (size_t) ((size) * (n)) <= 8 && (size) != 0)            \
+                  && (size_t) ((size) * (n)) <= 8 && (size_t) (size) != 0)   \
                  ? ({ const char *__ptr = (const char *) (ptr);              \
                       FILE *__stream = (stream);                             \
                       size_t __cnt;                                          \
-                      for (__cnt = (size) * (n); __cnt > 0; --__cnt)         \
+                      for (__cnt = (size_t) (size) * (size_t) (n);           \
+                           __cnt > 0; --__cnt)                               \
                         if (_IO_putc_unlocked (*__ptr++, __stream) == EOF)   \
                           break;                                             \
-                      ((size_t) ((size) * (n)) - __cnt) / (size); })         \
-                 : (((__builtin_constant_p (size) && (size) == 0)            \
-                     || (__builtin_constant_p (n) && (n) == 0))              \
+                      ((size_t) (size) * (size_t) (n) - __cnt)               \
+                       / (size_t) (size); })                                 \
+                 : (((__builtin_constant_p (size) && (size_t) (size) == 0)   \
+                     || (__builtin_constant_p (n) && (size_t) (n) == 0))     \
                        /* Evaluate all parameters once.  */                  \
-                    ? ((void) (ptr), (void) (stream), (void) (size), n)      \
+                    ? ((void) (ptr), (void) (stream), (void) (size),         \
+                       (size_t) n)                                           \
                     : fwrite_unlocked (ptr, size, n, stream))))
 #endif
 
This page took 0.049554 seconds and 5 git commands to generate.