Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1164)

Unified Diff: fusl/src/stdio/fflush.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/stdio/fflush.c
diff --git a/fusl/src/stdio/fflush.c b/fusl/src/stdio/fflush.c
index 3f462c80e8d12f6efbecd144a144d430736ec6eb..422f0188c422bc33cbf379026f5b1a0627f06b67 100644
--- a/fusl/src/stdio/fflush.c
+++ b/fusl/src/stdio/fflush.c
@@ -1,48 +1,49 @@
#include "stdio_impl.h"
-static int __fflush_unlocked(FILE *f)
-{
- /* If writing, flush output */
- if (f->wpos > f->wbase) {
- f->write(f, 0, 0);
- if (!f->wpos) return EOF;
- }
-
- /* If reading, sync position, per POSIX */
- if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
-
- /* Clear read and write modes */
- f->wpos = f->wbase = f->wend = 0;
- f->rpos = f->rend = 0;
-
- return 0;
+static int __fflush_unlocked(FILE* f) {
+ /* If writing, flush output */
+ if (f->wpos > f->wbase) {
+ f->write(f, 0, 0);
+ if (!f->wpos)
+ return EOF;
+ }
+
+ /* If reading, sync position, per POSIX */
+ if (f->rpos < f->rend)
+ f->seek(f, f->rpos - f->rend, SEEK_CUR);
+
+ /* Clear read and write modes */
+ f->wpos = f->wbase = f->wend = 0;
+ f->rpos = f->rend = 0;
+
+ return 0;
}
/* stdout.c will override this if linked */
-static FILE *volatile dummy = 0;
+static FILE* volatile dummy = 0;
weak_alias(dummy, __stdout_used);
-int fflush(FILE *f)
-{
- int r;
-
- if (f) {
- FLOCK(f);
- r = __fflush_unlocked(f);
- FUNLOCK(f);
- return r;
- }
-
- r = __stdout_used ? fflush(__stdout_used) : 0;
-
- for (f=*__ofl_lock(); f; f=f->next) {
- FLOCK(f);
- if (f->wpos > f->wbase) r |= __fflush_unlocked(f);
- FUNLOCK(f);
- }
- __ofl_unlock();
-
- return r;
+int fflush(FILE* f) {
+ int r;
+
+ if (f) {
+ FLOCK(f);
+ r = __fflush_unlocked(f);
+ FUNLOCK(f);
+ return r;
+ }
+
+ r = __stdout_used ? fflush(__stdout_used) : 0;
+
+ for (f = *__ofl_lock(); f; f = f->next) {
+ FLOCK(f);
+ if (f->wpos > f->wbase)
+ r |= __fflush_unlocked(f);
+ FUNLOCK(f);
+ }
+ __ofl_unlock();
+
+ return r;
}
weak_alias(__fflush_unlocked, fflush_unlocked);

Powered by Google App Engine
This is Rietveld 408576698