Closed Bug 504025 Opened 15 years ago Closed 15 years ago

[windows x64] casting pointer to long is illegal on win64

Categories

(Core :: General, defect)

x86_64
Windows XP
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.9.2b1

People

(Reporter: Mook, Assigned: Mook)

Details

Attachments

(3 files, 2 obsolete files)

On 64 bit Windows, sizeof(long) is 32 bit and sizeof(void*) is 64 bits.  (Yes, that's pretty ridiculous).

When compiling this with GCC, trying to cast a void* to a long is a fatal error.

Filing this bug as a generic catch-all for these casts
Component: Networking → General
QA Contact: networking → general
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsRequestObserverProxy.cpp?rev=7239b015f833&mark=94,141#91

See comment 0 for rationale.

(Sorry, I was originally going to file one bug per patch, but was told a catch-all bug was better; hence the component was initially set to networking.)
Attachment #388416 - Flags: review?(cbiesinger)
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsAutodialWin.cpp?rev=7239b015f833&mark=691,740#688

This one's actually casting a HANDLE to a UINT, but it's another "don't cast void* to long" patch :)
Attachment #388417 - Flags: review?
Attachment #388417 - Flags: review? → review?(doug.turner)
http://mxr.mozilla.org/mozilla-central/source/uriloader/exthandler/win/nsMIMEInfoWin.cpp?rev=7239b015f833&mark=149,329#146

See comment 0 for details; hInstaApp is a HINST(void* sized) and can't be cast to an int, it needs to be cast to something pointer-sized.  LONG_PTR is that on Windows.

(I'm not sure who to pick for r? on this one, given that it's windows-only code and none of the peers listed seem particularly windows-oriented...)
Attachment #388418 - Flags: review?(benjamin)
Comment on attachment 388416 [details] [diff] [review]
network: nsRequestObserverProxy.cpp - don't cast to long

just use %p and remove the cast
Attachment #388416 - Flags: review?(cbiesinger) → review-
Comment on attachment 388418 [details] [diff] [review]
cast HINST to LONG_PTR instead of int for comparison with 32
[Checkin: Comment 12]

I thought I was a peer for this one, but apparently not :)
Attachment #388418 - Flags: superreview+
Attachment #388417 - Flags: review?(doug.turner) → review+
Attached patch use %p instead of casts (obsolete) — Splinter Review
Thanks for the fast review!

Also, didn't know NSPR's printf supported %p - too used to the intersection of (gcc, msvc) :)
Attachment #388416 - Attachment is obsolete: true
Attachment #388423 - Flags: review?(cbiesinger)
Comment on attachment 388423 [details] [diff] [review]
use %p instead of casts

can you add a space after the comma?

both gcc and msvc support %p, right?
Attachment #388423 - Flags: review?(cbiesinger) → review+
carrying forward r+ from bug 388423

... and yes, msvc does have %p.  I _think_ I'll get things right eventually. Sigh.
Attachment #388423 - Attachment is obsolete: true
Attachment #388425 - Flags: review+
Attachment #388418 - Flags: review?(benjamin) → review+
Keywords: checkin-needed
Which patches need checkin here? All of the non-obsolete ones?
(In reply to comment #9)
> Which patches need checkin here? All of the non-obsolete ones?

I think so, yes - nothing here touches any interfaces, so by the new rules nothing should need sr.  They also all happen to be trivial patches (<1k each) :)
Comment on attachment 388417 [details] [diff] [review]
don't cast HANDLE to UINT either
[Checkin: Comment 11]


http://hg.mozilla.org/mozilla-central/rev/29dd8a03ef7d
Attachment #388417 - Attachment description: don't cast HANDLE to UINT either → don't cast HANDLE to UINT either [Checkin: Comment 11]
Comment on attachment 388418 [details] [diff] [review]
cast HINST to LONG_PTR instead of int for comparison with 32
[Checkin: Comment 12]


http://hg.mozilla.org/mozilla-central/rev/2311880a8e6a
Attachment #388418 - Attachment description: cast HINST to LONG_PTR instead of int for comparison with 32 → cast HINST to LONG_PTR instead of int for comparison with 32 [Checkin: Comment 12]
Comment on attachment 388425 [details] [diff] [review]
add spaces
[Checkin: Comment 13]


http://hg.mozilla.org/mozilla-central/rev/7a25fbd9ab9f
Attachment #388425 - Attachment description: add spaces → add spaces [Checkin: Comment 13]
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2b1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: