aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-12 15:45:34 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-12 15:45:34 -0700
commit1500f92cb22003471211eab1b37be386231c2138 (patch)
tree65e5356dfdc1d569f65cc1414a594e9a75ed8eb4
parent8925a551fc3d0216433c7609a1f272f877619b6b (diff)
downloadklibc-1500f92cb22003471211eab1b37be386231c2138.tar.gz
[klibc] fgetc: shave off a few bytes
Restructure fgetc() so that gcc produces slightly smaller code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--usr/klibc/stdio/fgetc.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/usr/klibc/stdio/fgetc.c b/usr/klibc/stdio/fgetc.c
index 83b2e4c07334a4..1d6e599316df5b 100644
--- a/usr/klibc/stdio/fgetc.c
+++ b/usr/klibc/stdio/fgetc.c
@@ -10,12 +10,10 @@ int fgetc(FILE *file)
unsigned char ch;
if (__likely(f->ibytes)) {
- ch = *f->data++;
f->ibytes--;
f->pub._io_filepos++;
- } else if (_fread(&ch, 1, file) != 1) {
- return EOF;
+ return (unsigned char) *f->data++;
+ } else {
+ return _fread(&ch, 1, file) == 1 ? ch : EOF;
}
-
- return (int)ch;
}