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

Side by Side Diff: ipc/ipc_channel_nacl.cc

Issue 10959063: nacl: Fix a bunch of compiler warnings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel.cc ('k') | ppapi/proxy/plugin_main_nacl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_channel_nacl.h" 5 #include "ipc/ipc_channel_nacl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/nacl_imc_api.h> 9 #include <sys/nacl_imc_api.h>
10 #include <sys/nacl_syscalls.h> 10 #include <sys/nacl_syscalls.h>
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (pipe_ == -1) 254 if (pipe_ == -1)
255 return false; 255 return false;
256 256
257 // Write out all the messages. The trusted implementation is guaranteed to not 257 // Write out all the messages. The trusted implementation is guaranteed to not
258 // block. See NaClIPCAdapter::Send for the implementation of imc_sendmsg. 258 // block. See NaClIPCAdapter::Send for the implementation of imc_sendmsg.
259 while (!output_queue_.empty()) { 259 while (!output_queue_.empty()) {
260 linked_ptr<Message> msg = output_queue_.front(); 260 linked_ptr<Message> msg = output_queue_.front();
261 output_queue_.pop_front(); 261 output_queue_.pop_front();
262 262
263 int fds[FileDescriptorSet::kMaxDescriptorsPerMessage]; 263 int fds[FileDescriptorSet::kMaxDescriptorsPerMessage];
264 const int num_fds = msg->file_descriptor_set()->size(); 264 const size_t num_fds = msg->file_descriptor_set()->size();
265 DCHECK(num_fds <= FileDescriptorSet::kMaxDescriptorsPerMessage); 265 DCHECK(num_fds <= FileDescriptorSet::kMaxDescriptorsPerMessage);
266 msg->file_descriptor_set()->GetDescriptors(fds); 266 msg->file_descriptor_set()->GetDescriptors(fds);
267 267
268 NaClImcMsgIoVec iov = { const_cast<void*>(msg->data()), msg->size() }; 268 NaClImcMsgIoVec iov = { const_cast<void*>(msg->data()), msg->size() };
269 NaClImcMsgHdr msgh = { &iov, 1, fds, num_fds }; 269 NaClImcMsgHdr msgh = { &iov, 1, fds, num_fds };
270 ssize_t bytes_written = imc_sendmsg(pipe_, &msgh, 0); 270 ssize_t bytes_written = imc_sendmsg(pipe_, &msgh, 0);
271 271
272 DCHECK(bytes_written); // The trusted side shouldn't return 0. 272 DCHECK(bytes_written); // The trusted side shouldn't return 0.
273 if (bytes_written < 0) { 273 if (bytes_written < 0) {
274 // The trusted side should only ever give us an error of EPIPE. We 274 // The trusted side should only ever give us an error of EPIPE. We
(...skipping 20 matching lines...) Expand all
295 char* buffer, 295 char* buffer,
296 int buffer_len, 296 int buffer_len,
297 int* bytes_read) { 297 int* bytes_read) {
298 *bytes_read = 0; 298 *bytes_read = 0;
299 if (pipe_ == -1) 299 if (pipe_ == -1)
300 return READ_FAILED; 300 return READ_FAILED;
301 if (read_queue_.empty()) 301 if (read_queue_.empty())
302 return READ_PENDING; 302 return READ_PENDING;
303 while (!read_queue_.empty() && *bytes_read < buffer_len) { 303 while (!read_queue_.empty() && *bytes_read < buffer_len) {
304 linked_ptr<std::vector<char> > vec(read_queue_.front()); 304 linked_ptr<std::vector<char> > vec(read_queue_.front());
305 int bytes_to_read = buffer_len - *bytes_read; 305 size_t bytes_to_read = buffer_len - *bytes_read;
306 if (vec->size() <= bytes_to_read) { 306 if (vec->size() <= bytes_to_read) {
307 // We can read and discard the entire vector. 307 // We can read and discard the entire vector.
308 std::copy(vec->begin(), vec->end(), buffer + *bytes_read); 308 std::copy(vec->begin(), vec->end(), buffer + *bytes_read);
309 *bytes_read += vec->size(); 309 *bytes_read += vec->size();
310 read_queue_.pop_front(); 310 read_queue_.pop_front();
311 } else { 311 } else {
312 // Read all the bytes we can and discard them from the front of the 312 // Read all the bytes we can and discard them from the front of the
313 // vector. (This can be slowish, since erase has to move the back of the 313 // vector. (This can be slowish, since erase has to move the back of the
314 // vector to the front, but it's hopefully a temporary hack and it keeps 314 // vector to the front, but it's hopefully a temporary hack and it keeps
315 // the code simple). 315 // the code simple).
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // A random name is sufficient validation on posix systems, so we don't need 388 // A random name is sufficient validation on posix systems, so we don't need
389 // an additional shared secret. 389 // an additional shared secret.
390 std::string id = prefix; 390 std::string id = prefix;
391 if (!id.empty()) 391 if (!id.empty())
392 id.append("."); 392 id.append(".");
393 393
394 return id.append(GenerateUniqueRandomChannelID()); 394 return id.append(GenerateUniqueRandomChannelID());
395 } 395 }
396 396
397 } // namespace IPC 397 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel.cc ('k') | ppapi/proxy/plugin_main_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698