klibc-bot for Jonathan Nieder
2012-Jul-02 09:12 UTC
[klibc] [klibc:master] [OUTPUT] Make outc an inline function
Commit-ID: 8ce54e2a6adb82cbbb988e1f335fa5ebf370f6c5 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=8ce54e2a6adb82cbbb988e1f335fa5ebf370f6c5 Author: Jonathan Nieder <jrnieder at gmail.com> AuthorDate: Thu, 7 Jul 2011 15:20:29 +0800 Committer: maximilian attems <max at stro.at> CommitDate: Mon, 2 Jul 2012 10:43:24 +0200 [klibc] [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 <nsz at port70.net> Signed-off-by: Jonathan Nieder <jrnieder at gmail.com> Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: maximilian attems <max at stro.at> --- usr/dash/output.h | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/usr/dash/output.h b/usr/dash/output.h index d123301..f853e9d 100644 --- a/usr/dash/output.h +++ b/usr/dash/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)
Apparently Analagous Threads
- [klibc:update-dash] [BUILTIN] Handle embedded NULs correctly in printf
- [klibc:update-dash] dash: [BUILTIN] Handle embedded NULs correctly in printf
- [klibc:update-dash] input: Move all input state into parsefile
- [klibc:update-dash] dash: input: Move all input state into parsefile
- [klibc:update-dash] input: Allow two consecutive calls to pungetc