Skip to content

Commit ae12308

Browse files
committed
Bug 944913 - Fixed char16_t/wchar_t mismatch in tollkit/. r=ehsan
--HG-- extra : rebase_source : c33427dd7c1c2db3d2741b8c2e0d1b4a0359a0a4
1 parent 9956262 commit ae12308

File tree

11 files changed

+54
-53
lines changed

11 files changed

+54
-53
lines changed

toolkit/components/downloads/nsDownloadScanner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,10 @@ nsDownloadScanner::Scan::DoScanAES()
459459
bool gotException = false;
460460
MOZ_SEH_TRY {
461461
(void)ae->SetClientGuid(GUID_MozillaVirusScannerPromptGeneric);
462-
(void)ae->SetLocalPath(mPath.BeginWriting());
462+
(void)ae->SetLocalPath(mPath.get());
463463
// Provide the src for everything but data: schemes.
464464
if (!mSkipSource)
465-
(void)ae->SetSource(mOrigin.BeginWriting());
465+
(void)ae->SetSource(mOrigin.get());
466466

467467
// Save() will invoke the scanner
468468
hr = ae->Save();

toolkit/components/startup/nsUserInfoWin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ nsUserInfo::GetUsername(char **aUsername)
3232
*aUsername = nullptr;
3333

3434
// ULEN is the max username length as defined in lmcons.h
35-
PRUnichar username[UNLEN +1];
35+
wchar_t username[UNLEN +1];
3636
DWORD size = mozilla::ArrayLength(username);
3737
if (!GetUserNameW(username, &size))
3838
return NS_ERROR_FAILURE;
@@ -47,7 +47,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
4747
NS_ENSURE_ARG_POINTER(aFullname);
4848
*aFullname = nullptr;
4949

50-
PRUnichar fullName[512];
50+
wchar_t fullName[512];
5151
DWORD size = mozilla::ArrayLength(fullName);
5252

5353
if (GetUserNameExW(NameDisplay, fullName, &size)) {
@@ -57,7 +57,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
5757

5858
// Try to use the net APIs regardless of the error because it may be
5959
// able to obtain the information.
60-
PRUnichar username[UNLEN + 1];
60+
wchar_t username[UNLEN + 1];
6161
size = mozilla::ArrayLength(username);
6262
if (!GetUserNameW(username, &size)) {
6363
// ERROR_NONE_MAPPED means the user info is not filled out on this computer
@@ -119,7 +119,7 @@ nsUserInfo::GetEmailAddress(char **aEmailAddress)
119119
*aEmailAddress = nullptr;
120120

121121
// RFC3696 says max length of an email address is 254
122-
PRUnichar emailAddress[255];
122+
wchar_t emailAddress[255];
123123
DWORD size = mozilla::ArrayLength(emailAddress);
124124

125125
if (!GetUserNameExW(NameUserPrincipal, emailAddress, &size)) {

toolkit/crashreporter/nsExceptionHandler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
871871
nsString crashReporterPath_temp;
872872

873873
exePath->GetPath(crashReporterPath_temp);
874-
crashReporterPath = ToNewUnicode(crashReporterPath_temp);
874+
crashReporterPath = reinterpret_cast<wchar_t*>(ToNewUnicode(crashReporterPath_temp));
875875
#elif !defined(__ANDROID__)
876876
nsCString crashReporterPath_temp;
877877

@@ -1098,7 +1098,7 @@ nsresult SetMinidumpPath(const nsAString& aPath)
10981098

10991099
#ifndef XP_LINUX
11001100
gExceptionHandler->set_dump_path(
1101-
CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading());
1101+
char16ptr_t(CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading()));
11021102
#else
11031103
gExceptionHandler->set_minidump_descriptor(
11041104
MinidumpDescriptor(CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading()));
@@ -1922,7 +1922,7 @@ FindPendingDir()
19221922
#ifdef XP_WIN
19231923
nsString path;
19241924
pendingDir->GetPath(path);
1925-
pendingDirectory = ToNewUnicode(path);
1925+
pendingDirectory = reinterpret_cast<wchar_t*>(ToNewUnicode(path));
19261926
#else
19271927
nsCString path;
19281928
pendingDir->GetNativePath(path);
@@ -2503,7 +2503,7 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)
25032503
nullptr, // no callback context
25042504
google_breakpad::ExceptionHandler::HANDLER_ALL,
25052505
MiniDumpNormal,
2506-
NS_ConvertASCIItoUTF16(crashPipe).BeginReading(),
2506+
NS_ConvertASCIItoUTF16(crashPipe).get(),
25072507
nullptr);
25082508
#ifdef XP_WIN
25092509
gExceptionHandler->set_handle_debug_exceptions(true);

toolkit/xre/nsAppRunner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
#include <process.h>
154154
#include <shlobj.h>
155155
#include "nsThreadUtils.h"
156-
#include <comutil.h>
157-
#include <Wbemidl.h>
156+
#include <comdef.h>
157+
#include <wbemidl.h>
158158
#endif
159159

160160
#ifdef XP_MACOSX

toolkit/xre/nsAppRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ WriteConsoleLog();
9797

9898
#ifdef XP_WIN
9999
BOOL
100-
WinLaunchChild(const PRUnichar *exePath, int argc,
100+
WinLaunchChild(const wchar_t *exePath, int argc,
101101
char **argv, HANDLE userToken = nullptr,
102102
HANDLE *hProcess = nullptr);
103103
BOOL

toolkit/xre/nsEmbedFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ using mozilla::startup::sChildProcessType;
9999
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
100100

101101
#ifdef XP_WIN
102-
static const PRUnichar kShellLibraryName[] = L"shell32.dll";
102+
static const wchar_t kShellLibraryName[] = L"shell32.dll";
103103
#endif
104104

105105
nsresult

toolkit/xre/nsNativeAppSupportWin.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ struct MessageWindow {
476476
}
477477

478478
// Class name: appName + "MessageWindow"
479-
static const PRUnichar *className() {
480-
static PRUnichar classNameBuffer[128];
481-
static PRUnichar *mClassName = 0;
479+
static const wchar_t *className() {
480+
static wchar_t classNameBuffer[128];
481+
static wchar_t *mClassName = 0;
482482
if ( !mClassName ) {
483483
::_snwprintf(classNameBuffer,
484484
128, // size of classNameBuffer in PRUnichars
@@ -643,7 +643,8 @@ nsNativeAppSupportWin::Start( bool *aResult ) {
643643
// Grab mutex first.
644644

645645
// Build mutex name from app name.
646-
::_snwprintf(mMutexName, sizeof mMutexName / sizeof(PRUnichar), L"%s%s%s",
646+
::_snwprintf(reinterpret_cast<wchar_t*>(mMutexName),
647+
sizeof mMutexName / sizeof(PRUnichar), L"%s%s%s",
647648
MOZ_MUTEX_NAMESPACE,
648649
NS_ConvertUTF8toUTF16(gAppData->name).get(),
649650
MOZ_STARTUP_MUTEX_NAME );
@@ -1218,7 +1219,7 @@ void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsString& aString)
12181219
// Ensure result's buffer is sufficiently big.
12191220
temp.SetLength( argLen );
12201221
// Now get the string contents.
1221-
DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINUNICODE );
1222+
DdeQueryString( mInstance, args, reinterpret_cast<wchar_t*>(temp.BeginWriting()), temp.Length(), CP_WINUNICODE );
12221223
// Parse out the given arg.
12231224
ParseDDEArg(temp.get(), index, aString);
12241225
return;

toolkit/xre/nsWindowsRestart.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* additional length if the string needs to be quoted and if characters need to
2525
* be escaped.
2626
*/
27-
static int ArgStrLen(const PRUnichar *s)
27+
static int ArgStrLen(const wchar_t *s)
2828
{
2929
int backslashes = 0;
3030
int i = wcslen(s);
@@ -65,7 +65,7 @@ static int ArgStrLen(const PRUnichar *s)
6565
*
6666
* @return the end of the string
6767
*/
68-
static PRUnichar* ArgToString(PRUnichar *d, const PRUnichar *s)
68+
static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
6969
{
7070
int backslashes = 0;
7171
BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr;
@@ -116,8 +116,8 @@ static PRUnichar* ArgToString(PRUnichar *d, const PRUnichar *s)
116116
*
117117
* argv is UTF8
118118
*/
119-
PRUnichar*
120-
MakeCommandLine(int argc, PRUnichar **argv)
119+
wchar_t*
120+
MakeCommandLine(int argc, wchar_t **argv)
121121
{
122122
int i;
123123
int len = 0;
@@ -130,11 +130,11 @@ MakeCommandLine(int argc, PRUnichar **argv)
130130
if (len == 0)
131131
len = 1;
132132

133-
PRUnichar *s = (PRUnichar*) malloc(len * sizeof(PRUnichar));
133+
wchar_t *s = (wchar_t*) malloc(len * sizeof(wchar_t));
134134
if (!s)
135135
return nullptr;
136136

137-
PRUnichar *c = s;
137+
wchar_t *c = s;
138138
for (i = 0; i < argc; ++i) {
139139
c = ArgToString(c, argv[i]);
140140
if (i + 1 != argc) {
@@ -168,7 +168,7 @@ AllocConvertUTF8toUTF16(const char *arg)
168168
}
169169

170170
static void
171-
FreeAllocStrings(int argc, PRUnichar **argv)
171+
FreeAllocStrings(int argc, wchar_t **argv)
172172
{
173173
while (argc) {
174174
--argc;
@@ -187,23 +187,23 @@ FreeAllocStrings(int argc, PRUnichar **argv)
187187
*/
188188

189189
BOOL
190-
WinLaunchChild(const PRUnichar *exePath,
191-
int argc, PRUnichar **argv,
190+
WinLaunchChild(const wchar_t *exePath,
191+
int argc, wchar_t **argv,
192192
HANDLE userToken = nullptr,
193193
HANDLE *hProcess = nullptr);
194194

195195
BOOL
196-
WinLaunchChild(const PRUnichar *exePath,
197-
int argc, char **argv,
196+
WinLaunchChild(const wchar_t *exePath,
197+
int argc, char **argv,
198198
HANDLE userToken,
199199
HANDLE *hProcess)
200200
{
201-
PRUnichar** argvConverted = new PRUnichar*[argc];
201+
wchar_t** argvConverted = new wchar_t*[argc];
202202
if (!argvConverted)
203203
return FALSE;
204204

205205
for (int i = 0; i < argc; ++i) {
206-
argvConverted[i] = AllocConvertUTF8toUTF16(argv[i]);
206+
argvConverted[i] = reinterpret_cast<wchar_t*>(AllocConvertUTF8toUTF16(argv[i]));
207207
if (!argvConverted[i]) {
208208
FreeAllocStrings(i, argvConverted);
209209
return FALSE;
@@ -216,13 +216,13 @@ WinLaunchChild(const PRUnichar *exePath,
216216
}
217217

218218
BOOL
219-
WinLaunchChild(const PRUnichar *exePath,
219+
WinLaunchChild(const wchar_t *exePath,
220220
int argc,
221-
PRUnichar **argv,
221+
wchar_t **argv,
222222
HANDLE userToken,
223223
HANDLE *hProcess)
224224
{
225-
PRUnichar *cl;
225+
wchar_t *cl;
226226
BOOL ok;
227227

228228
cl = MakeCommandLine(argc, argv);

toolkit/xre/nsWindowsWMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int main(int argc, char **argv, char **envp);
4949
#endif
5050

5151
static char*
52-
AllocConvertUTF16toUTF8(const WCHAR *arg)
52+
AllocConvertUTF16toUTF8(char16ptr_t arg)
5353
{
5454
// be generous... UTF16 units can expand up to 3 UTF8 units
5555
int len = wcslen(arg);

toolkit/xre/nsXREDirProvider.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ nsXREDirProvider::DoShutdown()
879879
static nsresult
880880
GetShellFolderPath(int folder, nsAString& _retval)
881881
{
882-
PRUnichar* buf;
882+
wchar_t* buf;
883883
uint32_t bufLength = _retval.GetMutableData(&buf, MAXPATHLEN + 3);
884884
NS_ENSURE_TRUE(bufLength >= (MAXPATHLEN + 3), NS_ERROR_OUT_OF_MEMORY);
885885

@@ -960,14 +960,14 @@ GetCachedHash(HKEY rootKey, const nsAString &regPath, const nsAString &path,
960960
nsAString &cachedHash)
961961
{
962962
HKEY baseKey;
963-
if (RegOpenKeyExW(rootKey, regPath.BeginReading(), 0, KEY_READ, &baseKey) !=
963+
if (RegOpenKeyExW(rootKey, reinterpret_cast<const wchar_t*>(regPath.BeginReading()), 0, KEY_READ, &baseKey) !=
964964
ERROR_SUCCESS) {
965965
return false;
966966
}
967967

968968
wchar_t cachedHashRaw[512];
969969
DWORD bufferSize = sizeof(cachedHashRaw);
970-
LONG result = RegQueryValueExW(baseKey, path.BeginReading(), 0, nullptr,
970+
LONG result = RegQueryValueExW(baseKey, reinterpret_cast<const wchar_t*>(path.BeginReading()), 0, nullptr,
971971
(LPBYTE)cachedHashRaw, &bufferSize);
972972
RegCloseKey(baseKey);
973973
if (result == ERROR_SUCCESS) {
@@ -1045,7 +1045,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
10451045
// AppDir may be a short path. Convert to long path to make sure
10461046
// the consistency of the update folder location
10471047
nsString longPath;
1048-
PRUnichar* buf;
1048+
wchar_t* buf;
10491049

10501050
uint32_t bufLength = longPath.GetMutableData(&buf, MAXPATHLEN);
10511051
NS_ENSURE_TRUE(bufLength >= MAXPATHLEN, NS_ERROR_OUT_OF_MEMORY);

0 commit comments

Comments
 (0)