Element.cpp:1969:59 [-Wformat=] format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'nsEventStates::InternalType {aka long unsigned int}'

RESOLVED FIXED in mozilla25

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla25
x86_64
Linux
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

My debug build spams this warning:
{
content/base/src/Element.cpp:1969:59 [-Wformat=] format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'nsEventStates::InternalType {aka long unsigned int}'
}

which, as it turns out, is the only remaining warning that I see for all of /content/base.

The code in question is:
> 1969   fprintf(out, " state=[%llx]", State().GetInternalValue());
 http://mxr.mozilla.org/mozilla-central/source/content/base/src/Element.cpp#1969
where GetInternalValue() returns InternalType, which is typedefed to uint64_t (which, on 64-bit linux, is a typedef for to "unsigned long", not unsigned-long-long, as the warning indicates.

This is pretty easy to fix -- we can just static_cast to unsigned long long, to *force* the arg to match the format string. The minor downside is that on 64-bit architectures, this will do some unnecessary promotion, but that should be harmless, since the promotion is safe and this is in a chunk of debugging code anyway (where perf isn't a factor).
Created attachment 784002 [details] [diff] [review]
fix v1
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #784002 - Flags: review?(bugs)
(Note: bug 730805 has a better way of doing this, but it seems to have stagnated.)

Updated

5 years ago
Attachment #784002 - Flags: review?(bugs) → review+
Depends on: 900274
Keywords: checkin-needed
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/8e78d28f3b46
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
Blocks: 900274
No longer depends on: 900274
You need to log in before you can comment on or make changes to this bug.