Closed Bug 1256464 Opened 8 years ago Closed 8 years ago

mozglue/misc/StackWalk.cpp(261): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 2 has type 'LPVOID'

Categories

(Core :: mozglue, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: gps, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

This compiler warning is getting converted to an error when automation builds with VS2015u1.
As part of unblocking building with VS2015u1 in automation, I'm mass
disabling compiler warnings that are turned into errors. This is not
the preferred mechanism to fix compilation warnings. So hopefully
this patch never lands because someone insists of fixing the underlying
problem instead. But if it does land, hopefully the workaround is
only temporary.

Review commit: https://reviewboard.mozilla.org/r/39839/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39839/
Attachment #8730408 - Flags: review?(nfroyd)
Comment on attachment 8730408 [details]
MozReview Request: Bug 1256464 - Disable C4477 to unblock compilation on VS2015; r?froydnj

https://reviewboard.mozilla.org/r/39839/#review36457

Can you try to just change the LPVOID declaration here:

http://mxr.mozilla.org/mozilla-central/source/mozglue/misc/StackWalk.cpp#250

to use LPSTR instead, and see if that compiles warning-free?  That's really the correct way to fix this.
Attachment #8730408 - Flags: review?(nfroyd)
Without this change, Visual Studio 2015 complains:

mozglue/misc/StackWalk.cpp(261): warning C4477: 'fprintf' : format
string '%s' requires an argument of type 'char *', but variadic argument
2 has type 'LPVOID'

Review commit: https://reviewboard.mozilla.org/r/39881/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39881/
Attachment #8730459 - Flags: review?(nfroyd)
Attachment #8730408 - Attachment is obsolete: true
Comment on attachment 8730459 [details]
MozReview Request: Bug 1256464 - Use LPSTR instead of LPVOID to avoid C4477 on VS2015; r?froydnj

https://reviewboard.mozilla.org/r/39881/#review36463

Thank you!
Attachment #8730459 - Flags: review?(nfroyd) → review+
https://reviewboard.mozilla.org/r/39881/#review36471

::: mozglue/misc/StackWalk.cpp:257
(Diff revision 1)
>    FormatMessageA(
>      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
>      nullptr,
>      lastErr,
>      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
>      (LPSTR)&lpMsgBuf,

This cast is a) wrong (FormatMessageA wants a _Out_ LPSTR, not a LPSTR) b) now useless (because a lpMsgBuf being a LPSTR, &lpMsgBuf is now a _Out_ LPSTR).
Mmmmm actually, _Out_ expands to nothing, so it seems like Windows is bending C in awful ways, and does require the (LPSTR) cast. Urgh.
https://hg.mozilla.org/mozilla-central/rev/ba45f827d74b
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: