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

Unified Diff: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc

Issue 10833044: Refactored ErrorCode into it's own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cosmetic changes Created 8 years, 4 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
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.cc ('k') | sandbox/linux/seccomp-bpf/util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
index ac25b2b28a0c02adff73aab4a5f6fe8fcc56a2eb..91b7746f85ac9987dc2cbe41ab4e033a09f83e6b 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
@@ -40,17 +40,17 @@ SANDBOX_TEST(SandboxBpf, CallSupportsTwice) {
// A simple blacklist test
-Sandbox::ErrorCode BlacklistNanosleepPolicy(int sysno) {
+ErrorCode BlacklistNanosleepPolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
switch (sysno) {
case __NR_nanosleep:
- return EACCES;
+ return ErrorCode(EACCES);
default:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
}
}
@@ -64,13 +64,13 @@ BPF_TEST(SandboxBpf, ApplyBasicBlacklistPolicy, BlacklistNanosleepPolicy) {
// Now do a simple whitelist test
-Sandbox::ErrorCode WhitelistGetpidPolicy(int sysno) {
+ErrorCode WhitelistGetpidPolicy(int sysno) {
switch (sysno) {
case __NR_getpid:
case __NR_exit_group:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
default:
- return ENOMEM;
+ return ErrorCode(ENOMEM);
}
}
@@ -99,18 +99,18 @@ intptr_t EnomemHandler(const struct arch_seccomp_data& args, void *aux) {
return -ENOMEM;
}
-Sandbox::ErrorCode BlacklistNanosleepPolicySigsys(int sysno) {
+ErrorCode BlacklistNanosleepPolicySigsys(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
switch (sysno) {
case __NR_nanosleep:
- return Sandbox::ErrorCode(EnomemHandler,
+ return Sandbox::Trap(EnomemHandler,
static_cast<void *>(&BlacklistNanosleepPolicySigsysAuxData));
default:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
}
}
@@ -147,11 +147,11 @@ int SysnoToRandomErrno(int sysno) {
return ((sysno & ~3) >> 2) % 29 + 1;
}
-Sandbox::ErrorCode SyntheticPolicy(int sysno) {
+ErrorCode SyntheticPolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy.
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
// TODO(jorgelo): remove this restriction once crbug.com/141694 is fixed.
@@ -166,9 +166,9 @@ Sandbox::ErrorCode SyntheticPolicy(int sysno) {
if (sysno == __NR_exit_group /* || sysno == __NR_write */) {
// exit_group() is special, we really need it to work.
// write() is needed for BPF_ASSERT() to report a useful error message.
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
} else {
- return SysnoToRandomErrno(sysno);
+ return ErrorCode(SysnoToRandomErrno(sysno));
}
}
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.cc ('k') | sandbox/linux/seccomp-bpf/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698