warning: format ‘%p’ expects type ‘void*’, but argument [n] has type ‘[class]*’

RESOLVED FIXED

Status

()

RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(6 attachments, 1 obsolete attachment)

(Assignee)

Description

9 years ago
Created attachment 421530 [details]
list of these warnings right now

Filing this bug on fixing gcc / g++ build warnings like this one:
{
 mozilla/content/svg/content/src/nsSVGStringProxyValue.cpp:154: warning: format ‘%p’ expects type ‘void*’, but argument 2 has type ‘nsSVGStringProxyValue*’
}

see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26542 for discussion on this warning.

It's easy to fix -- just static_cast the pointer to be a void*, when passing to printf.

Currently we've got 67 warnings of this type.  3 of those are in sqlite3.c, and the rest are in mozilla code. (most in /editor/libeditor/base/*Txn.cpp)
(Assignee)

Comment 1

9 years ago
Created attachment 421535 [details] [diff] [review]
fix for /xpcom/ directory
Attachment #421535 - Flags: review?(benjamin)
(Assignee)

Comment 2

9 years ago
Created attachment 421536 [details] [diff] [review]
fix for /content/ directory
Attachment #421536 - Flags: review?
(Assignee)

Updated

9 years ago
Attachment #421536 - Flags: review? → review?(jst)
(Assignee)

Comment 3

9 years ago
Created attachment 421540 [details] [diff] [review]
fix for /editor/ directory
Attachment #421540 - Flags: review?(neil)
(Assignee)

Comment 4

9 years ago
Created attachment 421541 [details] [diff] [review]
fix for /layout/ directory
Attachment #421541 - Flags: review?(dbaron)
(Assignee)

Comment 5

9 years ago
With the 4 attached patches, we're just left with the 3 of these warnings in sqlite3.c.

Comment 6

9 years ago
Comment on attachment 421540 [details] [diff] [review]
fix for /editor/ directory

>+    printf("%p Undo Insert Element of %p into parent %p at offset %d\n",
>+           static_cast<void*>(this),
>+           static_cast<void*>(mNode.get()),
>+           static_cast<void*>(mParent.get()), mOffset);
Nit: when you need more than two lines to list all the printf parameters, I
think it might make more sense to put them all on separate lines, to reduce
the chance that one subsequently gets overlooked.
Attachment #421540 - Flags: review?(neil) → review+
Comment on attachment 421541 [details] [diff] [review]
fix for /layout/ directory

r=dbaron

I hate this warning.
Attachment #421541 - Flags: review?(dbaron) → review+
(Assignee)

Comment 8

9 years ago
Created attachment 421551 [details] [diff] [review]
fix for /editor/ directory v2 (r=neil)

(In reply to comment #6)
> Nit: when you need more than two lines to list all the printf parameters, I
> think it might make more sense to put them all on separate lines, to reduce
> the chance that one subsequently gets overlooked.

Agreed - fixed in this version. Carrying forward r+.

(In reply to comment #7)
> I hate this warning.

Yeah, me too.
Attachment #421540 - Attachment is obsolete: true
Attachment #421551 - Flags: review+

Updated

9 years ago
Attachment #421536 - Flags: review?(jst) → review+
(Assignee)

Comment 10

9 years ago
Pushed a fix for a new instance of this in nsTableFrame.cpp:
http://hg.mozilla.org/mozilla-central/rev/8816f2b76e41
(Assignee)

Comment 11

9 years ago
Created attachment 424889 [details] [diff] [review]
fix for /testing/ directory

Here's a patch to fix a few instances of this warning in testing/mochitest/ssltunnel/ssltunnel.cpp (introduced with some logging code in changeset b7ee0f1acfef).  This also removes a few tab characters from that file.
Attachment #424889 - Flags: review?
(Assignee)

Updated

9 years ago
Attachment #424889 - Flags: review? → review?(jwalden+bmo)
Comment on attachment 424889 [details] [diff] [review]
fix for /testing/ directory

I echo dbaron.
Attachment #424889 - Flags: review?(jwalden+bmo) → review+
(Assignee)

Updated

9 years ago
Status: NEW → ASSIGNED

Updated

9 years ago
Attachment #421535 - Flags: review?(benjamin) → review+
(Assignee)

Comment 14

9 years ago
Landed fix for /xpcom/: http://hg.mozilla.org/mozilla-central/rev/970ed5de45ad

That's all the patches posted here. Resolving as FIXED.
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
(Assignee)

Updated

9 years ago
Whiteboard: [build_warning]
You need to log in before you can comment on or make changes to this bug.