Closed Bug 781058 Opened 12 years ago Closed 12 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: dholbert, Assigned: Ms2ger)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

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)
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: fatvals
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/
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)
setvalue is a horrible API
Attachment #650016 - Flags: review?(mounir)
Attachment #650018 - Flags: review?(mounir)
(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+
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
Closed: 12 years ago12 years ago
Resolution: --- → DUPLICATE
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
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: