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

Unified Diff: fusl/src/stdio/__stdio_write.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/__stdio_write.c
diff --git a/fusl/src/stdio/__stdio_write.c b/fusl/src/stdio/__stdio_write.c
index d2d89475b0f9429dca8b538b689f97c27bbe5fee..387d12bb47fc7363cda30a421480fb5448b0ea0e 100644
--- a/fusl/src/stdio/__stdio_write.c
+++ b/fusl/src/stdio/__stdio_write.c
@@ -1,34 +1,32 @@
#include "stdio_impl.h"
#include <sys/uio.h>
-size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
-{
- struct iovec iovs[2] = {
- { .iov_base = f->wbase, .iov_len = f->wpos-f->wbase },
- { .iov_base = (void *)buf, .iov_len = len }
- };
- struct iovec *iov = iovs;
- size_t rem = iov[0].iov_len + iov[1].iov_len;
- int iovcnt = 2;
- ssize_t cnt;
- for (;;) {
- cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
- if (cnt == rem) {
- f->wend = f->buf + f->buf_size;
- f->wpos = f->wbase = f->buf;
- return len;
- }
- if (cnt < 0) {
- f->wpos = f->wbase = f->wend = 0;
- f->flags |= F_ERR;
- return iovcnt == 2 ? 0 : len-iov[0].iov_len;
- }
- rem -= cnt;
- if (cnt > iov[0].iov_len) {
- cnt -= iov[0].iov_len;
- iov++; iovcnt--;
- }
- iov[0].iov_base = (char *)iov[0].iov_base + cnt;
- iov[0].iov_len -= cnt;
- }
+size_t __stdio_write(FILE* f, const unsigned char* buf, size_t len) {
+ struct iovec iovs[2] = {{.iov_base = f->wbase, .iov_len = f->wpos - f->wbase},
+ {.iov_base = (void*)buf, .iov_len = len}};
+ struct iovec* iov = iovs;
+ size_t rem = iov[0].iov_len + iov[1].iov_len;
+ int iovcnt = 2;
+ ssize_t cnt;
+ for (;;) {
+ cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
+ if (cnt == rem) {
+ f->wend = f->buf + f->buf_size;
+ f->wpos = f->wbase = f->buf;
+ return len;
+ }
+ if (cnt < 0) {
+ f->wpos = f->wbase = f->wend = 0;
+ f->flags |= F_ERR;
+ return iovcnt == 2 ? 0 : len - iov[0].iov_len;
+ }
+ rem -= cnt;
+ if (cnt > iov[0].iov_len) {
+ cnt -= iov[0].iov_len;
+ iov++;
+ iovcnt--;
+ }
+ iov[0].iov_base = (char*)iov[0].iov_base + cnt;
+ iov[0].iov_len -= cnt;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698