Fix -Werror=int-to-pointer-cast in dom/

RESOLVED FIXED in mozilla17

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: Ms2ger)

Tracking

(Blocks: 1 bug)

Trunk
mozilla17
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

5 years ago
Bug 743573 annotated dom/base/Makefile.in with FAIL_ON_WARNINGS, and there's at least one warning in that directory that's now killing my build  (with --enable-warnings-as-errors):
{
dom/base/nsDOMClassInfo.cpp: In function ‘void* FlagsToPrivate(PRUint32)’:
dom/base/nsDOMClassInfo.cpp:9069:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
}

I'm using GCC 4.7 (though IIRC that warning exists in GCC 4.6 as well, and I'd guess we have a decent number of developers using GCC 4.6)
(Reporter)

Comment 1

5 years ago
This warning is for this line: https://hg.mozilla.org/mozilla-central/rev/9c869e64ee26#l18.2267
from Bug 549143.

>  return (void *)(flags << 1);
(where flags is a PRUint32)
Blocks: 549143
(Assignee)

Updated

5 years ago
Assignee: nobody → Ms2ger
Summary: nsDOMClassInfo.cpp:9069:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] → Fix -Werror=int-to-pointer-cast in dom/
(Assignee)

Comment 2

5 years ago
Created attachment 650015 [details] [diff] [review]
Part a: nsPluginNativeWindowGtk2

We try to stick an XID into the void* window in NPWindow; this patch keeps the conversion in dedicated functions.
Attachment #650015 - Flags: review?(mounir)
(Assignee)

Comment 3

5 years ago
Created attachment 650016 [details] [diff] [review]
Part b: PluginInstanceParent

setvalue is a horrible API
Attachment #650016 - Flags: review?(mounir)
(Assignee)

Comment 4

5 years ago
Created attachment 650018 [details] [diff] [review]
Part c: nsDOMClassInfo
Attachment #650018 - Flags: review?(mounir)
(Reporter)

Comment 5

5 years ago
(At some point, I think uintptr_t wasn't supported by MSVC -- does it compile there now?)
Comment on attachment 650015 [details] [diff] [review]
Part a: nsPluginNativeWindowGtk2

Review of attachment 650015 [details] [diff] [review]:
-----------------------------------------------------------------

r=me if you check if static_cast<> is usable instead of reinterpret_cast<>.

::: dom/plugins/base/nsPluginNativeWindowGtk2.cpp
@@ +29,5 @@
>    virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance);
>  private:
> +  void SetWindow(XID aWindow)
> +  {
> +    window = reinterpret_cast<void*>(static_cast<uintptr_t>(aWindow));

I wonder why reinterpret_cast<> instead of static_cast<>... Could you confirm static_cast<> doesn't work here?
Attachment #650015 - Flags: review?(mounir) → review+
Comment on attachment 650016 [details] [diff] [review]
Part b: PluginInstanceParent

Review of attachment 650016 [details] [diff] [review]:
-----------------------------------------------------------------

Same thing for reinterpret_cast<>/static_cast<>.
Attachment #650016 - Flags: review?(mounir) → review+
Attachment #650018 - Flags: review?(mounir) → review+
(Assignee)

Comment 8

5 years ago
https://hg.mozilla.org/mozilla-central/rev/8759d59636f0
https://hg.mozilla.org/mozilla-central/rev/2a19a83e94c8
https://hg.mozilla.org/mozilla-central/rev/3199bc043da4
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
Duplicate of this bug: 781545
(Reporter)

Comment 10

5 years ago
Patch b here didn't finish off PluginInstanceParent.cpp -- a very-similar chunk of code -- with "(void*)drawingModel" -- also appears at line 453 (50 lines after the chunk touched by patch b), and that chunk triggers the same warning/error.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Yep, that's what I ran into in bug 781545. Landed on inbound.
Status: REOPENED → RESOLVED
Last Resolved: 5 years ago5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 781545
(Reporter)

Comment 12

5 years ago
Yup, just caught that. Thanks!

(Re-resolving as FIXED rather than dupe, since this bug and bug 781545 both had patches land, to fix different (but related) things, and it feels icky to have had patches land on a bug that's marked as a duplicate.)
Resolution: DUPLICATE → FIXED
Duplicate of this bug: 781686
You need to log in before you can comment on or make changes to this bug.