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

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

Issue 576673003: Decouple CodeGen from ErrorCode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf/sandbox_bpf.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index b90a9ef5da085b591279b790a455288a17df75ed..a5da20e82f00da1079c37dc99da4224e47ee3970 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -886,10 +886,14 @@ Instruction* SandboxBPF::AssembleJumpTable(CodeGen* gen,
}
Instruction* SandboxBPF::RetExpression(CodeGen* gen, const ErrorCode& err) {
- if (err.error_type_ == ErrorCode::ET_COND) {
+ switch (err.error_type()) {
+ case ErrorCode::ET_COND:
return CondExpression(gen, err);
rickyz (no longer on Chrome) 2014/09/16 22:36:46 nit: fix indent
mdempsky 2014/09/16 22:41:30 Oops, done.
- } else {
- return gen->MakeInstruction(BPF_RET + BPF_K, err);
+ case ErrorCode::ET_SIMPLE:
+ case ErrorCode::ET_TRAP:
+ return gen->MakeInstruction(BPF_RET + BPF_K, err.err());
+ default:
+ SANDBOX_DIE("ErrorCode is not suitable for returning from a BPF program");
jln (very slow on Chromium) 2014/09/16 22:42:29 Will this work with all compilers? I think there a
mdempsky 2014/09/16 22:47:44 I think so. There are other functions in this fil
}
}
« sandbox/linux/seccomp-bpf/codegen.h ('K') | « sandbox/linux/seccomp-bpf/codegen_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698