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

Side by Side Diff: fusl/src/stdio/ftell.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 unified diff | Download patch
OLDNEW
1 #include "stdio_impl.h" 1 #include "stdio_impl.h"
2 #include <limits.h> 2 #include <limits.h>
3 #include <errno.h> 3 #include <errno.h>
4 4
5 off_t __ftello_unlocked(FILE *f) 5 off_t __ftello_unlocked(FILE* f) {
6 { 6 off_t pos = f->seek(
7 » off_t pos = f->seek(f, 0, 7 f, 0, (f->flags & F_APP) && f->wpos > f->wbase ? SEEK_END : SEEK_CUR);
8 » » (f->flags & F_APP) && f->wpos > f->wbase 8 if (pos < 0)
9 » » ? SEEK_END : SEEK_CUR); 9 return pos;
10 » if (pos < 0) return pos;
11 10
12 » /* Adjust for data in buffer. */ 11 /* Adjust for data in buffer. */
13 » return pos - (f->rend - f->rpos) + (f->wpos - f->wbase); 12 return pos - (f->rend - f->rpos) + (f->wpos - f->wbase);
14 } 13 }
15 14
16 off_t __ftello(FILE *f) 15 off_t __ftello(FILE* f) {
17 { 16 off_t pos;
18 » off_t pos; 17 FLOCK(f);
19 » FLOCK(f); 18 pos = __ftello_unlocked(f);
20 » pos = __ftello_unlocked(f); 19 FUNLOCK(f);
21 » FUNLOCK(f); 20 return pos;
22 » return pos;
23 } 21 }
24 22
25 long ftell(FILE *f) 23 long ftell(FILE* f) {
26 { 24 off_t pos = __ftello(f);
27 » off_t pos = __ftello(f); 25 if (pos > LONG_MAX) {
28 » if (pos > LONG_MAX) { 26 errno = EOVERFLOW;
29 » » errno = EOVERFLOW; 27 return -1;
30 » » return -1; 28 }
31 » } 29 return pos;
32 » return pos;
33 } 30 }
34 31
35 weak_alias(__ftello, ftello); 32 weak_alias(__ftello, ftello);
36 33
37 weak_alias(__ftello, ftello64); 34 weak_alias(__ftello, ftello64);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698