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

Side by Side Diff: ports/glibc-compat/src/readv.c

Issue 1289343005: Added Tor (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@pepper_44
Patch Set: contains modifications as per feedback and a bug fix Created 5 years, 3 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
(Empty)
1 /* Copyright 2015 The Native Client Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
4
5 #include <sys/uio.h>
6 #include <unistd.h> // unix(nacl) standards
7 #include <errno.h>
8
9 ssize_t readv (int fd, const struct iovec *iov, int iovcnt) {
10 if (iovcnt < 0) {
11 // #TODO(dt) add check for IOV_MAX
12 errno = EINVAL;
13 return -1;
14 }
15 ssize_t bytes_read = 0;
16 ssize_t bytes_supposed_to_be_read = 0;
17 int i;
18 for (i = 0; i < (iovcnt); i++) {
19 bytes_read += read(fd, iov[i].iov_base, iov[i].iov_len);
20 bytes_supposed_to_be_read += iov[i].iov_len;
21 //#TODO(dt) add check for (max) ssize_t allowed
22 if (bytes_read != bytes_supposed_to_be_read) {
23 // deliberately not setting errno here as it might override
24 // errno set by read(...)
25 return -1;
26 }
27 }
28 return bytes_read;
29 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698