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

Side by Side Diff: sandbox/linux/seccomp-bpf/errorcode.h

Issue 570163003: Large IWYU cleanup for seccomp-bpf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trap-errorcode
Patch Set: Sort #includes 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 unified diff | Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/die.cc ('k') | sandbox/linux/seccomp-bpf/errorcode.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 #ifndef SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__ 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__ 6 #define SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__
7 7
8 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h"
9 #include "sandbox/linux/seccomp-bpf/trap.h" 8 #include "sandbox/linux/seccomp-bpf/trap.h"
10 #include "sandbox/sandbox_export.h" 9 #include "sandbox/sandbox_export.h"
11 10
12 namespace sandbox { 11 namespace sandbox {
13 12
14 struct arch_seccomp_data;
15
16 // This class holds all the possible values that can be returned by a sandbox 13 // This class holds all the possible values that can be returned by a sandbox
17 // policy. 14 // policy.
18 // We can either wrap a symbolic ErrorCode (i.e. ERR_XXX enum values), an 15 // We can either wrap a symbolic ErrorCode (i.e. ERR_XXX enum values), an
19 // errno value (in the range 0..4095), a pointer to a TrapFnc callback 16 // errno value (in the range 0..4095), a pointer to a TrapFnc callback
20 // handling a SECCOMP_RET_TRAP trap, or a complex constraint. 17 // handling a SECCOMP_RET_TRAP trap, or a complex constraint.
21 // All of the commonly used values are stored in the "err_" field. So, code 18 // All of the commonly used values are stored in the "err_" field. So, code
22 // that is using the ErrorCode class typically operates on a single 32bit 19 // that is using the ErrorCode class typically operates on a single 32bit
23 // field. 20 // field.
24 class SANDBOX_EXPORT ErrorCode { 21 class SANDBOX_EXPORT ErrorCode {
25 public: 22 public:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ET_SIMPLE, 103 ET_SIMPLE,
107 ET_TRAP, 104 ET_TRAP,
108 ET_COND, 105 ET_COND,
109 }; 106 };
110 107
111 // We allow the default constructor, as it makes the ErrorCode class 108 // We allow the default constructor, as it makes the ErrorCode class
112 // much easier to use. But if we ever encounter an invalid ErrorCode 109 // much easier to use. But if we ever encounter an invalid ErrorCode
113 // when compiling a BPF filter, we deliberately generate an invalid 110 // when compiling a BPF filter, we deliberately generate an invalid
114 // program that will get flagged both by our Verifier class and by 111 // program that will get flagged both by our Verifier class and by
115 // the Linux kernel. 112 // the Linux kernel.
116 ErrorCode() : error_type_(ET_INVALID), err_(SECCOMP_RET_INVALID) {} 113 ErrorCode();
117 explicit ErrorCode(int err); 114 explicit ErrorCode(int err);
118 115
119 // For all practical purposes, ErrorCodes are treated as if they were 116 // For all practical purposes, ErrorCodes are treated as if they were
120 // structs. The copy constructor and assignment operator are trivial and 117 // structs. The copy constructor and assignment operator are trivial and
121 // we do not need to explicitly specify them. 118 // we do not need to explicitly specify them.
122 // Most notably, it is in fact perfectly OK to directly copy the passed_ and 119 // Most notably, it is in fact perfectly OK to directly copy the passed_ and
123 // failed_ field. They only ever get set by our private constructor, and the 120 // failed_ field. They only ever get set by our private constructor, and the
124 // callers handle life-cycle management for these objects. 121 // callers handle life-cycle management for these objects.
125 122
126 // Destructor 123 // Destructor
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 186
190 // 32bit field used for all possible types of ErrorCode values. This is 187 // 32bit field used for all possible types of ErrorCode values. This is
191 // the value that uniquely identifies any ErrorCode and it (typically) can 188 // the value that uniquely identifies any ErrorCode and it (typically) can
192 // be emitted directly into a BPF filter program. 189 // be emitted directly into a BPF filter program.
193 uint32_t err_; 190 uint32_t err_;
194 }; 191 };
195 192
196 } // namespace sandbox 193 } // namespace sandbox
197 194
198 #endif // SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__ 195 #endif // SANDBOX_LINUX_SECCOMP_BPF_ERRORCODE_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/die.cc ('k') | sandbox/linux/seccomp-bpf/errorcode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698