diff options
author | Roland McGrath <roland@gnu.org> | 2004-08-10 18:01:40 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2004-08-10 18:01:40 +0000 |
commit | f98ca075dbc8b8598dcc1d953b930cd87ced023a (patch) | |
tree | d5d36261ebe9493d6197d4523ac566b4c7fb2103 /libio/bits | |
parent | * FAQ: Regenerated. (diff) | |
download | glibc-f98ca075dbc8b8598dcc1d953b930cd87ced023a.tar.gz glibc-f98ca075dbc8b8598dcc1d953b930cd87ced023a.tar.bz2 glibc-f98ca075dbc8b8598dcc1d953b930cd87ced023a.zip |
[BZ #316]
2004-08-10 Jakub Jelinek <jakub@redhat.com>
* libio/bits/stdio.h (fread_unlocked): Cast 0 to (size_t).
(fwrite_unlocked): When checking if size * n is <= 8, cast each
argument to size_t individually. Cast n to (void) instead of
(size_t), surround with (), return (size_t) 0 if one of n or size
is 0. [BZ #316]
* stdio-common/Makefile (tests): Add tst-unlockedio.
* stdio-common/tst-unlockedio.c: New test.
Diffstat (limited to 'libio/bits')
-rw-r--r-- | libio/bits/stdio.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h index e602dbd826..60c937f072 100644 --- a/libio/bits/stdio.h +++ b/libio/bits/stdio.h @@ -148,12 +148,13 @@ ferror_unlocked (FILE *__stream) __THROW || (__builtin_constant_p (n) && (size_t) (n) == 0)) \ /* Evaluate all parameters once. */ \ ? ((void) (ptr), (void) (stream), (void) (size), \ - (void) (n), 0) \ + (void) (n), (size_t) 0) \ : fread_unlocked (ptr, size, n, stream)))) # define fwrite_unlocked(ptr, size, n, stream) \ (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \ - && (size_t) ((size) * (n)) <= 8 && (size_t) (size) != 0) \ + && (size_t) (size) * (size_t) (n) <= 8 \ + && (size_t) (size) != 0) \ ? ({ const char *__ptr = (const char *) (ptr); \ FILE *__stream = (stream); \ size_t __cnt; \ @@ -167,7 +168,7 @@ ferror_unlocked (FILE *__stream) __THROW || (__builtin_constant_p (n) && (size_t) (n) == 0)) \ /* Evaluate all parameters once. */ \ ? ((void) (ptr), (void) (stream), (void) (size), \ - (size_t) n) \ + (void) (n), (size_t) 0) \ : fwrite_unlocked (ptr, size, n, stream)))) #endif |