From 4f9c19f9ba8dc756e732e0f17c1a2b2433eae467 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 7 Jul 2011 15:20:29 +0800 Subject: [OUTPUT] Make outc an inline function As "gcc -pedantic" warns, ISO C forbids conditional expressions with only one void side. So the (needslow ? slowpath() : fastpath) code for outc in the !USE_GLIBC_STDIO case might not be portable. More importantly, it's hard to read. Rip it out and replace it with an inline function which should generate the same code. Reported-by: Szabolcs Nagy Signed-off-by: Jonathan Nieder Signed-off-by: Herbert Xu --- src/output.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/output.h') diff --git a/src/output.h b/src/output.h index d123301..f853e9d 100644 --- a/src/output.h +++ b/src/output.h @@ -97,10 +97,21 @@ freestdout() #define OUTPUT_ERR 01 /* error occurred on output */ #ifdef USE_GLIBC_STDIO -#define outc(c, o) putc((c), (o)->stream) +static inline void outc(int ch, struct output *file) +{ + putc(ch, file->stream); +} #define doformat(d, f, a) vfprintf((d)->stream, (f), (a)) #else -#define outc(c, file) ((file)->nextc == (file)->end ? outcslow((c), (file)) : (*(file)->nextc = (c), (file)->nextc++)) +static inline void outc(int ch, struct output *file) +{ + if (file->nextc == file->end) + outcslow(ch, file); + else { + *file->nextc = ch; + file->nextc++; + } +} #endif #define out1c(c) outc((c), out1) #define out2c(c) outcslow((c), out2) -- cgit 1.4.1