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

Side by Side Diff: chrome/installer/mini_installer/decompress.cc

Issue 1126163003: mini_installer: Change to use _countof rather than base's arraysize macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 7 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
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 <windows.h> // NOLINT 5 #include <windows.h> // NOLINT
6 #include <fcntl.h> // for _O_* constants 6 #include <fcntl.h> // for _O_* constants
7 #include <fdi.h> 7 #include <fdi.h>
8 #include <stdlib.h>
grt (UTC plus 2) 2015/05/06 18:10:15 is this still needed?
tfarina 2015/05/06 18:16:07 Done.
8 9
9 #include "chrome/installer/mini_installer/decompress.h" 10 #include "chrome/installer/mini_installer/decompress.h"
10 11
11 namespace { 12 namespace {
12 13
13 FNALLOC(Alloc) { 14 FNALLOC(Alloc) {
14 return ::HeapAlloc(::GetProcessHeap(), 0, cb); 15 return ::HeapAlloc(::GetProcessHeap(), 0, cb);
15 } 16 }
16 17
17 FNFREE(Free) { 18 FNFREE(Free) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // environment variables set, so we try a couple that *should* always be 184 // environment variables set, so we try a couple that *should* always be
184 // present and fallback to the default Windows install path if all else 185 // present and fallback to the default Windows install path if all else
185 // fails. 186 // fails.
186 // The cabinet.dll should be available on all supported versions of Windows. 187 // The cabinet.dll should be available on all supported versions of Windows.
187 static const wchar_t* const candidate_paths[] = { 188 static const wchar_t* const candidate_paths[] = {
188 L"%WINDIR%\\system32\\cabinet.dll", 189 L"%WINDIR%\\system32\\cabinet.dll",
189 L"%SYSTEMROOT%\\system32\\cabinet.dll", 190 L"%SYSTEMROOT%\\system32\\cabinet.dll",
190 L"C:\\Windows\\system32\\cabinet.dll", 191 L"C:\\Windows\\system32\\cabinet.dll",
191 }; 192 };
192 193
193 wchar_t path[MAX_PATH] = {0}; 194 static const DWORD kBufferSize = MAX_PATH;
194 for (int i = 0; i < arraysize(candidate_paths); ++i) { 195 wchar_t path[kBufferSize];
196 for (const wchar_t* candidate_path : candidate_paths) {
195 path[0] = L'\0'; 197 path[0] = L'\0';
196 DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i], 198 DWORD result = ::ExpandEnvironmentStringsW(candidate_path,
197 path, arraysize(path)); 199 path, kBufferSize);
198 200
199 if (result > 0 && result <= arraysize(path)) 201 if (result > 0 && result <= kBufferSize)
200 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 202 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
201 203
202 if (g_fdi) 204 if (g_fdi)
203 break; 205 break;
204 } 206 }
205 } 207 }
206 208
207 if (g_fdi) { 209 if (g_fdi) {
208 g_FDICreate = 210 g_FDICreate =
209 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate")); 211 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate"));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 &Notify, NULL, const_cast<wchar_t*>(destination))) { 254 &Notify, NULL, const_cast<wchar_t*>(destination))) {
253 success = true; 255 success = true;
254 } 256 }
255 g_FDIDestroy(fdi); 257 g_FDIDestroy(fdi);
256 } 258 }
257 259
258 return success; 260 return success;
259 } 261 }
260 262
261 } // namespace mini_installer 263 } // namespace mini_installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698