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

Issue 1852143002: win: Remove GetModuleFromAddress, deduplicate __ImageBase code. (Closed)

Created:
4 years, 8 months ago by Nico
Modified:
4 years, 8 months ago
CC:
chromium-reviews, grt+watch_chromium.org, chromoting-reviews_chromium.org, sadrul, asvitkine+watch_chromium.org, wfh+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

win: Remove GetModuleFromAddress, deduplicate __ImageBase code. 8 different places were using __ImageBase to get the current module, create a CURRENT_MODULE() macro that all these places can use. All but one use of base::GetModuleFromAddress() were used to get the module of the current file; change all these to use CURRENT_MODULE() instead. The (somewhat lame) motivation is that GetModuleFromAddress() took a void* but was always called with function pointers, and converting function pointers to void* has undefined behavior. POSIX (dlsym()) requires that conversions between void* and function pointers work in practice, but on posix an explicit reinterpret_cast is required, and it seems nice to have compilers behave identically between platforms here (i.e. we should turn on clang/win's -Wmicrosoft-cast). In the one place where GetModuleFromAddress() didn't refer to the current TU's module, add an explicit reinterpret_cast. BUG=550065 TBR=asvitkine,wez Committed: https://crrev.com/d62f5447b35d5d8d1b3521a05b7ed312ab31dbd1 Cr-Commit-Position: refs/heads/master@{#384841}

Patch Set 1 #

Patch Set 2 : git add #

Patch Set 3 : . #

Patch Set 4 : . #

Patch Set 5 : . #

Patch Set 6 : . #

Patch Set 7 : . #

Patch Set 8 : . #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+68 lines, -112 lines) Patch
M base/base_paths_win.cc View 2 chunks +2 lines, -5 lines 0 comments Download
M base/debug/profiler.cc View 4 chunks +3 lines, -7 lines 0 comments Download
M base/file_version_info.h View 1 2 3 4 3 chunks +5 lines, -21 lines 0 comments Download
M base/message_loop/message_loop_unittest.cc View 2 chunks +2 lines, -1 line 0 comments Download
M base/message_loop/message_pump_win.cc View 1 2 3 4 5 3 chunks +3 lines, -4 lines 0 comments Download
M base/process/memory.h View 2 chunks +0 lines, -10 lines 0 comments Download
M base/process/memory_unittest.cc View 1 2 3 4 5 6 7 1 chunk +0 lines, -18 lines 2 comments Download
M base/process/memory_win.cc View 1 chunk +0 lines, -11 lines 0 comments Download
A base/win/current_module.h View 1 2 3 1 chunk +15 lines, -0 lines 2 comments Download
M base/win/message_window.cc View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
M base/win/scoped_handle.cc View 2 chunks +2 lines, -4 lines 0 comments Download
M base/win/scoped_handle_test_dll.cc View 2 chunks +2 lines, -4 lines 0 comments Download
M base/win/wrapped_window_proc.cc View 2 chunks +17 lines, -2 lines 2 comments Download
M chrome/child/pdf_child_init.cc View 2 chunks +2 lines, -6 lines 0 comments Download
M chrome/installer/util/module_util_win.cc View 2 chunks +2 lines, -1 line 0 comments Download
M components/metrics/metrics_log.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M remoting/base/breakpad_win.cc View 1 2 3 4 5 6 2 chunks +2 lines, -4 lines 0 comments Download
M remoting/host/continue_window_win.cc View 1 2 2 chunks +3 lines, -4 lines 2 comments Download
M remoting/host/disconnect_window_win.cc View 1 2 2 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 28 (13 generated)
Nico
4 years, 8 months ago (2016-04-04 00:35:44 UTC) #5
Will Harris
I noticed this is happening in screen_capturer_win_magnifier.cc too, via a single reinterpret_cast https://codereview.chromium.org/1852143002/diff/140001/base/win/wrapped_window_proc.cc File base/win/wrapped_window_proc.cc ...
4 years, 8 months ago (2016-04-04 01:26:44 UTC) #6
Nico
https://codereview.chromium.org/1852143002/diff/140001/base/win/wrapped_window_proc.cc File base/win/wrapped_window_proc.cc (right): https://codereview.chromium.org/1852143002/diff/140001/base/win/wrapped_window_proc.cc#newcode21 base/win/wrapped_window_proc.cc:21: static_cast<char*>(address), On 2016/04/04 01:26:44, Will Harris wrote: > why ...
4 years, 8 months ago (2016-04-04 01:38:47 UTC) #7
Will Harris
lgtm
4 years, 8 months ago (2016-04-04 02:02:23 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1852143002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1852143002/140001
4 years, 8 months ago (2016-04-04 02:04:41 UTC) #10
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/163979)
4 years, 8 months ago (2016-04-04 02:13:21 UTC) #12
Nico
tbr'ing: asvitkine: components/metrics wez: remoting
4 years, 8 months ago (2016-04-04 02:16:04 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1852143002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1852143002/140001
4 years, 8 months ago (2016-04-04 02:16:20 UTC) #17
commit-bot: I haz the power
Committed patchset #8 (id:140001)
4 years, 8 months ago (2016-04-04 02:21:21 UTC) #19
commit-bot: I haz the power
Patchset 8 (id:??) landed as https://crrev.com/d62f5447b35d5d8d1b3521a05b7ed312ab31dbd1 Cr-Commit-Position: refs/heads/master@{#384841}
4 years, 8 months ago (2016-04-04 02:22:51 UTC) #21
sof
https://codereview.chromium.org/1852143002/diff/140001/base/process/memory_unittest.cc File base/process/memory_unittest.cc (right): https://codereview.chromium.org/1852143002/diff/140001/base/process/memory_unittest.cc#newcode50 base/process/memory_unittest.cc:50: const int kConstantInModule = 42; This now appears unused ...
4 years, 8 months ago (2016-04-04 07:32:44 UTC) #23
sof
https://codereview.chromium.org/1852143002/diff/140001/base/process/memory_unittest.cc File base/process/memory_unittest.cc (right): https://codereview.chromium.org/1852143002/diff/140001/base/process/memory_unittest.cc#newcode50 base/process/memory_unittest.cc:50: const int kConstantInModule = 42; On 2016/04/04 07:32:44, sof ...
4 years, 8 months ago (2016-04-04 07:49:08 UTC) #24
Alexei Svitkine (slow)
lgtm
4 years, 8 months ago (2016-04-04 15:16:02 UTC) #25
joedow
lgtm remoting https://codereview.chromium.org/1852143002/diff/140001/base/win/current_module.h File base/win/current_module.h (right): https://codereview.chromium.org/1852143002/diff/140001/base/win/current_module.h#newcode1 base/win/current_module.h:1: // Copyright (c) 2016 The Chromium Authors. ...
4 years, 8 months ago (2016-04-04 15:37:01 UTC) #27
Nico
4 years, 8 months ago (2016-04-04 15:43:08 UTC) #28
Message was sent while issue was closed.
Thanks, addressing most of your comments at
https://codereview.chromium.org/1856683003

https://codereview.chromium.org/1852143002/diff/140001/remoting/host/continue...
File remoting/host/continue_window_win.cc (right):

https://codereview.chromium.org/1852143002/diff/140001/remoting/host/continue...
remoting/host/continue_window_win.cc:59: nullptr, (DLGPROC)DialogProc, (LPARAM)
this);
On 2016/04/04 15:37:01, joedow wrote:
> Why the extra space for 'this' and not in front of the other casts?

Excellent question. clang-format put it there, but that looks like a bug. Filed
https://llvm.org/bugs/show_bug.cgi?id=27198

Powered by Google App Engine
This is Rietveld 408576698