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

Side by Side Diff: sandbox/win/src/sandbox_utils.cc

Issue 10942004: Cleanup: avoid foo ? true : false, part 2. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/win/src/sandbox_utils.h" 5 #include "sandbox/win/src/sandbox_utils.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
11 #include "sandbox/win/src/internal_types.h" 11 #include "sandbox/win/src/internal_types.h"
12 #include "sandbox/win/src/nt_internals.h" 12 #include "sandbox/win/src/nt_internals.h"
13 13
14 namespace sandbox { 14 namespace sandbox {
15 15
16 bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name, 16 bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name,
17 HMODULE* module) { 17 HMODULE* module) {
18 DCHECK(module); 18 DCHECK(module);
19 19
20 HMODULE kernel32_base = ::GetModuleHandle(kKerneldllName); 20 HMODULE kernel32_base = ::GetModuleHandle(kKerneldllName);
21 if (!kernel32_base) { 21 if (!kernel32_base) {
22 NOTREACHED(); 22 NOTREACHED();
23 return false; 23 return false;
24 } 24 }
25 25
26 GetModuleHandleExFunction get_module_handle_ex = reinterpret_cast< 26 GetModuleHandleExFunction get_module_handle_ex = reinterpret_cast<
27 GetModuleHandleExFunction>(::GetProcAddress(kernel32_base, 27 GetModuleHandleExFunction>(::GetProcAddress(kernel32_base,
28 "GetModuleHandleExW")); 28 "GetModuleHandleExW"));
29 if (get_module_handle_ex) { 29 if (get_module_handle_ex)
30 BOOL ret = get_module_handle_ex(flags, module_name, module); 30 return !!get_module_handle_ex(flags, module_name, module);
rvargas (doing something else) 2012/09/18 18:56:28 This one I actually dislike a lot. how about xx !=
Lei Zhang 2012/09/19 01:32:41 Done.
Peter Kasting 2012/09/19 21:26:31 We shouldn't need the "!!" or the "!= FALSE", shou
rvargas (doing something else) 2012/09/19 21:35:13 There's the annoying "performance" warning of VS a
31 return (ret ? true : false);
32 }
33 31
34 if (!flags) { 32 if (!flags) {
35 *module = ::LoadLibrary(module_name); 33 *module = ::LoadLibrary(module_name);
36 } else if (flags & GET_MODULE_HANDLE_EX_FLAG_PIN) { 34 } else if (flags & GET_MODULE_HANDLE_EX_FLAG_PIN) {
37 NOTREACHED(); 35 NOTREACHED();
38 return false; 36 return false;
39 } else if (!(flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)) { 37 } else if (!(flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)) {
40 DCHECK((flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) == 38 DCHECK((flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) ==
41 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT); 39 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT);
42 40
(...skipping 27 matching lines...) Expand all
70 HMODULE ntdll = ::GetModuleHandle(kNtdllName); 68 HMODULE ntdll = ::GetModuleHandle(kNtdllName);
71 RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>( 69 RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>(
72 GetProcAddress(ntdll, "RtlInitUnicodeString")); 70 GetProcAddress(ntdll, "RtlInitUnicodeString"));
73 DCHECK(RtlInitUnicodeString); 71 DCHECK(RtlInitUnicodeString);
74 } 72 }
75 RtlInitUnicodeString(uni_name, name.c_str()); 73 RtlInitUnicodeString(uni_name, name.c_str());
76 InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); 74 InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL);
77 } 75 }
78 76
79 }; // namespace sandbox 77 }; // namespace sandbox
OLDNEW
« sandbox/win/src/sandbox_nt_util.cc ('K') | « sandbox/win/src/sandbox_nt_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698