Closed Bug 539585 Opened 11 years ago Closed 10 years ago

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

Categories

(Core :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dholbert, Assigned: dholbert)

Details

(Whiteboard: [build_warning])

Attachments

(6 files, 1 obsolete file)

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)
Attachment #421535 - Flags: review?(benjamin)
Attachment #421536 - Flags: review?
Attachment #421536 - Flags: review? → review?(jst)
Attached patch fix for /editor/ directory (obsolete) — Splinter Review
Attachment #421540 - Flags: review?(neil)
Attachment #421541 - Flags: review?(dbaron)
With the 4 attached patches, we're just left with the 3 of these warnings in sqlite3.c.
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+
(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+
Attachment #421536 - Flags: review?(jst) → review+
Pushed a fix for a new instance of this in nsTableFrame.cpp:
http://hg.mozilla.org/mozilla-central/rev/8816f2b76e41
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?
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+
Status: NEW → ASSIGNED
Attachment #421535 - Flags: review?(benjamin) → review+
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
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [build_warning]
You need to log in before you can comment on or make changes to this bug.