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

Side by Side Diff: sandbox/linux/syscall_broker/broker_file_permission_unittest.cc

Issue 821693003: replace COMPILE_ASSERT with static_assert in sandbox/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 11 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/services/credentials.cc ('k') | sandbox/linux/tests/scoped_temporary_file.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "sandbox/linux/syscall_broker/broker_file_permission.h" 5 #include "sandbox/linux/syscall_broker/broker_file_permission.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 118
119 // O_SYNC can be defined as (__O_SYNC|O_DSYNC) 119 // O_SYNC can be defined as (__O_SYNC|O_DSYNC)
120 #ifdef O_DSYNC 120 #ifdef O_DSYNC
121 const int kSyncFlag = O_SYNC & ~O_DSYNC; 121 const int kSyncFlag = O_SYNC & ~O_DSYNC;
122 #else 122 #else
123 const int kSyncFlag = O_SYNC; 123 const int kSyncFlag = O_SYNC;
124 #endif 124 #endif
125 125
126 const int kNumberOfBitsInOAccMode = 2; 126 const int kNumberOfBitsInOAccMode = 2;
127 COMPILE_ASSERT(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1), 127 static_assert(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1),
128 number_of_bits); 128 "incorrect number of bits");
129 // check every possible flag and act accordingly. 129 // check every possible flag and act accordingly.
130 // Skipping AccMode bits as they are present in every case. 130 // Skipping AccMode bits as they are present in every case.
131 for (int i = kNumberOfBitsInOAccMode; i < 32; i++) { 131 for (int i = kNumberOfBitsInOAccMode; i < 32; i++) {
132 int flag = 1 << i; 132 int flag = 1 << i;
133 switch (flag) { 133 switch (flag) {
134 case O_APPEND: 134 case O_APPEND:
135 case O_ASYNC: 135 case O_ASYNC:
136 case O_DIRECT: 136 case O_DIRECT:
137 case O_DIRECTORY: 137 case O_DIRECTORY:
138 #ifdef O_DSYNC 138 #ifdef O_DSYNC
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/..")); 253 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/.."));
254 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/../bad")); 254 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/../bad"));
255 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/../bad")); 255 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/../bad"));
256 } 256 }
257 257
258 } // namespace 258 } // namespace
259 259
260 } // namespace syscall_broker 260 } // namespace syscall_broker
261 261
262 } // namespace sandbox 262 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/credentials.cc ('k') | sandbox/linux/tests/scoped_temporary_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698