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

Side by Side Diff: components/nacl/loader/nacl_ipc_adapter.cc

Issue 794683005: replace COMPILE_ASSERT with static_assert in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting fixup Created 5 years, 12 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/loader/nacl_ipc_adapter.h" 5 #include "components/nacl/loader/nacl_ipc_adapter.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 current_message_len = input_data_len; 379 current_message_len = input_data_len;
380 did_append_input_data = false; 380 did_append_input_data = false;
381 } else { 381 } else {
382 // We've already accumulated some data, accumulate this new data and 382 // We've already accumulated some data, accumulate this new data and
383 // point to the beginning of the buffer. 383 // point to the beginning of the buffer.
384 384
385 // Make sure our accumulated message size doesn't overflow our max. Since 385 // Make sure our accumulated message size doesn't overflow our max. Since
386 // we know that data_len < max size (checked above) and our current 386 // we know that data_len < max size (checked above) and our current
387 // accumulated value is also < max size, we just need to make sure that 387 // accumulated value is also < max size, we just need to make sure that
388 // 2x max size can never overflow. 388 // 2x max size can never overflow.
389 COMPILE_ASSERT(IPC::Channel::kMaximumMessageSize < (UINT_MAX / 2), 389 static_assert(IPC::Channel::kMaximumMessageSize < (UINT_MAX / 2),
390 MaximumMessageSizeWillOverflow); 390 "kMaximumMessageSize is too large, and may overflow");
391 size_t new_size = locked_data_.to_be_sent_.size() + input_data_len; 391 size_t new_size = locked_data_.to_be_sent_.size() + input_data_len;
392 if (new_size > IPC::Channel::kMaximumMessageSize) { 392 if (new_size > IPC::Channel::kMaximumMessageSize) {
393 ClearToBeSent(); 393 ClearToBeSent();
394 return -1; 394 return -1;
395 } 395 }
396 396
397 locked_data_.to_be_sent_.append(input_data, input_data_len); 397 locked_data_.to_be_sent_.append(input_data, input_data_len);
398 current_message = &locked_data_.to_be_sent_[0]; 398 current_message = &locked_data_.to_be_sent_[0];
399 current_message_len = locked_data_.to_be_sent_.size(); 399 current_message_len = locked_data_.to_be_sent_.size();
400 did_append_input_data = true; 400 did_append_input_data = true;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 header.flags = msg.flags(); 826 header.flags = msg.flags();
827 header.num_fds = static_cast<uint16>(rewritten_msg->desc_count()); 827 header.num_fds = static_cast<uint16>(rewritten_msg->desc_count());
828 828
829 rewritten_msg->SetData(header, msg.payload(), msg.payload_size()); 829 rewritten_msg->SetData(header, msg.payload(), msg.payload_size());
830 locked_data_.to_be_received_.push(rewritten_msg); 830 locked_data_.to_be_received_.push(rewritten_msg);
831 } 831 }
832 832
833 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) { 833 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags) {
834 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags); 834 return TranslatePepperFileReadWriteOpenFlags(pp_open_flags);
835 } 835 }
OLDNEW
« no previous file with comments | « components/history/core/android/android_history_types.cc ('k') | components/nacl/loader/nonsfi/nonsfi_sandbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698