Closed Bug 1256027 Opened 4 years ago Closed 4 years ago

C4477 snwprintf format string '%s' requires an argument of type 'wchar_t *', but variadic argument 1 has type 'char16ptr_t'

Categories

(Core :: General, defect)

defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: gps, Assigned: Waldo)

References

Details

Attachments

(2 files, 1 obsolete file)

The following warnings in toolkit/xre are currently getting suppressed by Visual Studio 2015. To reproduce them, remove "-Wv:18" from old-configure.in and rebuild.

toolkit/xre/nsNativeAppSupportWin.cpp:508 [C4477] '_snwprintf' : format string '%s' requires an argument of type 'wchar_t *', but variadic argument 1 has type 'char16ptr_t'
toolkit/xre/nsNativeAppSupportWin.cpp:670 [C4477] '_snwprintf' : format string '%s' requires an argument of type 'wchar_t *', but variadic argument 2 has type 'char16ptr_t'
toolkit/xre/nsWindowsRestart.cpp:292 [C4477] 'wprintf' : format string '%s' requires an argument of type 'wchar_t *', but variadic argument 1 has type 'LPVOID'
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 on fixing the underlying
problem instead. But if it does land, hopefully the workaround is
only temporary.

Review commit: https://reviewboard.mozilla.org/r/39947/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39947/
Attachment #8730495 - Flags: review?(benjamin)
Comment on attachment 8730495 [details]
MozReview Request: Bug 1256027 - Disable C4477 to unblock compilation on VS2015; r?bsmedberg

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39947/diff/1-2/
Comment on attachment 8730495 [details]
MozReview Request: Bug 1256027 - Disable C4477 to unblock compilation on VS2015; r?bsmedberg

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39947/diff/2-3/
Comment on attachment 8730495 [details]
MozReview Request: Bug 1256027 - Disable C4477 to unblock compilation on VS2015; r?bsmedberg

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39947/diff/3-4/
jimm: This is one of the few compiler warnings bugs blocking VS2015 that hasn't seen any action. Could you please triage it? The preferred resolution is to fix the C++ warning, which I don't think is much effort for someone competent in C++ (which isn't me).
Flags: needinfo?(jmathies)
Attached patch Maybe a patch?Splinter Review
Untested, but this might work.
Assignee: nobody → jwalden+bmo
Status: NEW → ASSIGNED
Comment on attachment 8734066 [details] [diff] [review]
Maybe a patch?

Review of attachment 8734066 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with changes below.

::: toolkit/xre/nsNativeAppSupportWin.cpp
@@ +505,5 @@
>          if ( !mClassName ) {
>              ::_snwprintf(classNameBuffer,
>                           128,   // size of classNameBuffer in PRUnichars
>                           L"%s%s",
> +                         static_cast<const wchar_t*>(NS_ConvertUTF8toUTF16(gAppData->remotingName).get()),

wwc():

http://mxr.mozilla.org/mozilla-central/source/xpcom/string/nsString.h#154

ought to do the same thing with less fussiness...but I guess there aren't |const| variants of those functions, bother.

::: toolkit/xre/nsWindowsRestart.cpp
@@ +288,5 @@
>                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
>                    (LPTSTR) &lpMsgBuf,
>                    0,
>                    nullptr);
> +    wprintf(L"Error restarting: %s\n", lpMsgBuf ? static_cast<const wchar_t*>(lpMsgBuf) : L"(null)");

I think this change instead wants to change |lpMsgBuf| to a LPTSTR.  (Yes, this is wacky, and yes, FormatMessage is a terrible interface for suggesting that you do this, but what are you gonna do?)
Attachment #8734066 - Flags: review+
Want to make the change in comment 7 and land this?
Flags: needinfo?(jwalden+bmo)
Waldo's original patch passed Try.
Attachment #8730495 - Attachment is obsolete: true
Attachment #8730495 - Flags: review?(benjamin)
Flags: needinfo?(jmathies)
The version of the patch on inbound still doesn't compile with VS2015. I'm using Waldo's original version of the patch (from comment #6) to test VS2015.
Keywords: leave-open
End state is Waldo's original patch, which so far has been the only
version that compiles on VS2015.

Review commit: https://reviewboard.mozilla.org/r/42201/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/42201/
Attachment #8734390 - Flags: review?(nfroyd)
Attachment #8734390 - Flags: review?(nfroyd) → review+
Comment on attachment 8734390 [details]
MozReview Request: Bug 1256027 - Coerce VS2015 into compiling without warnings; r?froydnj

https://reviewboard.mozilla.org/r/42201/#review38771

Sure.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Keywords: leave-open
Resolution: --- → FIXED
Depends on: 1259919
Flags: needinfo?(jwalden+bmo)
You need to log in before you can comment on or make changes to this bug.