Skip to content

Commit

Permalink
Misc. cleanup, primarily removing unused locals.
Browse files Browse the repository at this point in the history
Also various other fixes, e.g. condensing code, converting DCHECK_LT(0, a) -> DCHECK_GT(a, 0) (and the like) for readability, inserting a few typecasts.

BUG=none
TEST=none

Review URL: https://codereview.chromium.org/637023002

Cr-Commit-Position: refs/heads/master@{#299362}
  • Loading branch information
pkasting authored and Commit bot committed Oct 13, 2014
1 parent 21860bb commit 7bc277b
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 134 deletions.
22 changes: 9 additions & 13 deletions chrome/app/chrome_crash_reporter_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,11 @@ void ChromeCrashReporterClient::InitBrowserCrashDumpsRegKey() {
// browser process might have the same process id and tick count, but crash
// before consuming the signal (overwriting the signal with an identical one).
// For now, we're willing to live with that risk.
int length = base::strings::SafeSPrintf(g_browser_crash_dump_prefix,
kBrowserCrashDumpPrefixTemplate,
chrome::kChromeVersion,
::GetCurrentProcessId(),
::GetTickCount());
if (length <= 0) {
if (base::strings::SafeSPrintf(g_browser_crash_dump_prefix,
kBrowserCrashDumpPrefixTemplate,
chrome::kChromeVersion,
::GetCurrentProcessId(),
::GetTickCount()) <= 0) {
NOTREACHED();
g_browser_crash_dump_prefix[0] = '\0';
return;
Expand All @@ -241,13 +240,10 @@ void ChromeCrashReporterClient::RecordCrashDumpAttempt(bool is_real_crash) {
// base value name).
const size_t kMaxValueSize = 2 * kBrowserCrashDumpPrefixLength;
char value_name[kMaxValueSize + 1] = {};
int length = base::strings::SafeSPrintf(
value_name,
"%s-%x",
g_browser_crash_dump_prefix,
base::subtle::NoBarrier_AtomicIncrement(&g_browser_crash_dump_count, 1));

if (length > 0) {
if (base::strings::SafeSPrintf(
value_name, "%s-%x", g_browser_crash_dump_prefix,
base::subtle::NoBarrier_AtomicIncrement(&g_browser_crash_dump_count,
1)) > 0) {
DWORD value_dword = is_real_crash ? 1 : 0;
::RegSetValueExA(g_browser_crash_dump_regkey, value_name, 0, REG_DWORD,
reinterpret_cast<BYTE*>(&value_dword),
Expand Down
7 changes: 4 additions & 3 deletions chrome/browser/ui/webui/devtools_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ void DevToolsDataSource::StartBundledDataRequest(
int resource_id =
content::DevToolsHttpHandler::GetFrontendResourceId(filename);

DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: "
<< filename << ". If you compiled with debug_devtools=1, try running"
" with --debug-devtools.";
DLOG_IF(WARNING, resource_id == -1)
<< "Unable to find dev tool resource: " << filename
<< ". If you compiled with debug_devtools=1, try running with "
"--debug-devtools.";
const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes(
resource_id));
Expand Down
1 change: 0 additions & 1 deletion chrome/installer/util/installer_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ bool InstallerState::AnyExistsAndIsInUse(
// Check only for the current version (i.e., the version we are upgrading
// _from_). Later versions from pending in-use updates need not be checked
// since the current version is guaranteed to be in use if any such are.
bool in_use = false;
scoped_ptr<Version> current_version(GetCurrentVersion(machine_state));
if (!current_version)
return false;
Expand Down
1 change: 0 additions & 1 deletion chrome/service/service_utility_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ bool ServiceUtilityProcessHost::StartProcess(bool no_sandbox) {
bool ServiceUtilityProcessHost::Launch(base::CommandLine* cmd_line,
bool no_sandbox) {
if (no_sandbox) {
base::ProcessHandle process = base::kNullProcessHandle;
cmd_line->AppendSwitch(switches::kNoSandbox);
base::LaunchProcess(*cmd_line, base::LaunchOptions(), &handle_);
} else {
Expand Down
2 changes: 2 additions & 0 deletions components/crash/app/breakpad_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ extern "C" int __declspec(dllexport) CrashForException(
return EXCEPTION_CONTINUE_SEARCH;
}

#ifndef _WIN64
static NTSTATUS WINAPI HookNtTerminateProcess(HANDLE ProcessHandle,
NTSTATUS ExitStatus) {
if (g_breakpad &&
Expand Down Expand Up @@ -440,6 +441,7 @@ static void InitTerminateProcessHooks() {
old_protect,
&old_protect));
}
#endif

static void InitPipeNameEnvVar(bool is_per_user_install) {
scoped_ptr<base::Environment> env(base::Environment::Create());
Expand Down
3 changes: 1 addition & 2 deletions components/crash/tools/crash_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool CreateTopWindow(HINSTANCE instance, bool visible) {
wcx.lpfnWndProc = CrashSvcWndProc;
wcx.hInstance = instance;
wcx.lpszClassName = L"crash_svc_class";
ATOM atom = ::RegisterClassExW(&wcx);
::RegisterClassExW(&wcx);
DWORD style = visible ? WS_POPUPWINDOW | WS_VISIBLE : WS_OVERLAPPED;

// The window size is zero but being a popup window still shows in the
Expand Down Expand Up @@ -466,7 +466,6 @@ PSECURITY_DESCRIPTOR CrashService::GetSecurityDescriptorForLowIntegrity() {
// Build the SDDL string for the label.
std::wstring sddl = L"S:(ML;;NW;;;S-1-16-4096)";

DWORD error = ERROR_SUCCESS;
PSECURITY_DESCRIPTOR sec_desc = NULL;

PACL sacl = NULL;
Expand Down
1 change: 0 additions & 1 deletion components/wifi/wifi_service_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,6 @@ DWORD WiFiServiceImpl::SetProfile(bool shared,
}

bool WiFiServiceImpl::HaveProfile(const std::string& network_guid) {
DWORD error = ERROR_SUCCESS;
std::string profile_xml;
return GetProfile(network_guid, false, &profile_xml) == ERROR_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion content/browser/devtools/devtools_http_handler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void DevToolsHttpHandlerImpl::OnHttpRequest(
int resource_id = DevToolsHttpHandler::GetFrontendResourceId(filename);
if (resource_id != -1) {
base::StringPiece data = GetContentClient()->GetDataResource(
resource_id, ui::SCALE_FACTOR_NONE);
resource_id, ui::SCALE_FACTOR_NONE);
server_->Send200(connection_id, data.as_string(), mime_type);
return;
}
Expand Down
1 change: 0 additions & 1 deletion content/browser/fileapi/obfuscated_file_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,6 @@ TEST_F(ObfuscatedFileUtilTest, TestQuotaOnMoveFile) {
from_file, from_file_size));
ASSERT_EQ(expected_total_file_size, ComputeTotalFileSize());

int64 to_file_size ALLOW_UNUSED = from_file_size;
from_file_size = 0;
ASSERT_EQ(base::File::FILE_OK,
ofu()->CopyOrMoveFile(
Expand Down
2 changes: 1 addition & 1 deletion content/test/plugin/plugin_get_javascript_url_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void CALLBACK ExecuteGetJavascriptUrlTest::TimerProc(
NPVariant result_var;

this_instance->npn_evaluate_context_ = true;
NPError result = this_instance->HostFunctions()->evaluate(
this_instance->HostFunctions()->evaluate(
this_instance->id(), window_obj, &script_string, &result_var);
this_instance->npn_evaluate_context_ = false;
}
Expand Down
6 changes: 3 additions & 3 deletions content/test/plugin/plugin_npobject_lifetime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void NPObjectLifetimeTest::URLNotify(const char* url, NPReason reason,
// Declare a local variant value.
NPVariant variantValue;
// Get the location property from the window object (which is another object).
bool b1 = HostFunctions()->getproperty(id(), other_plugin_instance_object_,
identifier, &variantValue );
HostFunctions()->getproperty(id(), other_plugin_instance_object_, identifier,
&variantValue );
HostFunctions()->releaseobject(other_plugin_instance_object_);
other_plugin_instance_object_ = NULL;
// If this test failed, then we'd have crashed by now.
Expand Down Expand Up @@ -165,7 +165,7 @@ void CALLBACK NPObjectDeletePluginInNPN_Evaluate::TimerProc(
static_cast<unsigned int>(script.length());

NPVariant result_var;
bool result = g_npn_evaluate_test_instance_->HostFunctions()->evaluate(
g_npn_evaluate_test_instance_->HostFunctions()->evaluate(
g_npn_evaluate_test_instance_->id(), window_obj,
&script_string, &result_var);
// If this test failed we would have crashed by now.
Expand Down
3 changes: 1 addition & 2 deletions ipc/ipc_channel_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ bool ChannelReader::DispatchInputData(const char* input_data,
return false;

#ifdef IPC_MESSAGE_LOG_ENABLED
Logging* logger = Logging::GetInstance();
std::string name;
logger->GetMessageText(m.type(), &name, &m, NULL);
Logging::GetInstance()->GetMessageText(m.type(), &name, &m, NULL);
TRACE_EVENT1("ipc,toplevel", "ChannelReader::DispatchInputData",
"name", name);
#else
Expand Down
3 changes: 1 addition & 2 deletions ipc/ipc_sync_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ void SyncChannel::SetRestrictDispatchChannelGroup(int group) {

bool SyncChannel::Send(Message* message) {
#ifdef IPC_MESSAGE_LOG_ENABLED
Logging* logger = Logging::GetInstance();
std::string name;
logger->GetMessageText(message->type(), &name, message, NULL);
Logging::GetInstance()->GetMessageText(message->type(), &name, message, NULL);
TRACE_EVENT1("ipc", "SyncChannel::Send", "name", name);
#else
TRACE_EVENT2("ipc", "SyncChannel::Send",
Expand Down
2 changes: 1 addition & 1 deletion net/base/escape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool UnescapeUnsignedCharAtIndex(const STR& escaped_text,
static_cast<typename STR::value_type>(escaped_text[index + 2]));
if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) {
*value = HexDigitToInt(most_sig_digit) * 16 +
HexDigitToInt(least_sig_digit);
HexDigitToInt(least_sig_digit);
return true;
}
return false;
Expand Down
11 changes: 4 additions & 7 deletions net/disk_cache/cache_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,12 @@ int PreferredCacheSize(int64 available) {
if (available < 0)
return kDefaultCacheSize;

int64 max_size = PreferredCacheSizeInternal(available);

// Limit cache size to somewhat less than kint32max to avoid potential
// integer overflows in cache backend implementations.
DCHECK(kDefaultCacheSize * 4 < kint32max);
if (max_size > kDefaultCacheSize * 4)
max_size = kDefaultCacheSize * 4;

return implicit_cast<int32>(max_size);
DCHECK_LT(kDefaultCacheSize * 4, kint32max);
return static_cast<int32>(std::min(
PreferredCacheSizeInternal(available),
static_cast<int64>(kDefaultCacheSize * 4)));
}

} // namespace disk_cache
Loading

0 comments on commit 7bc277b

Please sign in to comment.