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

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

Issue 66723007: Make sandbox/linux/seccomp-bpf/ follow the style guide. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (empty) rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp-bpf/codegen.cc ('k') | sandbox/linux/seccomp-bpf/die.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_DIE_H__ 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_DIE_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ 6 #define SANDBOX_LINUX_SECCOMP_BPF_DIE_H__
7 7
8 #include "sandbox/linux/seccomp-bpf/port.h" 8 #include "sandbox/linux/seccomp-bpf/port.h"
9 9
10
11 namespace playground2 { 10 namespace playground2 {
12 11
13 class Die { 12 class Die {
14 public: 13 public:
15 // This is the main API for using this file. Prints a error message and 14 // This is the main API for using this file. Prints a error message and
16 // exits with a fatal error. This is not async-signal safe. 15 // exits with a fatal error. This is not async-signal safe.
17 #define SANDBOX_DIE(m) playground2::Die::SandboxDie(m, __FILE__, __LINE__) 16 #define SANDBOX_DIE(m) playground2::Die::SandboxDie(m, __FILE__, __LINE__)
18 17
19 // An async signal safe version of the same API. Won't print the filename 18 // An async signal safe version of the same API. Won't print the filename
20 // and line numbers. 19 // and line numbers.
21 #define RAW_SANDBOX_DIE(m) playground2::Die::RawSandboxDie(m) 20 #define RAW_SANDBOX_DIE(m) playground2::Die::RawSandboxDie(m)
22 21
23 // Adds an informational message to the log file or stderr as appropriate. 22 // Adds an informational message to the log file or stderr as appropriate.
24 #define SANDBOX_INFO(m) playground2::Die::SandboxInfo(m, __FILE__, __LINE__) 23 #define SANDBOX_INFO(m) playground2::Die::SandboxInfo(m, __FILE__, __LINE__)
25 24
26 // Terminate the program, even if the current sandbox policy prevents some 25 // Terminate the program, even if the current sandbox policy prevents some
27 // of the more commonly used functions used for exiting. 26 // of the more commonly used functions used for exiting.
28 // Most users would want to call SANDBOX_DIE() instead, as it logs extra 27 // Most users would want to call SANDBOX_DIE() instead, as it logs extra
29 // information. But calling ExitGroup() is correct and in some rare cases 28 // information. But calling ExitGroup() is correct and in some rare cases
30 // preferable. So, we make it part of the public API. 29 // preferable. So, we make it part of the public API.
31 static void ExitGroup() __attribute__((noreturn)); 30 static void ExitGroup() __attribute__((noreturn));
32 31
33 // This method gets called by SANDBOX_DIE(). There is normally no reason 32 // This method gets called by SANDBOX_DIE(). There is normally no reason
34 // to call it directly unless you are defining your own exiting macro. 33 // to call it directly unless you are defining your own exiting macro.
35 static void SandboxDie(const char *msg, const char *file, int line) 34 static void SandboxDie(const char* msg, const char* file, int line)
36 __attribute__((noreturn)); 35 __attribute__((noreturn));
37 36
38 static void RawSandboxDie(const char *msg) __attribute__((noreturn)); 37 static void RawSandboxDie(const char* msg) __attribute__((noreturn));
39 38
40 // This method gets called by SANDBOX_INFO(). There is normally no reason 39 // This method gets called by SANDBOX_INFO(). There is normally no reason
41 // to call it directly unless you are defining your own logging macro. 40 // to call it directly unless you are defining your own logging macro.
42 static void SandboxInfo(const char *msg, const char *file, int line); 41 static void SandboxInfo(const char* msg, const char* file, int line);
43 42
44 // Writes a message to stderr. Used as a fall-back choice, if we don't have 43 // Writes a message to stderr. Used as a fall-back choice, if we don't have
45 // any other way to report an error. 44 // any other way to report an error.
46 static void LogToStderr(const char *msg, const char *file, int line); 45 static void LogToStderr(const char* msg, const char* file, int line);
47 46
48 // We generally want to run all exit handlers. This means, on SANDBOX_DIE() 47 // We generally want to run all exit handlers. This means, on SANDBOX_DIE()
49 // we should be calling LOG(FATAL). But there are some situations where 48 // we should be calling LOG(FATAL). But there are some situations where
50 // we just need to print a message and then terminate. This would typically 49 // we just need to print a message and then terminate. This would typically
51 // happen in cases where we consume the error message internally (e.g. in 50 // happen in cases where we consume the error message internally (e.g. in
52 // unit tests or in the supportsSeccompSandbox() method). 51 // unit tests or in the supportsSeccompSandbox() method).
53 static void EnableSimpleExit() { simple_exit_ = true; } 52 static void EnableSimpleExit() { simple_exit_ = true; }
54 53
55 // Sometimes we need to disable all informational messages (e.g. from within 54 // Sometimes we need to disable all informational messages (e.g. from within
56 // unittests). 55 // unittests).
57 static void SuppressInfoMessages(bool flag) { suppress_info_ = flag; } 56 static void SuppressInfoMessages(bool flag) { suppress_info_ = flag; }
58 57
59 private: 58 private:
60 static bool simple_exit_; 59 static bool simple_exit_;
61 static bool suppress_info_; 60 static bool suppress_info_;
62 61
63 DISALLOW_IMPLICIT_CONSTRUCTORS(Die); 62 DISALLOW_IMPLICIT_CONSTRUCTORS(Die);
64 }; 63 };
65 64
66 } // namespace 65 } // namespace
67 66
68 #endif // SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ 67 #endif // SANDBOX_LINUX_SECCOMP_BPF_DIE_H__
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/codegen.cc ('k') | sandbox/linux/seccomp-bpf/die.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698