summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authormostynb <mostynb@opera.com>2015-01-06 15:04:01 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-06 23:05:42 +0000
commit7430d7c80a263d3ac861d1c9f1f39a2e15ec4dd8 (patch)
tree200ca2fbbc33ced1356ba15b76ab7d955088ce17 /sandbox
parentb9ef84152bce335b4814175204744ea2d5b148b4 (diff)
downloadchromium_src-7430d7c80a263d3ac861d1c9f1f39a2e15ec4dd8.zip
chromium_src-7430d7c80a263d3ac861d1c9f1f39a2e15ec4dd8.tar.gz
chromium_src-7430d7c80a263d3ac861d1c9f1f39a2e15ec4dd8.tar.bz2
replace COMPILE_ASSERT with static_assert in sandbox/
BUG=442514 Review URL: https://codereview.chromium.org/821693003 Cr-Commit-Position: refs/heads/master@{#310165}
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc7
-rw-r--r--sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc3
-rw-r--r--sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc2
-rw-r--r--sandbox/linux/seccomp-bpf/syscall.cc4
-rw-r--r--sandbox/linux/seccomp-bpf/syscall_iterator.cc5
-rw-r--r--sandbox/linux/services/credentials.cc7
-rw-r--r--sandbox/linux/syscall_broker/broker_file_permission_unittest.cc4
-rw-r--r--sandbox/linux/tests/scoped_temporary_file.cc4
-rw-r--r--sandbox/win/src/Wow64.cc2
-rw-r--r--sandbox/win/src/crosscall_client.h4
-rw-r--r--sandbox/win/src/crosscall_params.h6
-rw-r--r--sandbox/win/src/policy_engine_opcodes.h4
-rw-r--r--sandbox/win/src/policy_low_level.h3
-rw-r--r--sandbox/win/src/policy_params.h8
-rw-r--r--sandbox/win/src/service_resolver_32.cc7
-rw-r--r--sandbox/win/src/sharedmem_ipc_server.cc2
-rw-r--r--sandbox/win/wow_helper/wow_helper.cc2
17 files changed, 40 insertions, 34 deletions
diff --git a/sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc b/sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc
index d6c88d6..1e4fdb4 100644
--- a/sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc
+++ b/sandbox/linux/bpf_dsl/bpf_dsl_more_unittest.cc
@@ -906,7 +906,7 @@ ResultExpr SimpleCondTestPolicy::EvaluateSyscall(int sysno) const {
flags_argument_position = 2;
// Allow opening files for reading, but don't allow writing.
- COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_be_all_zero_bits);
+ static_assert(O_RDONLY == 0, "O_RDONLY must be all zero bits");
const Arg<int> flags(flags_argument_position);
return If((flags & O_ACCMODE) != 0, Error(EROFS)).Else(Allow());
}
@@ -951,9 +951,10 @@ class EqualityStressTest {
// We are actually constructing a graph of ArgValue objects. This
// graph will later be used to a) compute our sandbox policy, and
// b) drive the code that verifies the output from the BPF program.
- COMPILE_ASSERT(
+ static_assert(
kNumTestCases < (int)(MAX_PUBLIC_SYSCALL - MIN_SYSCALL - 10),
- num_test_cases_must_be_significantly_smaller_than_num_system_calls);
+ "kNumTestCases must be significantly smaller than the number "
+ "of system calls");
for (int sysno = MIN_SYSCALL, end = kNumTestCases; sysno < end; ++sysno) {
if (IsReservedSyscall(sysno)) {
// Skip reserved system calls. This ensures that our test frame
diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
index 69d32bc..214b99c 100644
--- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
@@ -187,7 +187,8 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
defined(__aarch64__)
if (sysno == __NR_socketpair) {
// Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
- COMPILE_ASSERT(AF_UNIX == PF_UNIX, af_unix_pf_unix_different);
+ static_assert(AF_UNIX == PF_UNIX,
+ "af_unix and pf_unix should not be different");
const Arg<int> domain(0);
return If(domain == AF_UNIX, Allow()).Else(CrashSIGSYS());
}
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
index 7707953f..42d98bb 100644
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -264,7 +264,7 @@ ResultExpr RestrictGetSetpriority(pid_t target_pid) {
}
ResultExpr RestrictClockID() {
- COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit);
+ static_assert(4 == sizeof(clockid_t), "clockid_t is not 32bit");
const Arg<clockid_t> clockid(0);
return If(
#if defined(OS_CHROMEOS)
diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc
index 57f6baf..4839f63 100644
--- a/sandbox/linux/seccomp-bpf/syscall.cc
+++ b/sandbox/linux/seccomp-bpf/syscall.cc
@@ -279,8 +279,8 @@ intptr_t Syscall::Call(int nr,
// that this would only be an issue for IA64, which we are currently not
// planning on supporting. And it is even possible that this would work
// on IA64, but for lack of actual hardware, I cannot test.
- COMPILE_ASSERT(sizeof(void*) == sizeof(intptr_t),
- pointer_types_and_intptr_must_be_exactly_the_same_size);
+ static_assert(sizeof(void*) == sizeof(intptr_t),
+ "pointer types and intptr_t must be exactly the same size");
// TODO(nedeljko): Enable use of more than six parameters on architectures
// where that makes sense.
diff --git a/sandbox/linux/seccomp-bpf/syscall_iterator.cc b/sandbox/linux/seccomp-bpf/syscall_iterator.cc
index 3590530..195a8b0 100644
--- a/sandbox/linux/seccomp-bpf/syscall_iterator.cc
+++ b/sandbox/linux/seccomp-bpf/syscall_iterator.cc
@@ -14,10 +14,11 @@ namespace {
#if defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32)
// This is true for Mips O32 ABI.
-COMPILE_ASSERT(MIN_SYSCALL == __NR_Linux, min_syscall_should_be_4000);
+static_assert(MIN_SYSCALL == __NR_Linux, "min syscall number should be 4000");
#else
// This true for supported architectures (Intel and ARM EABI).
-COMPILE_ASSERT(MIN_SYSCALL == 0u, min_syscall_should_always_be_zero);
+static_assert(MIN_SYSCALL == 0u,
+ "min syscall should always be zero");
#endif
// SyscallRange represents an inclusive range of system call numbers.
diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
index e97dff8..c1283ea 100644
--- a/sandbox/linux/services/credentials.cc
+++ b/sandbox/linux/services/credentials.cc
@@ -58,7 +58,8 @@ struct FILECloser {
// TODO(jln): fix base/.
typedef scoped_ptr<FILE, FILECloser> ScopedFILE;
-COMPILE_ASSERT((base::is_same<uid_t, gid_t>::value), UidAndGidAreSameType);
+static_assert((base::is_same<uid_t, gid_t>::value),
+ "uid_t and gid_t should be the same type");
// generic_id_t can be used for either uid_t or gid_t.
typedef uid_t generic_id_t;
@@ -100,8 +101,8 @@ void ChrootToThreadFdInfo(base::PlatformThreadId tid, bool* result) {
DCHECK(result);
*result = false;
- COMPILE_ASSERT((base::is_same<base::PlatformThreadId, int>::value),
- TidIsAnInt);
+ static_assert((base::is_same<base::PlatformThreadId, int>::value),
+ "platform thread id should be an int");
const std::string current_thread_fdinfo = "/proc/" +
base::IntToString(tid) + "/fdinfo/";
diff --git a/sandbox/linux/syscall_broker/broker_file_permission_unittest.cc b/sandbox/linux/syscall_broker/broker_file_permission_unittest.cc
index 2853021..b58a901 100644
--- a/sandbox/linux/syscall_broker/broker_file_permission_unittest.cc
+++ b/sandbox/linux/syscall_broker/broker_file_permission_unittest.cc
@@ -124,8 +124,8 @@ void CheckPerm(const BrokerFilePermission& perm,
#endif
const int kNumberOfBitsInOAccMode = 2;
- COMPILE_ASSERT(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1),
- number_of_bits);
+ static_assert(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1),
+ "incorrect number of bits");
// check every possible flag and act accordingly.
// Skipping AccMode bits as they are present in every case.
for (int i = kNumberOfBitsInOAccMode; i < 32; i++) {
diff --git a/sandbox/linux/tests/scoped_temporary_file.cc b/sandbox/linux/tests/scoped_temporary_file.cc
index 82df9e0..1f2d66f 100644
--- a/sandbox/linux/tests/scoped_temporary_file.cc
+++ b/sandbox/linux/tests/scoped_temporary_file.cc
@@ -20,8 +20,8 @@ ScopedTemporaryFile::ScopedTemporaryFile() : fd_(-1) {
#else
static const char file_template[] = "/tmp/ScopedTempFileXXXXXX";
#endif // defined(OS_ANDROID)
- COMPILE_ASSERT(sizeof(full_file_name_) >= sizeof(file_template),
- full_file_name_is_large_enough);
+ static_assert(sizeof(full_file_name_) >= sizeof(file_template),
+ "full_file_name is not large enough");
memcpy(full_file_name_, file_template, sizeof(file_template));
fd_ = mkstemp(full_file_name_);
CHECK_LE(0, fd_);
diff --git a/sandbox/win/src/Wow64.cc b/sandbox/win/src/Wow64.cc
index 59df1d6..60ee13d 100644
--- a/sandbox/win/src/Wow64.cc
+++ b/sandbox/win/src/Wow64.cc
@@ -137,7 +137,7 @@ bool Wow64::WaitForNtdll() {
}
bool Wow64::RunWowHelper(void* buffer) {
- COMPILE_ASSERT(sizeof(buffer) <= sizeof(DWORD), unsupported_64_bits);
+ static_assert(sizeof(buffer) <= sizeof(DWORD), "unsupported 64 bits");
// Get the path to the helper (beside the exe).
wchar_t prog_name[MAX_PATH];
diff --git a/sandbox/win/src/crosscall_client.h b/sandbox/win/src/crosscall_client.h
index 2a482b4..5b1bce7 100644
--- a/sandbox/win/src/crosscall_client.h
+++ b/sandbox/win/src/crosscall_client.h
@@ -78,7 +78,7 @@ class CopyHelper {
// Returns this object's type.
ArgType GetType() {
- COMPILE_ASSERT(sizeof(T) == sizeof(uint32), need_specialization);
+ static_assert(sizeof(T) == sizeof(uint32), "specialization needed");
return UINT32_TYPE;
}
@@ -300,7 +300,7 @@ class CopyHelper<InOutCountedBuffer> {
ActualParams* params = new(raw_mem) ActualParams(tag);
#define XCALL_GEN_COPY_PARAM(num, params) \
- COMPILE_ASSERT(kMaxIpcParams >= num, too_many_parameters); \
+ static_assert(kMaxIpcParams >= num, "too many parameters"); \
CopyHelper<Par##num> ch##num(p##num); \
if (!params->CopyParamIn(num - 1, ch##num.GetStart(), ch##num.GetSize(), \
ch##num.IsInOut(), ch##num.GetType())) \
diff --git a/sandbox/win/src/crosscall_params.h b/sandbox/win/src/crosscall_params.h
index 4a71f69..6facb20 100644
--- a/sandbox/win/src/crosscall_params.h
+++ b/sandbox/win/src/crosscall_params.h
@@ -287,9 +287,9 @@ class ActualCallParams : public CrossCallParams {
DISALLOW_COPY_AND_ASSIGN(ActualCallParams);
};
-COMPILE_ASSERT(sizeof(ActualCallParams<1, 1024>) == 1024, bad_size_buffer);
-COMPILE_ASSERT(sizeof(ActualCallParams<2, 1024>) == 1024, bad_size_buffer);
-COMPILE_ASSERT(sizeof(ActualCallParams<3, 1024>) == 1024, bad_size_buffer);
+static_assert(sizeof(ActualCallParams<1, 1024>) == 1024, "bad size buffer");
+static_assert(sizeof(ActualCallParams<2, 1024>) == 1024, "bad size buffer");
+static_assert(sizeof(ActualCallParams<3, 1024>) == 1024, "bad size buffer");
} // namespace sandbox
diff --git a/sandbox/win/src/policy_engine_opcodes.h b/sandbox/win/src/policy_engine_opcodes.h
index 741ebe3..17d1764 100644
--- a/sandbox/win/src/policy_engine_opcodes.h
+++ b/sandbox/win/src/policy_engine_opcodes.h
@@ -154,7 +154,7 @@ class PolicyOpcode {
// from 0 to < kArgumentCount.
template <typename T>
void GetArgument(size_t index, T* argument) const {
- COMPILE_ASSERT(sizeof(T) <= sizeof(arguments_[0]), invalid_size);
+ static_assert(sizeof(T) <= sizeof(arguments_[0]), "invalid size");
*argument = *reinterpret_cast<const T*>(&arguments_[index].mem);
}
@@ -162,7 +162,7 @@ class PolicyOpcode {
// from 0 to < kArgumentCount.
template <typename T>
void SetArgument(size_t index, const T& argument) {
- COMPILE_ASSERT(sizeof(T) <= sizeof(arguments_[0]), invalid_size);
+ static_assert(sizeof(T) <= sizeof(arguments_[0]), "invalid size");
*reinterpret_cast<T*>(&arguments_[index].mem) = argument;
}
diff --git a/sandbox/win/src/policy_low_level.h b/sandbox/win/src/policy_low_level.h
index 6b733ac..7abc0ef 100644
--- a/sandbox/win/src/policy_low_level.h
+++ b/sandbox/win/src/policy_low_level.h
@@ -41,7 +41,8 @@ namespace sandbox {
// TODO(cpu): Move this constant to crosscall_client.h.
const size_t kMaxServiceCount = 32;
-COMPILE_ASSERT(IPC_LAST_TAG <= kMaxServiceCount, kMaxServiceCount_is_too_low);
+static_assert(IPC_LAST_TAG <= kMaxServiceCount,
+ "kMaxServiceCount is too low");
// Defines the memory layout of the policy. This memory is filled by
// LowLevelPolicy object.
diff --git a/sandbox/win/src/policy_params.h b/sandbox/win/src/policy_params.h
index 7ded1fc..f50cf1e 100644
--- a/sandbox/win/src/policy_params.h
+++ b/sandbox/win/src/policy_params.h
@@ -32,10 +32,10 @@ POLPARAMS_BEGIN(FileName)
POLPARAM(BROKER) // TRUE if called from the broker.
POLPARAMS_END(FileName)
-COMPILE_ASSERT(OpenFile::NAME == static_cast<int>(FileName::NAME),
- to_simplify_fs_policies);
-COMPILE_ASSERT(OpenFile::BROKER == static_cast<int>(FileName::BROKER),
- to_simplify_fs_policies);
+static_assert(OpenFile::NAME == static_cast<int>(FileName::NAME),
+ "to simplify fs policies");
+static_assert(OpenFile::BROKER == static_cast<int>(FileName::BROKER),
+ "to simplify fs policies");
// Policy parameter for name-based policies.
POLPARAMS_BEGIN(NameBased)
diff --git a/sandbox/win/src/service_resolver_32.cc b/sandbox/win/src/service_resolver_32.cc
index be9de6b..ab69ab8 100644
--- a/sandbox/win/src/service_resolver_32.cc
+++ b/sandbox/win/src/service_resolver_32.cc
@@ -123,9 +123,10 @@ struct Wow64EntryW8 {
// Make sure that relaxed patching works as expected.
const size_t kMinServiceSize = offsetof(ServiceEntry, ret);
-COMPILE_ASSERT(sizeof(ServiceEntryW8) >= kMinServiceSize, wrong_service_len);
-COMPILE_ASSERT(sizeof(Wow64Entry) >= kMinServiceSize, wrong_service_len);
-COMPILE_ASSERT(sizeof(Wow64EntryW8) >= kMinServiceSize, wrong_service_len);
+static_assert(sizeof(ServiceEntryW8) >= kMinServiceSize,
+ "wrong service length");
+static_assert(sizeof(Wow64Entry) >= kMinServiceSize, "wrong service length");
+static_assert(sizeof(Wow64EntryW8) >= kMinServiceSize, "wrong service length");
struct ServiceFullThunk {
union {
diff --git a/sandbox/win/src/sharedmem_ipc_server.cc b/sandbox/win/src/sharedmem_ipc_server.cc
index 3b5fe6c..c9bd8fa 100644
--- a/sandbox/win/src/sharedmem_ipc_server.cc
+++ b/sandbox/win/src/sharedmem_ipc_server.cc
@@ -230,7 +230,7 @@ bool SharedMemIPCServer::InvokeCallback(const ServerControl* service_context,
return false;
uint32 tag = params->GetTag();
- COMPILE_ASSERT(0 == INVALID_TYPE, Incorrect_type_enum);
+ static_assert(0 == INVALID_TYPE, "incorrect type enum");
IPCParams ipc_params = {0};
ipc_params.ipc_tag = tag;
diff --git a/sandbox/win/wow_helper/wow_helper.cc b/sandbox/win/wow_helper/wow_helper.cc
index ea73e84..e349337 100644
--- a/sandbox/win/wow_helper/wow_helper.cc
+++ b/sandbox/win/wow_helper/wow_helper.cc
@@ -61,7 +61,7 @@ int PatchNtdll(HANDLE child, void* thunk, size_t thunk_bytes) {
// It should be noted that we don't wait until the real work is done; this
// program quits as soon as the 64-bit interception is performed.
int wWinMain(HINSTANCE, HINSTANCE, wchar_t* command_line, int) {
- COMPILE_ASSERT(sizeof(void*) > sizeof(DWORD), unsupported_32_bits);
+ static_assert(sizeof(void*) > sizeof(DWORD), "unsupported 32 bits");
if (!command_line)
return 1;