Closed Bug 569586 Opened 14 years ago Closed 14 years ago

XPCOM compilation failure on mingw-w64 due to pointer to int cast loosing precision.

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jacek, Assigned: jacek)

References

Details

Attachments

(1 file)

Attached patch fix v1.0Splinter Review
I get following errors:

xpcom/base/nsStackWalk.cpp:1034:29: error: cast from 'void*' to 'DWORD' loses precision
xpcom/ds/nsWindowsRegKey.cpp:142:40: error: cast from 'HKEY__*' to 'PRUint32' loses precision
xpcom/ds/nsWindowsRegKey.cpp:160:42: error: cast from 'HKEY__*' to 'PRUint32' loses precision

All of those casts are intentional, so proper casts are all we need. The attached patch fixes the problem.
Attachment #448752 - Attachment is patch: true
Attachment #448752 - Flags: review?(benjamin)
Attachment #448752 - Flags: review?(benjamin) → review+
Thanks for quick review.
Keywords: checkin-needed
Assignee: nobody → jacek
Blocks: 570342
Sorry, I believe the nsWindowsRegKey changes are incorrect, because  nsWindowsRegKey::Open [1] takes a PRUint32, since it's an IDL method taking an unsigned long [2].  An HKEY is pointer-sized, so the current patch would truncate the handle.  I have an old patch [3] that works, but I'm not quite comfortable with changing the interface - I think it's doable to make the current open() implementation internal and (on win64 at last) add a stub for the predefined HKEYs, but haven't had time to really do it yet :(

[1] http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsWindowsRegKey.cpp?rev=5b3604a3cfbe&mark=109-109#107
[2] http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsIWindowsRegKey.idl?rev=5b3604a3cfbe&mark=141-141#124
[3] http://bitbucket.org/mook/mozwin64/src/tip/win64.nsIWindowsRegKey
My patch doesn't really change anything. These casts are already in the code, all my patch does is a different way of casting that is acceptable for mingw-w64. There even is a comment about the problem:

 * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey
 * parameter of this function.  However, for compatibility with 64-bit
 * Windows, that usage should probably be avoided in favor of openChild.

And the comment is also quite not right. HKEY is in fact a system HANDLE and such handles, although have 8-bytes size, use only 4 bytes values. so there is no problem with the code (except ugly casts).
http://hg.mozilla.org/mozilla-central/rev/8d73c22067ed
Status: NEW → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: