Bug 784739 - Switch from NULL to nullptr in toolkit/components/ (2/2); r=ehsan

This commit is contained in:
Birunthan Mohanathas 2013-10-10 16:38:19 -04:00
Родитель 72f11bcb4b
Коммит 9deb678652
18 изменённых файлов: 220 добавлений и 216 удалений

Просмотреть файл

@ -102,7 +102,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl
if (!ShouldShowAlert()) { if (!ShouldShowAlert()) {
// Do not display the alert. Instead call alertfinished and get out. // Do not display the alert. Instead call alertfinished and get out.
if (aAlertListener) if (aAlertListener)
aAlertListener->Observe(NULL, "alertfinished", PromiseFlatString(aAlertCookie).get()); aAlertListener->Observe(nullptr, "alertfinished", PromiseFlatString(aAlertCookie).get());
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1727,15 +1727,15 @@ NS_DEFINE_NAMED_CID(NS_AUTOCOMPLETECONTROLLER_CID);
NS_DEFINE_NAMED_CID(NS_AUTOCOMPLETESIMPLERESULT_CID); NS_DEFINE_NAMED_CID(NS_AUTOCOMPLETESIMPLERESULT_CID);
static const mozilla::Module::CIDEntry kAutoCompleteCIDs[] = { static const mozilla::Module::CIDEntry kAutoCompleteCIDs[] = {
{ &kNS_AUTOCOMPLETECONTROLLER_CID, false, NULL, nsAutoCompleteControllerConstructor }, { &kNS_AUTOCOMPLETECONTROLLER_CID, false, nullptr, nsAutoCompleteControllerConstructor },
{ &kNS_AUTOCOMPLETESIMPLERESULT_CID, false, NULL, nsAutoCompleteSimpleResultConstructor }, { &kNS_AUTOCOMPLETESIMPLERESULT_CID, false, nullptr, nsAutoCompleteSimpleResultConstructor },
{ NULL } { nullptr }
}; };
static const mozilla::Module::ContractIDEntry kAutoCompleteContracts[] = { static const mozilla::Module::ContractIDEntry kAutoCompleteContracts[] = {
{ NS_AUTOCOMPLETECONTROLLER_CONTRACTID, &kNS_AUTOCOMPLETECONTROLLER_CID }, { NS_AUTOCOMPLETECONTROLLER_CONTRACTID, &kNS_AUTOCOMPLETECONTROLLER_CID },
{ NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID, &kNS_AUTOCOMPLETESIMPLERESULT_CID }, { NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID, &kNS_AUTOCOMPLETESIMPLERESULT_CID },
{ NULL } { nullptr }
}; };
static const mozilla::Module kAutoCompleteModule = { static const mozilla::Module kAutoCompleteModule = {

Просмотреть файл

@ -70,7 +70,7 @@ nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, REFNSIID aIID,
NS_ENSURE_NO_AGGREGATION(aOuter); NS_ENSURE_NO_AGGREGATION(aOuter);
nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv); nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv);
if (NULL == inst) { if (nullptr == inst) {
return rv; return rv;
} }
/* NS_ADDREF(inst); */ /* NS_ADDREF(inst); */
@ -111,30 +111,30 @@ NS_DEFINE_NAMED_CID(NS_UPDATEPROCESSOR_CID);
#endif #endif
static const mozilla::Module::CIDEntry kToolkitCIDs[] = { static const mozilla::Module::CIDEntry kToolkitCIDs[] = {
{ &kNS_TOOLKIT_APPSTARTUP_CID, false, NULL, nsAppStartupConstructor }, { &kNS_TOOLKIT_APPSTARTUP_CID, false, nullptr, nsAppStartupConstructor },
{ &kNS_USERINFO_CID, false, NULL, nsUserInfoConstructor }, { &kNS_USERINFO_CID, false, nullptr, nsUserInfoConstructor },
{ &kNS_ALERTSSERVICE_CID, false, NULL, nsAlertsServiceConstructor }, { &kNS_ALERTSSERVICE_CID, false, nullptr, nsAlertsServiceConstructor },
#if defined(XP_WIN) && !defined(MOZ_DISABLE_PARENTAL_CONTROLS) #if defined(XP_WIN) && !defined(MOZ_DISABLE_PARENTAL_CONTROLS)
{ &kNS_PARENTALCONTROLSSERVICE_CID, false, NULL, nsParentalControlsServiceWinConstructor }, { &kNS_PARENTALCONTROLSSERVICE_CID, false, nullptr, nsParentalControlsServiceWinConstructor },
#endif #endif
{ &kNS_DOWNLOADMANAGER_CID, false, NULL, nsDownloadManagerConstructor }, { &kNS_DOWNLOADMANAGER_CID, false, nullptr, nsDownloadManagerConstructor },
{ &kNS_DOWNLOADPLATFORM_CID, false, NULL, DownloadPlatformConstructor }, { &kNS_DOWNLOADPLATFORM_CID, false, nullptr, DownloadPlatformConstructor },
{ &kNS_DOWNLOAD_CID, false, NULL, nsDownloadProxyConstructor }, { &kNS_DOWNLOAD_CID, false, nullptr, nsDownloadProxyConstructor },
{ &kNS_FIND_SERVICE_CID, false, NULL, nsFindServiceConstructor }, { &kNS_FIND_SERVICE_CID, false, nullptr, nsFindServiceConstructor },
{ &kNS_TYPEAHEADFIND_CID, false, NULL, nsTypeAheadFindConstructor }, { &kNS_TYPEAHEADFIND_CID, false, nullptr, nsTypeAheadFindConstructor },
#ifdef MOZ_URL_CLASSIFIER #ifdef MOZ_URL_CLASSIFIER
{ &kNS_APPLICATION_REPUTATION_SERVICE_CID, false, NULL, ApplicationReputationServiceConstructor }, { &kNS_APPLICATION_REPUTATION_SERVICE_CID, false, nullptr, ApplicationReputationServiceConstructor },
{ &kNS_URLCLASSIFIERPREFIXSET_CID, false, NULL, nsUrlClassifierPrefixSetConstructor }, { &kNS_URLCLASSIFIERPREFIXSET_CID, false, nullptr, nsUrlClassifierPrefixSetConstructor },
{ &kNS_URLCLASSIFIERDBSERVICE_CID, false, NULL, nsUrlClassifierDBServiceConstructor }, { &kNS_URLCLASSIFIERDBSERVICE_CID, false, nullptr, nsUrlClassifierDBServiceConstructor },
{ &kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, NULL, nsUrlClassifierStreamUpdaterConstructor }, { &kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, nullptr, nsUrlClassifierStreamUpdaterConstructor },
{ &kNS_URLCLASSIFIERUTILS_CID, false, NULL, nsUrlClassifierUtilsConstructor }, { &kNS_URLCLASSIFIERUTILS_CID, false, nullptr, nsUrlClassifierUtilsConstructor },
#endif #endif
{ &kNS_BROWSERSTATUSFILTER_CID, false, NULL, nsBrowserStatusFilterConstructor }, { &kNS_BROWSERSTATUSFILTER_CID, false, nullptr, nsBrowserStatusFilterConstructor },
{ &kNS_CHARSETMENU_CID, false, NULL, NS_NewCharsetMenu }, { &kNS_CHARSETMENU_CID, false, nullptr, NS_NewCharsetMenu },
#if defined(USE_MOZ_UPDATER) #if defined(USE_MOZ_UPDATER)
{ &kNS_UPDATEPROCESSOR_CID, false, NULL, nsUpdateProcessorConstructor }, { &kNS_UPDATEPROCESSOR_CID, false, nullptr, nsUpdateProcessorConstructor },
#endif #endif
{ NULL } { nullptr }
}; };
static const mozilla::Module::ContractIDEntry kToolkitContracts[] = { static const mozilla::Module::ContractIDEntry kToolkitContracts[] = {
@ -162,7 +162,7 @@ static const mozilla::Module::ContractIDEntry kToolkitContracts[] = {
#if defined(USE_MOZ_UPDATER) #if defined(USE_MOZ_UPDATER)
{ NS_UPDATEPROCESSOR_CONTRACTID, &kNS_UPDATEPROCESSOR_CID }, { NS_UPDATEPROCESSOR_CONTRACTID, &kNS_UPDATEPROCESSOR_CID },
#endif #endif
{ NULL } { nullptr }
}; };
static const mozilla::Module kToolkitModule = { static const mozilla::Module kToolkitModule = {

Просмотреть файл

@ -84,7 +84,7 @@ nsCommandLine::nsCommandLine() :
} }
NS_IMPL_CLASSINFO(nsCommandLine, NULL, 0, NS_COMMANDLINE_CID) NS_IMPL_CLASSINFO(nsCommandLine, nullptr, 0, NS_COMMANDLINE_CID)
NS_IMPL_ISUPPORTS2_CI(nsCommandLine, NS_IMPL_ISUPPORTS2_CI(nsCommandLine,
nsICommandLine, nsICommandLine,
nsICommandLineRunner) nsICommandLineRunner)
@ -267,7 +267,7 @@ nsCommandLine::ResolveFile(const nsAString& aArgument, nsIFile* *aResult)
NS_CopyUnicodeToNative(aArgument, path); NS_CopyUnicodeToNative(aArgument, path);
CFURLRef newurl = CFURLRef newurl =
CFURLCreateFromFileSystemRepresentationRelativeToBase(NULL, (const UInt8*) path.get(), CFURLCreateFromFileSystemRepresentationRelativeToBase(nullptr, (const UInt8*) path.get(),
path.Length(), path.Length(),
true, baseurl); true, baseurl);
@ -668,13 +668,13 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandLine)
NS_DEFINE_NAMED_CID(NS_COMMANDLINE_CID); NS_DEFINE_NAMED_CID(NS_COMMANDLINE_CID);
static const mozilla::Module::CIDEntry kCommandLineCIDs[] = { static const mozilla::Module::CIDEntry kCommandLineCIDs[] = {
{ &kNS_COMMANDLINE_CID, false, NULL, nsCommandLineConstructor }, { &kNS_COMMANDLINE_CID, false, nullptr, nsCommandLineConstructor },
{ NULL } { nullptr }
}; };
static const mozilla::Module::ContractIDEntry kCommandLineContracts[] = { static const mozilla::Module::ContractIDEntry kCommandLineContracts[] = {
{ "@mozilla.org/toolkit/command-line;1", &kNS_COMMANDLINE_CID }, { "@mozilla.org/toolkit/command-line;1", &kNS_COMMANDLINE_CID },
{ NULL } { nullptr }
}; };
static const mozilla::Module kCommandLineModule = { static const mozilla::Module kCommandLineModule = {

Просмотреть файл

@ -31,12 +31,12 @@ UnicodeToNative(JSContext *cx, const jschar *source, size_t slen)
nsresult rv = NS_CopyUnicodeToNative(unicode, native); nsresult rv = NS_CopyUnicodeToNative(unicode, native);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
JS_ReportError(cx, "could not convert string to native charset"); JS_ReportError(cx, "could not convert string to native charset");
return NULL; return nullptr;
} }
char* result = static_cast<char*>(JS_malloc(cx, native.Length() + 1)); char* result = static_cast<char*>(JS_malloc(cx, native.Length() + 1));
if (!result) if (!result)
return NULL; return nullptr;
memcpy(result, native.get(), native.Length() + 1); memcpy(result, native.get(), native.Length() + 1);
return result; return result;
@ -134,13 +134,13 @@ Module::Call(nsIXPConnectWrappedNative* wrapper,
NS_DEFINE_NAMED_CID(JSCTYPES_CID); NS_DEFINE_NAMED_CID(JSCTYPES_CID);
static const mozilla::Module::CIDEntry kCTypesCIDs[] = { static const mozilla::Module::CIDEntry kCTypesCIDs[] = {
{ &kJSCTYPES_CID, false, NULL, mozilla::ctypes::ModuleConstructor }, { &kJSCTYPES_CID, false, nullptr, mozilla::ctypes::ModuleConstructor },
{ NULL } { nullptr }
}; };
static const mozilla::Module::ContractIDEntry kCTypesContracts[] = { static const mozilla::Module::ContractIDEntry kCTypesContracts[] = {
{ JSCTYPES_CONTRACTID, &kJSCTYPES_CID }, { JSCTYPES_CONTRACTID, &kJSCTYPES_CID },
{ NULL } { nullptr }
}; };
static const mozilla::Module kCTypesModule = { static const mozilla::Module kCTypesModule = {

Просмотреть файл

@ -16,7 +16,7 @@
#define FAIL \ #define FAIL \
{ \ { \
fprintf(stderr, "Assertion failed at line %i\n", __LINE__); \ fprintf(stderr, "Assertion failed at line %i\n", __LINE__); \
(*(int*)NULL)++; \ (*(int*)nullptr)++; \
} }

Просмотреть файл

@ -19,8 +19,8 @@
* - 1: acquired * - 1: acquired
* - < 0: error, resource has been released several times. * - < 0: error, resource has been released several times.
*/ */
int *gFinalizerTestResources = NULL; int *gFinalizerTestResources = nullptr;
char **gFinalizerTestNames = NULL; char **gFinalizerTestNames = nullptr;
size_t gFinalizerTestSize; size_t gFinalizerTestSize;
void void
@ -31,7 +31,7 @@ test_finalizer_start(size_t size)
gFinalizerTestSize = size; gFinalizerTestSize = size;
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
gFinalizerTestResources[i] = 0; gFinalizerTestResources[i] = 0;
gFinalizerTestNames[i] = NULL; gFinalizerTestNames[i] = nullptr;
} }
} }
@ -197,21 +197,21 @@ test_finalizer_cmp_int32_ptr_t(int32_t *a, int32_t *b)
return a==b; return a==b;
} }
// Resource type: NULL // Resource type: nullptr
// Acquire resource i // Acquire resource i
void* void*
test_finalizer_acq_null_t(size_t i) test_finalizer_acq_null_t(size_t i)
{ {
gFinalizerTestResources[0] = 1;//Always index 0 gFinalizerTestResources[0] = 1;//Always index 0
return NULL; return nullptr;
} }
// Release resource i // Release resource i
void void
test_finalizer_rel_null_t(void *i) test_finalizer_rel_null_t(void *i)
{ {
if (i != NULL) { if (i != nullptr) {
MOZ_CRASH("Assertion failed"); MOZ_CRASH("Assertion failed");
} }
gFinalizerTestResources[0] --; gFinalizerTestResources[0] --;
@ -306,10 +306,10 @@ test_finalizer_cmp_struct_t(RECT a, RECT b)
return a.top == b.top; return a.top == b.top;
} }
// Support for checking that we reject NULL finalizer // Support for checking that we reject nullptr finalizer
afun* test_finalizer_rel_null_function() afun* test_finalizer_rel_null_function()
{ {
return NULL; return nullptr;
} }
void void

Просмотреть файл

@ -63,8 +63,8 @@ Base64urlEncode(const uint8_t* aBytes,
uint32_t aNumBytes, uint32_t aNumBytes,
nsCString& _result) nsCString& _result)
{ {
// SetLength does not set aside space for NULL termination. PL_Base64Encode // SetLength does not set aside space for null termination. PL_Base64Encode
// will not NULL terminate, however, nsCStrings must be NULL terminated. As a // will not null terminate, however, nsCStrings must be null terminated. As a
// result, we set the capacity to be one greater than what we need, and the // result, we set the capacity to be one greater than what we need, and the
// length to our desired length. // length to our desired length.
uint32_t length = (aNumBytes + 2) / 3 * 4; // +2 due to integer math. uint32_t length = (aNumBytes + 2) / 3 * 4; // +2 due to integer math.

Просмотреть файл

@ -2552,7 +2552,7 @@ nsDownloadManager::ConfirmCancelDownloads(int32_t aCount,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//// nsDownload //// nsDownload
NS_IMPL_CLASSINFO(nsDownload, NULL, 0, NS_DOWNLOAD_CID) NS_IMPL_CLASSINFO(nsDownload, nullptr, 0, NS_DOWNLOAD_CID)
NS_IMPL_ISUPPORTS4_CI( NS_IMPL_ISUPPORTS4_CI(
nsDownload nsDownload
, nsIDownload , nsIDownload
@ -2590,8 +2590,8 @@ NS_IMETHODIMP nsDownload::SetSha256Hash(const nsACString& aHash) {
#ifdef MOZ_ENABLE_GIO #ifdef MOZ_ENABLE_GIO
static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpointer user_data) static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpointer user_data)
{ {
GError *err = NULL; GError *err = nullptr;
g_file_set_attributes_finish(G_FILE(source_obj), res, NULL, &err); g_file_set_attributes_finish(G_FILE(source_obj), res, nullptr, &err);
if (err) { if (err) {
#ifdef DEBUG #ifdef DEBUG
NS_DebugBreak(NS_DEBUG_WARNING, "Set file metadata failed: ", err->message, __FILE__, __LINE__); NS_DebugBreak(NS_DEBUG_WARNING, "Set file metadata failed: ", err->message, __FILE__, __LINE__);
@ -2733,7 +2733,7 @@ nsDownload::SetState(DownloadState aState)
GtkRecentManager* manager = gtk_recent_manager_get_default(); GtkRecentManager* manager = gtk_recent_manager_get_default();
gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(), gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(),
NULL, NULL); nullptr, nullptr);
if (uri) { if (uri) {
gtk_recent_manager_add_item(manager, uri); gtk_recent_manager_add_item(manager, uri);
g_free(uri); g_free(uri);
@ -2751,7 +2751,7 @@ nsDownload::SetState(DownloadState aState)
file_info, file_info,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT, G_PRIORITY_DEFAULT,
NULL, gio_set_metadata_done, NULL); nullptr, gio_set_metadata_done, nullptr);
g_object_unref(file_info); g_object_unref(file_info);
g_object_unref(gio_file); g_object_unref(gio_file);
#endif #endif
@ -2764,7 +2764,7 @@ nsDownload::SetState(DownloadState aState)
kCFStringEncodingUTF8); kCFStringEncodingUTF8);
CFNotificationCenterRef center = ::CFNotificationCenterGetDistributedCenter(); CFNotificationCenterRef center = ::CFNotificationCenterGetDistributedCenter();
::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"), ::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"),
observedObject, NULL, TRUE); observedObject, nullptr, TRUE);
::CFRelease(observedObject); ::CFRelease(observedObject);
#endif #endif
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID

Просмотреть файл

@ -161,7 +161,7 @@ nsDownloadScanner::Init()
// This CoInitialize/CoUninitialize pattern seems to be common in the Mozilla // This CoInitialize/CoUninitialize pattern seems to be common in the Mozilla
// codebase. All other COM calls/objects are made on different threads. // codebase. All other COM calls/objects are made on different threads.
nsresult rv = NS_OK; nsresult rv = NS_OK;
CoInitialize(NULL); CoInitialize(nullptr);
if (!IsAESAvailable()) { if (!IsAESAvailable()) {
CoUninitialize(); CoUninitialize();
@ -192,7 +192,7 @@ nsDownloadScanner::IsAESAvailable()
// Try to instantiate IAE to see if it's available. // Try to instantiate IAE to see if it's available.
nsRefPtr<IAttachmentExecute> ae; nsRefPtr<IAttachmentExecute> ae;
HRESULT hr; HRESULT hr;
hr = CoCreateInstance(CLSID_AttachmentServices, NULL, CLSCTX_INPROC, hr = CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_INPROC,
IID_IAttachmentExecute, getter_AddRefs(ae)); IID_IAttachmentExecute, getter_AddRefs(ae));
if (FAILED(hr)) { if (FAILED(hr)) {
NS_WARNING("Could not instantiate attachment execution service\n"); NS_WARNING("Could not instantiate attachment execution service\n");
@ -238,7 +238,7 @@ nsDownloadScanner::CheckPolicy(nsIURI *aSource, nsIURI *aTarget)
nsRefPtr<IAttachmentExecute> ae; nsRefPtr<IAttachmentExecute> ae;
HRESULT hr; HRESULT hr;
hr = CoCreateInstance(CLSID_AttachmentServices, NULL, CLSCTX_INPROC, hr = CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_INPROC,
IID_IAttachmentExecute, getter_AddRefs(ae)); IID_IAttachmentExecute, getter_AddRefs(ae));
if (FAILED(hr)) if (FAILED(hr))
return AVPOLICY_DOWNLOAD; return AVPOLICY_DOWNLOAD;
@ -305,7 +305,7 @@ nsresult ReleaseDispatcher::Run() {
} }
nsDownloadScanner::Scan::Scan(nsDownloadScanner *scanner, nsDownload *download) nsDownloadScanner::Scan::Scan(nsDownloadScanner *scanner, nsDownload *download)
: mDLScanner(scanner), mThread(NULL), : mDLScanner(scanner), mThread(nullptr),
mDownload(download), mStatus(AVSCAN_NOTSTARTED), mDownload(download), mStatus(AVSCAN_NOTSTARTED),
mSkipSource(false) mSkipSource(false)
{ {
@ -321,8 +321,8 @@ nsDownloadScanner::Scan::Start()
{ {
mStartTime = PR_Now(); mStartTime = PR_Now();
mThread = (HANDLE)_beginthreadex(NULL, 0, ScannerThreadFunction, mThread = (HANDLE)_beginthreadex(nullptr, 0, ScannerThreadFunction,
this, CREATE_SUSPENDED, NULL); this, CREATE_SUSPENDED, nullptr);
if (!mThread) if (!mThread)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -446,7 +446,7 @@ nsDownloadScanner::Scan::DoScanAES()
HRESULT hr; HRESULT hr;
nsRefPtr<IAttachmentExecute> ae; nsRefPtr<IAttachmentExecute> ae;
MOZ_SEH_TRY { MOZ_SEH_TRY {
hr = CoCreateInstance(CLSID_AttachmentServices, NULL, CLSCTX_ALL, hr = CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_ALL,
IID_IAttachmentExecute, getter_AddRefs(ae)); IID_IAttachmentExecute, getter_AddRefs(ae));
} MOZ_SEH_EXCEPT(ExceptionFilterFunction(GetExceptionCode())) { } MOZ_SEH_EXCEPT(ExceptionFilterFunction(GetExceptionCode())) {
return CheckAndSetState(AVSCAN_NOTSTARTED,AVSCAN_FAILED); return CheckAndSetState(AVSCAN_NOTSTARTED,AVSCAN_FAILED);
@ -471,7 +471,7 @@ nsDownloadScanner::Scan::DoScanAES()
} }
MOZ_SEH_TRY { MOZ_SEH_TRY {
ae = NULL; ae = nullptr;
} MOZ_SEH_EXCEPT(ExceptionFilterFunction(GetExceptionCode())) { } MOZ_SEH_EXCEPT(ExceptionFilterFunction(GetExceptionCode())) {
gotException = true; gotException = true;
} }
@ -506,7 +506,7 @@ nsDownloadScanner::Scan::DoScanAES()
void void
nsDownloadScanner::Scan::DoScan() nsDownloadScanner::Scan::DoScan()
{ {
CoInitialize(NULL); CoInitialize(nullptr);
if (DoScanAES()) { if (DoScanAES()) {
// We need to do a few more things on the main thread // We need to do a few more things on the main thread
@ -588,7 +588,7 @@ nsDownloadScanner::ScanDownload(nsDownload *download)
} }
nsDownloadScannerWatchdog::nsDownloadScannerWatchdog() nsDownloadScannerWatchdog::nsDownloadScannerWatchdog()
: mNewItemEvent(NULL), mQuitEvent(NULL) { : mNewItemEvent(nullptr), mQuitEvent(nullptr) {
InitializeCriticalSection(&mQueueSync); InitializeCriticalSection(&mQueueSync);
} }
nsDownloadScannerWatchdog::~nsDownloadScannerWatchdog() { nsDownloadScannerWatchdog::~nsDownloadScannerWatchdog() {
@ -598,10 +598,10 @@ nsDownloadScannerWatchdog::~nsDownloadScannerWatchdog() {
nsresult nsresult
nsDownloadScannerWatchdog::Init() { nsDownloadScannerWatchdog::Init() {
// Both events are auto-reset // Both events are auto-reset
mNewItemEvent = CreateEvent(NULL, FALSE, FALSE, NULL); mNewItemEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (INVALID_HANDLE_VALUE == mNewItemEvent) if (INVALID_HANDLE_VALUE == mNewItemEvent)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
mQuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); mQuitEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (INVALID_HANDLE_VALUE == mQuitEvent) { if (INVALID_HANDLE_VALUE == mQuitEvent) {
(void)CloseHandle(mNewItemEvent); (void)CloseHandle(mNewItemEvent);
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -609,8 +609,8 @@ nsDownloadScannerWatchdog::Init() {
// This thread is always running, however it will be asleep // This thread is always running, however it will be asleep
// for most of the dlmgr's lifetime // for most of the dlmgr's lifetime
mThread = (HANDLE)_beginthreadex(NULL, 0, WatchdogThread, mThread = (HANDLE)_beginthreadex(nullptr, 0, WatchdogThread,
this, 0, NULL); this, 0, nullptr);
if (!mThread) { if (!mThread) {
(void)CloseHandle(mNewItemEvent); (void)CloseHandle(mNewItemEvent);
(void)CloseHandle(mQuitEvent); (void)CloseHandle(mQuitEvent);
@ -667,7 +667,7 @@ nsDownloadScannerWatchdog::WatchdogThread(void *p) {
(waitStatus = (waitStatus =
WaitForMultipleObjects(2, waitHandles, FALSE, INFINITE)) && WaitForMultipleObjects(2, waitHandles, FALSE, INFINITE)) &&
waitStatus != WAIT_FAILED) { waitStatus != WAIT_FAILED) {
Scan *scan = NULL; Scan *scan = nullptr;
PRTime startTime, expectedEndTime, now; PRTime startTime, expectedEndTime, now;
DWORD waitTime; DWORD waitTime;

Просмотреть файл

@ -253,15 +253,15 @@ NS_DEFINE_NAMED_CID(NS_FILECOMPLETE_CID);
NS_DEFINE_NAMED_CID(NS_FILEVIEW_CID); NS_DEFINE_NAMED_CID(NS_FILEVIEW_CID);
static const mozilla::Module::CIDEntry kFileViewCIDs[] = { static const mozilla::Module::CIDEntry kFileViewCIDs[] = {
{ &kNS_FILECOMPLETE_CID, false, NULL, nsFileCompleteConstructor }, { &kNS_FILECOMPLETE_CID, false, nullptr, nsFileCompleteConstructor },
{ &kNS_FILEVIEW_CID, false, NULL, nsFileViewConstructor }, { &kNS_FILEVIEW_CID, false, nullptr, nsFileViewConstructor },
{ NULL } { nullptr }
}; };
static const mozilla::Module::ContractIDEntry kFileViewContracts[] = { static const mozilla::Module::ContractIDEntry kFileViewContracts[] = {
{ NS_FILECOMPLETE_CONTRACTID, &kNS_FILECOMPLETE_CID }, { NS_FILECOMPLETE_CONTRACTID, &kNS_FILECOMPLETE_CID },
{ NS_FILEVIEW_CONTRACTID, &kNS_FILEVIEW_CID }, { NS_FILEVIEW_CONTRACTID, &kNS_FILEVIEW_CID },
{ NULL } { nullptr }
}; };
static const mozilla::Module kFileViewModule = { static const mozilla::Module kFileViewModule = {

Просмотреть файл

@ -446,24 +446,24 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCharsetMenu)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
nsIRDFDataSource * nsCharsetMenu::mInner = NULL; nsIRDFDataSource * nsCharsetMenu::mInner = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserAutodetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserAutodetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserCharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserCharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMoreCharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMoreCharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore1CharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMore1CharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore2CharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMore2CharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore3CharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMore3CharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore4CharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMore4CharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BrowserMore5CharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_BrowserMore5CharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_MaileditCharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_MaileditCharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_MailviewCharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_MailviewCharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_ComposerCharsetMenuRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_ComposerCharsetMenuRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_DecodersRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_DecodersRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_EncodersRoot = NULL; nsIRDFResource * nsCharsetMenu::kNC_EncodersRoot = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_Name = NULL; nsIRDFResource * nsCharsetMenu::kNC_Name = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_CharsetDetector = NULL; nsIRDFResource * nsCharsetMenu::kNC_CharsetDetector = nullptr;
nsIRDFResource * nsCharsetMenu::kNC_BookmarkSeparator = NULL; nsIRDFResource * nsCharsetMenu::kNC_BookmarkSeparator = nullptr;
nsIRDFResource * nsCharsetMenu::kRDF_type = NULL; nsIRDFResource * nsCharsetMenu::kRDF_type = nullptr;
nsCharsetMenu::nsCharsetMenu() nsCharsetMenu::nsCharsetMenu()
: mInitialized(false), : mInitialized(false),
@ -629,7 +629,7 @@ nsresult nsCharsetMenu::RefreshMaileditMenu()
SetArrayFromEnumerator(encoders, encs); SetArrayFromEnumerator(encoders, encs);
// add menu items from pref // add menu items from pref
res = AddFromPrefsToMenu(NULL, container, kMaileditPrefKey, encs, NULL); res = AddFromPrefsToMenu(nullptr, container, kMaileditPrefKey, encs, nullptr);
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing mailedit charset menu from prefs"); NS_ASSERTION(NS_SUCCEEDED(res), "error initializing mailedit charset menu from prefs");
return res; return res;
@ -714,35 +714,35 @@ nsresult nsCharsetMenu::Init()
&kNC_BookmarkSeparator); &kNC_BookmarkSeparator);
mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_type), &kRDF_type); mRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_type), &kRDF_type);
nsIRDFContainerUtils * rdfUtil = NULL; nsIRDFContainerUtils * rdfUtil = nullptr;
res = CallGetService(kRDFContainerUtilsCID, &rdfUtil); res = CallGetService(kRDFContainerUtilsCID, &rdfUtil);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserAutodetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserAutodetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserCharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserCharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMoreCharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMoreCharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore1CharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore1CharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore2CharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore2CharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore3CharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore3CharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore4CharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore4CharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore5CharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_BrowserMore5CharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_MaileditCharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_MaileditCharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_MailviewCharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_MailviewCharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_ComposerCharsetMenuRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_ComposerCharsetMenuRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_DecodersRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_DecodersRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = rdfUtil->MakeSeq(mInner, kNC_EncodersRoot, NULL); res = rdfUtil->MakeSeq(mInner, kNC_EncodersRoot, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
done: done:
@ -793,9 +793,9 @@ nsresult nsCharsetMenu::FreeResources()
/* nsIObserverService has to have released nsCharsetMenu already */ /* nsIObserverService has to have released nsCharsetMenu already */
} }
mRDFService = NULL; mRDFService = nullptr;
mCCManager = NULL; mCCManager = nullptr;
mPrefs = NULL; mPrefs = nullptr;
return res; return res;
} }
@ -864,7 +864,8 @@ nsresult nsCharsetMenu::InitMaileditMenu()
nsTArray<nsCString> maileditEncoderList; nsTArray<nsCString> maileditEncoderList;
SetArrayFromEnumerator(encoders, maileditEncoderList); SetArrayFromEnumerator(encoders, maileditEncoderList);
res = AddFromPrefsToMenu(NULL, container, kMaileditPrefKey, maileditEncoderList, NULL); res = AddFromPrefsToMenu(nullptr, container, kMaileditPrefKey,
maileditEncoderList, nullptr);
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing mailedit charset menu from prefs"); NS_ASSERTION(NS_SUCCEEDED(res), "error initializing mailedit charset menu from prefs");
// register prefs callback // register prefs callback
@ -1098,7 +1099,7 @@ nsresult nsCharsetMenu::InitMoreMenu(nsTArray<nsCString>& aDecs,
res = ReorderMenuItemArray(&moreMenu); res = ReorderMenuItemArray(&moreMenu);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = AddMenuItemArrayToContainer(container, &moreMenu, NULL); res = AddMenuItemArrayToContainer(container, &moreMenu, nullptr);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
done: done:
@ -1127,27 +1128,27 @@ nsresult nsCharsetMenu::InitMoreSubmenus(nsTArray<nsCString>& aDecs)
res = NewRDFContainer(mInner, kNC_BrowserMore1CharsetMenuRoot, res = NewRDFContainer(mInner, kNC_BrowserMore1CharsetMenuRoot,
getter_AddRefs(container1)); getter_AddRefs(container1));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
AddFromNolocPrefsToMenu(NULL, container1, key1, aDecs, NULL); AddFromNolocPrefsToMenu(nullptr, container1, key1, aDecs, nullptr);
res = NewRDFContainer(mInner, kNC_BrowserMore2CharsetMenuRoot, res = NewRDFContainer(mInner, kNC_BrowserMore2CharsetMenuRoot,
getter_AddRefs(container2)); getter_AddRefs(container2));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
AddFromNolocPrefsToMenu(NULL, container2, key2, aDecs, NULL); AddFromNolocPrefsToMenu(nullptr, container2, key2, aDecs, nullptr);
res = NewRDFContainer(mInner, kNC_BrowserMore3CharsetMenuRoot, res = NewRDFContainer(mInner, kNC_BrowserMore3CharsetMenuRoot,
getter_AddRefs(container3)); getter_AddRefs(container3));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
AddFromNolocPrefsToMenu(NULL, container3, key3, aDecs, NULL); AddFromNolocPrefsToMenu(nullptr, container3, key3, aDecs, nullptr);
res = NewRDFContainer(mInner, kNC_BrowserMore4CharsetMenuRoot, res = NewRDFContainer(mInner, kNC_BrowserMore4CharsetMenuRoot,
getter_AddRefs(container4)); getter_AddRefs(container4));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
AddFromNolocPrefsToMenu(NULL, container4, key4, aDecs, NULL); AddFromNolocPrefsToMenu(nullptr, container4, key4, aDecs, nullptr);
res = NewRDFContainer(mInner, kNC_BrowserMore5CharsetMenuRoot, res = NewRDFContainer(mInner, kNC_BrowserMore5CharsetMenuRoot,
getter_AddRefs(container5)); getter_AddRefs(container5));
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
AddFromNolocPrefsToMenu(NULL, container5, key5, aDecs, NULL); AddFromNolocPrefsToMenu(nullptr, container5, key5, aDecs, nullptr);
return res; return res;
} }
@ -1158,12 +1159,12 @@ nsresult nsCharsetMenu::AddCharsetToItemArray(nsTArray<nsMenuEntry*> *aArray,
int32_t aPlace) int32_t aPlace)
{ {
nsresult res = NS_OK; nsresult res = NS_OK;
nsMenuEntry * item = NULL; nsMenuEntry * item = nullptr;
if (aResult != NULL) *aResult = NULL; if (aResult != nullptr) *aResult = nullptr;
item = new nsMenuEntry(); item = new nsMenuEntry();
if (item == NULL) { if (item == nullptr) {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
goto done; goto done;
} }
@ -1174,7 +1175,7 @@ nsresult nsCharsetMenu::AddCharsetToItemArray(nsTArray<nsMenuEntry*> *aArray,
item->mTitle.AssignWithConversion(aCharset.get()); item->mTitle.AssignWithConversion(aCharset.get());
} }
if (aArray != NULL) { if (aArray != nullptr) {
if (aPlace < 0) { if (aPlace < 0) {
aArray->AppendElement(item); aArray->AppendElement(item);
} else { } else {
@ -1182,13 +1183,13 @@ nsresult nsCharsetMenu::AddCharsetToItemArray(nsTArray<nsMenuEntry*> *aArray,
} }
} }
if (aResult != NULL) *aResult = item; if (aResult != nullptr) *aResult = item;
// if we have made another reference to "item", do not delete it // if we have made another reference to "item", do not delete it
if ((aArray != NULL) || (aResult != NULL)) item = NULL; if ((aArray != nullptr) || (aResult != nullptr)) item = nullptr;
done: done:
if (item != NULL) delete item; if (item != nullptr) delete item;
return res; return res;
} }
@ -1202,7 +1203,7 @@ nsCharsetMenu::AddCharsetArrayToItemArray(nsTArray<nsMenuEntry*>& aArray,
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
const nsCString& str = aCharsets[i]; const nsCString& str = aCharsets[i];
nsresult res = AddCharsetToItemArray(&aArray, str, NULL, -1); nsresult res = AddCharsetToItemArray(&aArray, str, nullptr, -1);
if (NS_FAILED(res)) if (NS_FAILED(res))
return res; return res;
@ -1224,7 +1225,7 @@ nsresult nsCharsetMenu::AddMenuItemToContainer(
nsCOMPtr<nsIRDFResource> node; nsCOMPtr<nsIRDFResource> node;
nsAutoCString id; nsAutoCString id;
if (aIDPrefix != NULL) id.Assign(aIDPrefix); if (aIDPrefix != nullptr) id.Assign(aIDPrefix);
id.Append(aItem->mCharset); id.Append(aItem->mCharset);
// Make up a unique ID and create the RDF NODE // Make up a unique ID and create the RDF NODE
@ -1246,7 +1247,7 @@ nsresult nsCharsetMenu::AddMenuItemToContainer(
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
if (aType != NULL) { if (aType != nullptr) {
if (aPlace < -1) { if (aPlace < -1) {
res = Unassert(node, kRDF_type, aType); res = Unassert(node, kRDF_type, aType);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
@ -1281,9 +1282,9 @@ nsresult nsCharsetMenu::AddMenuItemArrayToContainer(
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
nsMenuEntry * item = aArray->ElementAt(i); nsMenuEntry * item = aArray->ElementAt(i);
if (item == NULL) return NS_ERROR_UNEXPECTED; if (item == nullptr) return NS_ERROR_UNEXPECTED;
res = AddMenuItemToContainer(aContainer, item, aType, NULL, -1); res = AddMenuItemToContainer(aContainer, item, aType, nullptr, -1);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
@ -1298,20 +1299,20 @@ nsresult nsCharsetMenu::AddCharsetToContainer(nsTArray<nsMenuEntry*> *aArray,
int32_t aRDFPlace) int32_t aRDFPlace)
{ {
nsresult res = NS_OK; nsresult res = NS_OK;
nsMenuEntry * item = NULL; nsMenuEntry * item = nullptr;
res = AddCharsetToItemArray(aArray, aCharset, &item, aPlace); res = AddCharsetToItemArray(aArray, aCharset, &item, aPlace);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
res = AddMenuItemToContainer(aContainer, item, NULL, aIDPrefix, res = AddMenuItemToContainer(aContainer, item, nullptr, aIDPrefix,
aPlace + aRDFPlace); aPlace + aRDFPlace);
if (NS_FAILED(res)) goto done; if (NS_FAILED(res)) goto done;
// if we have made another reference to "item", do not delete it // if we have made another reference to "item", do not delete it
if (aArray != NULL) item = NULL; if (aArray != nullptr) item = nullptr;
done: done:
if (item != NULL) delete item; if (item != nullptr) delete item;
return res; return res;
} }
@ -1350,11 +1351,11 @@ nsCharsetMenu::AddFromNolocPrefsToMenu(nsTArray<nsMenuEntry*> * aArray,
{ {
nsresult res = NS_OK; nsresult res = NS_OK;
char * value = NULL; char * value = nullptr;
res = mPrefs->GetCharPref(aKey, &value); res = mPrefs->GetCharPref(aKey, &value);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
if (value != NULL) { if (value != nullptr) {
res = AddFromStringToMenu(value, aArray, aContainer, aDecs, aIDPrefix); res = AddFromStringToMenu(value, aArray, aContainer, aDecs, aIDPrefix);
nsMemory::Free(value); nsMemory::Free(value);
} }
@ -1414,7 +1415,7 @@ nsresult nsCharsetMenu::AddSeparatorToContainer(nsIRDFContainer * aContainer)
item.mTitle.AssignWithConversion(str.get()); item.mTitle.AssignWithConversion(str.get());
return AddMenuItemToContainer(aContainer, &item, kNC_BookmarkSeparator, return AddMenuItemToContainer(aContainer, &item, kNC_BookmarkSeparator,
NULL, -1); nullptr, -1);
} }
nsresult nsresult
@ -1428,7 +1429,7 @@ nsCharsetMenu::AddCharsetToCache(const nsAFlatCString& aCharset,
int32_t i; int32_t i;
nsresult res = NS_OK; nsresult res = NS_OK;
i = FindMenuItemInArray(aArray, aCharset, NULL); i = FindMenuItemInArray(aArray, aCharset, nullptr);
if (i >= 0) return res; if (i >= 0) return res;
nsCOMPtr<nsIRDFContainer> container; nsCOMPtr<nsIRDFContainer> container;
@ -1460,7 +1461,7 @@ nsresult nsCharsetMenu::WriteCacheToPrefs(nsTArray<nsMenuEntry*> * aArray,
for (uint32_t i = aCacheStart; i < count; i++) { for (uint32_t i = aCacheStart; i < count; i++) {
nsMenuEntry * item = aArray->ElementAt(i); nsMenuEntry * item = aArray->ElementAt(i);
if (item != NULL) { if (item != nullptr) {
cache.Append(item->mCharset); cache.Append(item->mCharset);
if (i < count - 1) { if (i < count - 1) {
cache.Append(sep); cache.Append(sep);
@ -1517,8 +1518,8 @@ nsresult nsCharsetMenu::ClearMenu(nsIRDFContainer * aContainer,
uint32_t count = aArray->Length(); uint32_t count = aArray->Length();
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
nsMenuEntry * item = aArray->ElementAt(i); nsMenuEntry * item = aArray->ElementAt(i);
if (item != NULL) { if (item != nullptr) {
res = AddMenuItemToContainer(aContainer, item, NULL, "charset.", -2); res = AddMenuItemToContainer(aContainer, item, nullptr, "charset.", -2);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
} }
@ -1537,8 +1538,8 @@ nsresult nsCharsetMenu::RemoveLastMenuItem(nsIRDFContainer * aContainer,
int32_t last = aArray->Length() - 1; int32_t last = aArray->Length() - 1;
if (last >= 0) { if (last >= 0) {
nsMenuEntry * item = aArray->ElementAt(last); nsMenuEntry * item = aArray->ElementAt(last);
if (item != NULL) { if (item != nullptr) {
res = AddMenuItemToContainer(aContainer, item, NULL, "charset.", -2); res = AddMenuItemToContainer(aContainer, item, nullptr, "charset.", -2);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
aArray->RemoveElementAt(last); aArray->RemoveElementAt(last);
@ -1590,7 +1591,7 @@ void nsCharsetMenu::FreeMenuItemArray(nsTArray<nsMenuEntry*> * aArray)
uint32_t count = aArray->Length(); uint32_t count = aArray->Length();
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
nsMenuEntry * item = aArray->ElementAt(i); nsMenuEntry * item = aArray->ElementAt(i);
if (item != NULL) { if (item != nullptr) {
delete item; delete item;
} }
} }
@ -1606,12 +1607,12 @@ int32_t nsCharsetMenu::FindMenuItemInArray(const nsTArray<nsMenuEntry*>* aArray,
for (uint32_t i=0; i < count; i++) { for (uint32_t i=0; i < count; i++) {
nsMenuEntry * item = aArray->ElementAt(i); nsMenuEntry * item = aArray->ElementAt(i);
if (item->mCharset == aCharset) { if (item->mCharset == aCharset) {
if (aResult != NULL) *aResult = item; if (aResult != nullptr) *aResult = item;
return i; return i;
} }
} }
if (aResult != NULL) *aResult = NULL; if (aResult != nullptr) *aResult = nullptr;
return -1; return -1;
} }

Просмотреть файл

@ -53,8 +53,8 @@ DownloadPlatform* DownloadPlatform::GetDownloadPlatform()
#ifdef MOZ_ENABLE_GIO #ifdef MOZ_ENABLE_GIO
static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpointer user_data) static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpointer user_data)
{ {
GError *err = NULL; GError *err = nullptr;
g_file_set_attributes_finish(G_FILE(source_obj), res, NULL, &err); g_file_set_attributes_finish(G_FILE(source_obj), res, nullptr, &err);
if (err) { if (err) {
#ifdef DEBUG #ifdef DEBUG
NS_DebugBreak(NS_DEBUG_WARNING, "Set file metadata failed: ", err->message, __FILE__, __LINE__); NS_DebugBreak(NS_DEBUG_WARNING, "Set file metadata failed: ", err->message, __FILE__, __LINE__);
@ -82,7 +82,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget,
GtkRecentManager* manager = gtk_recent_manager_get_default(); GtkRecentManager* manager = gtk_recent_manager_get_default();
gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(), gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(),
NULL, NULL); nullptr, nullptr);
if (uri) { if (uri) {
gtk_recent_manager_add_item(manager, uri); gtk_recent_manager_add_item(manager, uri);
g_free(uri); g_free(uri);
@ -100,7 +100,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget,
file_info, file_info,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT, G_PRIORITY_DEFAULT,
NULL, gio_set_metadata_done, NULL); nullptr, gio_set_metadata_done, nullptr);
g_object_unref(file_info); g_object_unref(file_info);
g_object_unref(gio_file); g_object_unref(gio_file);
#endif #endif
@ -113,7 +113,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget,
kCFStringEncodingUTF8); kCFStringEncodingUTF8);
CFNotificationCenterRef center = ::CFNotificationCenterGetDistributedCenter(); CFNotificationCenterRef center = ::CFNotificationCenterGetDistributedCenter();
::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"), ::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"),
observedObject, NULL, TRUE); observedObject, nullptr, TRUE);
::CFRelease(observedObject); ::CFRelease(observedObject);
#endif #endif
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID

Просмотреть файл

@ -28,10 +28,10 @@ DWORD
CheckCertificateForPEFile(LPCWSTR filePath, CheckCertificateForPEFile(LPCWSTR filePath,
CertificateCheckInfo &infoToMatch) CertificateCheckInfo &infoToMatch)
{ {
HCERTSTORE certStore = NULL; HCERTSTORE certStore = nullptr;
HCRYPTMSG cryptMsg = NULL; HCRYPTMSG cryptMsg = nullptr;
PCCERT_CONTEXT certContext = NULL; PCCERT_CONTEXT certContext = nullptr;
PCMSG_SIGNER_INFO signerInfo = NULL; PCMSG_SIGNER_INFO signerInfo = nullptr;
DWORD lastError = ERROR_SUCCESS; DWORD lastError = ERROR_SUCCESS;
// Get the HCERTSTORE and HCRYPTMSG from the signed file. // Get the HCERTSTORE and HCRYPTMSG from the signed file.
@ -41,17 +41,17 @@ CheckCertificateForPEFile(LPCWSTR filePath,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED, CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_CONTENT_FLAG_ALL,
0, &encoding, &contentType, 0, &encoding, &contentType,
&formatType, &certStore, &cryptMsg, NULL); &formatType, &certStore, &cryptMsg, nullptr);
if (!result) { if (!result) {
lastError = GetLastError(); lastError = GetLastError();
LOG_WARN(("CryptQueryObject failed. (%d)", lastError)); LOG_WARN(("CryptQueryObject failed. (%d)", lastError));
goto cleanup; goto cleanup;
} }
// Pass in NULL to get the needed signer information size. // Pass in nullptr to get the needed signer information size.
DWORD signerInfoSize; DWORD signerInfoSize;
result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0, result = CryptMsgGetParam(cryptMsg, CMSG_SIGNER_INFO_PARAM, 0,
NULL, &signerInfoSize); nullptr, &signerInfoSize);
if (!result) { if (!result) {
lastError = GetLastError(); lastError = GetLastError();
LOG_WARN(("CryptMsgGetParam failed. (%d)", lastError)); LOG_WARN(("CryptMsgGetParam failed. (%d)", lastError));
@ -82,7 +82,7 @@ CheckCertificateForPEFile(LPCWSTR filePath,
certInfo.SerialNumber = signerInfo->SerialNumber; certInfo.SerialNumber = signerInfo->SerialNumber;
certContext = CertFindCertificateInStore(certStore, ENCODING, 0, certContext = CertFindCertificateInStore(certStore, ENCODING, 0,
CERT_FIND_SUBJECT_CERT, CERT_FIND_SUBJECT_CERT,
(PVOID)&certInfo, NULL); (PVOID)&certInfo, nullptr);
if (!certContext) { if (!certContext) {
lastError = GetLastError(); lastError = GetLastError();
LOG_WARN(("CertFindCertificateInStore failed. (%d)", lastError)); LOG_WARN(("CertFindCertificateInStore failed. (%d)", lastError));
@ -123,14 +123,14 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
CertificateCheckInfo &infoToMatch) CertificateCheckInfo &infoToMatch)
{ {
DWORD dwData; DWORD dwData;
LPTSTR szName = NULL; LPTSTR szName = nullptr;
if (infoToMatch.issuer) { if (infoToMatch.issuer) {
// Pass in NULL to get the needed size of the issuer buffer. // Pass in nullptr to get the needed size of the issuer buffer.
dwData = CertGetNameString(certContext, dwData = CertGetNameString(certContext,
CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_SIMPLE_DISPLAY_TYPE,
CERT_NAME_ISSUER_FLAG, NULL, CERT_NAME_ISSUER_FLAG, nullptr,
NULL, 0); nullptr, 0);
if (!dwData) { if (!dwData) {
LOG_WARN(("CertGetNameString failed. (%d)", GetLastError())); LOG_WARN(("CertGetNameString failed. (%d)", GetLastError()));
@ -147,7 +147,7 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
// Get Issuer name. // Get Issuer name.
if (!CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, if (!CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE,
CERT_NAME_ISSUER_FLAG, NULL, szName, dwData)) { CERT_NAME_ISSUER_FLAG, nullptr, szName, dwData)) {
LOG_WARN(("CertGetNameString failed. (%d)", GetLastError())); LOG_WARN(("CertGetNameString failed. (%d)", GetLastError()));
LocalFree(szName); LocalFree(szName);
return FALSE; return FALSE;
@ -161,13 +161,13 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
} }
LocalFree(szName); LocalFree(szName);
szName = NULL; szName = nullptr;
} }
if (infoToMatch.name) { if (infoToMatch.name) {
// Pass in NULL to get the needed size of the name buffer. // Pass in nullptr to get the needed size of the name buffer.
dwData = CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, dwData = CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE,
0, NULL, NULL, 0); 0, nullptr, nullptr, 0);
if (!dwData) { if (!dwData) {
LOG_WARN(("CertGetNameString failed. (%d)", GetLastError())); LOG_WARN(("CertGetNameString failed. (%d)", GetLastError()));
return FALSE; return FALSE;
@ -183,7 +183,7 @@ DoCertificateAttributesMatch(PCCERT_CONTEXT certContext,
// Obtain the name. // Obtain the name.
if (!(CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, if (!(CertGetNameString(certContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
NULL, szName, dwData))) { nullptr, szName, dwData))) {
LOG_WARN(("CertGetNameString failed. (%d)", GetLastError())); LOG_WARN(("CertGetNameString failed. (%d)", GetLastError()));
LocalFree(szName); LocalFree(szName);
return FALSE; return FALSE;
@ -240,21 +240,21 @@ VerifyCertificateTrustForFile(LPCWSTR filePath)
WINTRUST_DATA trustData; WINTRUST_DATA trustData;
ZeroMemory(&trustData, sizeof(trustData)); ZeroMemory(&trustData, sizeof(trustData));
trustData.cbStruct = sizeof(trustData); trustData.cbStruct = sizeof(trustData);
trustData.pPolicyCallbackData = NULL; trustData.pPolicyCallbackData = nullptr;
trustData.pSIPClientData = NULL; trustData.pSIPClientData = nullptr;
trustData.dwUIChoice = WTD_UI_NONE; trustData.dwUIChoice = WTD_UI_NONE;
trustData.fdwRevocationChecks = WTD_REVOKE_NONE; trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
trustData.dwUnionChoice = WTD_CHOICE_FILE; trustData.dwUnionChoice = WTD_CHOICE_FILE;
trustData.dwStateAction = 0; trustData.dwStateAction = 0;
trustData.hWVTStateData = NULL; trustData.hWVTStateData = nullptr;
trustData.pwszURLReference = NULL; trustData.pwszURLReference = nullptr;
// no UI // no UI
trustData.dwUIContext = 0; trustData.dwUIContext = 0;
trustData.pFile = &fileToCheck; trustData.pFile = &fileToCheck;
GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
// Check if the file is signed by something that is trusted. // Check if the file is signed by something that is trusted.
LONG ret = WinVerifyTrust(NULL, &policyGUID, &trustData); LONG ret = WinVerifyTrust(nullptr, &policyGUID, &trustData);
if (ERROR_SUCCESS == ret) { if (ERROR_SUCCESS == ret) {
// The hash that represents the subject is trusted and there were no // The hash that represents the subject is trusted and there were no
// verification errors. No publisher nor time stamp chain errors. // verification errors. No publisher nor time stamp chain errors.

Просмотреть файл

@ -16,9 +16,9 @@
#include "updatehelper.h" #include "updatehelper.h"
SERVICE_STATUS gSvcStatus = { 0 }; SERVICE_STATUS gSvcStatus = { 0 };
SERVICE_STATUS_HANDLE gSvcStatusHandle = NULL; SERVICE_STATUS_HANDLE gSvcStatusHandle = nullptr;
HANDLE gWorkDoneEvent = NULL; HANDLE gWorkDoneEvent = nullptr;
HANDLE gThread = NULL; HANDLE gThread = nullptr;
bool gServiceControlStopping = false; bool gServiceControlStopping = false;
// logs are pretty small, about 20 lines, so 10 seems reasonable. // logs are pretty small, about 20 lines, so 10 seems reasonable.
@ -100,7 +100,7 @@ wmain(int argc, WCHAR **argv)
SERVICE_TABLE_ENTRYW DispatchTable[] = { SERVICE_TABLE_ENTRYW DispatchTable[] = {
{ SVC_NAME, (LPSERVICE_MAIN_FUNCTIONW) SvcMain }, { SVC_NAME, (LPSERVICE_MAIN_FUNCTIONW) SvcMain },
{ NULL, NULL } { nullptr, nullptr }
}; };
// This call returns when the service has stopped. // This call returns when the service has stopped.
@ -121,7 +121,7 @@ wmain(int argc, WCHAR **argv)
BOOL BOOL
GetLogDirectoryPath(WCHAR *path) GetLogDirectoryPath(WCHAR *path)
{ {
HRESULT hr = SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, HRESULT hr = SHGetFolderPathW(nullptr, CSIDL_COMMON_APPDATA, nullptr,
SHGFP_TYPE_CURRENT, path); SHGFP_TYPE_CURRENT, path);
if (FAILED(hr)) { if (FAILED(hr)) {
return FALSE; return FALSE;
@ -132,12 +132,12 @@ GetLogDirectoryPath(WCHAR *path)
} }
// The directory should already be created from the installer, but // The directory should already be created from the installer, but
// just to be safe in case someone deletes. // just to be safe in case someone deletes.
CreateDirectoryW(path, NULL); CreateDirectoryW(path, nullptr);
if (!PathAppendSafe(path, L"logs")) { if (!PathAppendSafe(path, L"logs")) {
return FALSE; return FALSE;
} }
CreateDirectoryW(path, NULL); CreateDirectoryW(path, nullptr);
return TRUE; return TRUE;
} }
@ -222,8 +222,8 @@ StartTerminationThread()
{ {
// If the process does not self terminate like it should, this thread // If the process does not self terminate like it should, this thread
// will terminate the process after 5 seconds. // will terminate the process after 5 seconds.
HANDLE thread = CreateThread(NULL, 0, EnsureProcessTerminatedThread, HANDLE thread = CreateThread(nullptr, 0, EnsureProcessTerminatedThread,
NULL, 0, NULL); nullptr, 0, nullptr);
if (thread) { if (thread) {
CloseHandle(thread); CloseHandle(thread);
} }
@ -244,7 +244,7 @@ SvcMain(DWORD argc, LPWSTR *argv)
// Disable every privilege we don't need. Processes started using // Disable every privilege we don't need. Processes started using
// CreateProcess will use the same token as this process. // CreateProcess will use the same token as this process.
UACHelper::DisablePrivileges(NULL); UACHelper::DisablePrivileges(nullptr);
// Register the handler function for the service // Register the handler function for the service
gSvcStatusHandle = RegisterServiceCtrlHandlerW(SVC_NAME, SvcCtrlHandler); gSvcStatusHandle = RegisterServiceCtrlHandlerW(SVC_NAME, SvcCtrlHandler);
@ -264,7 +264,7 @@ SvcMain(DWORD argc, LPWSTR *argv)
// This event will be used to tell the SvcCtrlHandler when the work is // This event will be used to tell the SvcCtrlHandler when the work is
// done for when a stop comamnd is manually issued. // done for when a stop comamnd is manually issued.
gWorkDoneEvent = CreateEvent(NULL, TRUE, FALSE, NULL); gWorkDoneEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!gWorkDoneEvent) { if (!gWorkDoneEvent) {
ReportSvcStatus(SERVICE_STOPPED, 1, 0); ReportSvcStatus(SERVICE_STOPPED, 1, 0);
StartTerminationThread(); StartTerminationThread();
@ -340,7 +340,7 @@ StopServiceAndWaitForCommandThread(LPVOID)
ReportSvcStatus(SERVICE_STOP_PENDING, NO_ERROR, 1000); ReportSvcStatus(SERVICE_STOP_PENDING, NO_ERROR, 1000);
} while(WaitForSingleObject(gWorkDoneEvent, 100) == WAIT_TIMEOUT); } while(WaitForSingleObject(gWorkDoneEvent, 100) == WAIT_TIMEOUT);
CloseHandle(gWorkDoneEvent); CloseHandle(gWorkDoneEvent);
gWorkDoneEvent = NULL; gWorkDoneEvent = nullptr;
ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0); ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0);
StartTerminationThread(); StartTerminationThread();
return 0; return 0;
@ -368,15 +368,16 @@ SvcCtrlHandler(DWORD dwCtrl)
// The SvcCtrlHandler thread should not spend more than 30 seconds in // The SvcCtrlHandler thread should not spend more than 30 seconds in
// shutdown so we spawn a new thread for stopping the service // shutdown so we spawn a new thread for stopping the service
HANDLE thread = CreateThread(NULL, 0, StopServiceAndWaitForCommandThread, HANDLE thread = CreateThread(nullptr, 0,
NULL, 0, NULL); StopServiceAndWaitForCommandThread,
nullptr, 0, nullptr);
if (thread) { if (thread) {
CloseHandle(thread); CloseHandle(thread);
} else { } else {
// Couldn't start the thread so just call the stop ourselves. // Couldn't start the thread so just call the stop ourselves.
// If it happens to take longer than 30 seconds the caller will // If it happens to take longer than 30 seconds the caller will
// get an error. // get an error.
StopServiceAndWaitForCommandThread(NULL); StopServiceAndWaitForCommandThread(nullptr);
} }
} }
break; break;

Просмотреть файл

@ -55,8 +55,9 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
// Get the number of subkeys. // Get the number of subkeys.
DWORD subkeyCount = 0; DWORD subkeyCount = 0;
retCode = RegQueryInfoKeyW(baseKey, NULL, NULL, NULL, &subkeyCount, NULL, retCode = RegQueryInfoKeyW(baseKey, nullptr, nullptr, nullptr, &subkeyCount,
NULL, NULL, NULL, NULL, NULL, NULL); nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr);
if (retCode != ERROR_SUCCESS) { if (retCode != ERROR_SUCCESS) {
LOG_WARN(("Could not query info key. (%d)", retCode)); LOG_WARN(("Could not query info key. (%d)", retCode));
return FALSE; return FALSE;
@ -67,8 +68,8 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
WCHAR subkeyBuffer[MAX_KEY_LENGTH]; WCHAR subkeyBuffer[MAX_KEY_LENGTH];
DWORD subkeyBufferCount = MAX_KEY_LENGTH; DWORD subkeyBufferCount = MAX_KEY_LENGTH;
retCode = RegEnumKeyExW(baseKey, i, subkeyBuffer, retCode = RegEnumKeyExW(baseKey, i, subkeyBuffer,
&subkeyBufferCount, NULL, &subkeyBufferCount, nullptr,
NULL, NULL, NULL); nullptr, nullptr, nullptr);
if (retCode != ERROR_SUCCESS) { if (retCode != ERROR_SUCCESS) {
LOG_WARN(("Could not enum certs. (%d)", retCode)); LOG_WARN(("Could not enum certs. (%d)", retCode));
return FALSE; return FALSE;
@ -93,7 +94,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
WCHAR issuer[MAX_CHAR_COUNT] = { L'\0' }; WCHAR issuer[MAX_CHAR_COUNT] = { L'\0' };
// Get the name from the registry // Get the name from the registry
retCode = RegQueryValueExW(subKey, L"name", 0, NULL, retCode = RegQueryValueExW(subKey, L"name", 0, nullptr,
(LPBYTE)name, &valueBufSize); (LPBYTE)name, &valueBufSize);
if (retCode != ERROR_SUCCESS) { if (retCode != ERROR_SUCCESS) {
LOG_WARN(("Could not obtain name from registry. (%d)", retCode)); LOG_WARN(("Could not obtain name from registry. (%d)", retCode));
@ -102,7 +103,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
// Get the issuer from the registry // Get the issuer from the registry
valueBufSize = MAX_CHAR_COUNT * sizeof(WCHAR); valueBufSize = MAX_CHAR_COUNT * sizeof(WCHAR);
retCode = RegQueryValueExW(subKey, L"issuer", 0, NULL, retCode = RegQueryValueExW(subKey, L"issuer", 0, nullptr,
(LPBYTE)issuer, &valueBufSize); (LPBYTE)issuer, &valueBufSize);
if (retCode != ERROR_SUCCESS) { if (retCode != ERROR_SUCCESS) {
LOG_WARN(("Could not obtain issuer from registry. (%d)", retCode)); LOG_WARN(("Could not obtain issuer from registry. (%d)", retCode));

Просмотреть файл

@ -21,18 +21,18 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
{ {
sameContent = FALSE; sameContent = FALSE;
nsAutoHandle file1(CreateFileW(file1Path, GENERIC_READ, FILE_SHARE_READ, nsAutoHandle file1(CreateFileW(file1Path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL)); nullptr, OPEN_EXISTING, 0, nullptr));
if (INVALID_HANDLE_VALUE == file1) { if (INVALID_HANDLE_VALUE == file1) {
return FALSE; return FALSE;
} }
nsAutoHandle file2(CreateFileW(file2Path, GENERIC_READ, FILE_SHARE_READ, nsAutoHandle file2(CreateFileW(file2Path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL)); nullptr, OPEN_EXISTING, 0, nullptr));
if (INVALID_HANDLE_VALUE == file2) { if (INVALID_HANDLE_VALUE == file2) {
return FALSE; return FALSE;
} }
DWORD fileSize1 = GetFileSize(file1, NULL); DWORD fileSize1 = GetFileSize(file1, nullptr);
DWORD fileSize2 = GetFileSize(file2, NULL); DWORD fileSize2 = GetFileSize(file2, nullptr);
if (INVALID_FILE_SIZE == fileSize1 || INVALID_FILE_SIZE == fileSize2) { if (INVALID_FILE_SIZE == fileSize1 || INVALID_FILE_SIZE == fileSize2) {
return FALSE; return FALSE;
} }
@ -48,12 +48,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
DWORD leftOver = fileSize1 % COMPARE_BLOCKSIZE; DWORD leftOver = fileSize1 % COMPARE_BLOCKSIZE;
DWORD readAmount; DWORD readAmount;
for (DWORD i = 0; i < numBlocks; i++) { for (DWORD i = 0; i < numBlocks; i++) {
if (!ReadFile(file1, buf1, COMPARE_BLOCKSIZE, &readAmount, NULL) || if (!ReadFile(file1, buf1, COMPARE_BLOCKSIZE, &readAmount, nullptr) ||
readAmount != COMPARE_BLOCKSIZE) { readAmount != COMPARE_BLOCKSIZE) {
return FALSE; return FALSE;
} }
if (!ReadFile(file2, buf2, COMPARE_BLOCKSIZE, &readAmount, NULL) || if (!ReadFile(file2, buf2, COMPARE_BLOCKSIZE, &readAmount, nullptr) ||
readAmount != COMPARE_BLOCKSIZE) { readAmount != COMPARE_BLOCKSIZE) {
return FALSE; return FALSE;
} }
@ -65,12 +65,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
} }
if (leftOver) { if (leftOver) {
if (!ReadFile(file1, buf1, leftOver, &readAmount, NULL) || if (!ReadFile(file1, buf1, leftOver, &readAmount, nullptr) ||
readAmount != leftOver) { readAmount != leftOver) {
return FALSE; return FALSE;
} }
if (!ReadFile(file2, buf2, leftOver, &readAmount, NULL) || if (!ReadFile(file2, buf2, leftOver, &readAmount, nullptr) ||
readAmount != leftOver) { readAmount != leftOver) {
return FALSE; return FALSE;
} }

Просмотреть файл

@ -101,7 +101,7 @@ BOOL
UpdateServiceDescription(SC_HANDLE serviceHandle) UpdateServiceDescription(SC_HANDLE serviceHandle)
{ {
WCHAR updaterINIPath[MAX_PATH + 1]; WCHAR updaterINIPath[MAX_PATH + 1];
if (!GetModuleFileNameW(NULL, updaterINIPath, if (!GetModuleFileNameW(nullptr, updaterINIPath,
sizeof(updaterINIPath) / sizeof(updaterINIPath) /
sizeof(updaterINIPath[0]))) { sizeof(updaterINIPath[0]))) {
LOG_WARN(("Could not obtain module filename when attempting to " LOG_WARN(("Could not obtain module filename when attempting to "
@ -213,8 +213,8 @@ FixServicePath(SC_HANDLE service,
if (!ChangeServiceConfigW(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, if (!ChangeServiceConfigW(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE, fixedPath, NULL, NULL, NULL, SERVICE_NO_CHANGE, fixedPath, nullptr, nullptr,
NULL, NULL, NULL)) { nullptr, nullptr, nullptr, nullptr)) {
LOG_WARN(("Could not fix service path. (%d)", GetLastError())); LOG_WARN(("Could not fix service path. (%d)", GetLastError()));
return FALSE; return FALSE;
} }
@ -235,7 +235,7 @@ BOOL
SvcInstall(SvcInstallAction action) SvcInstall(SvcInstallAction action)
{ {
// Get a handle to the local computer SCM database with full access rights. // Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle schSCManager(OpenSCManager(NULL, NULL, nsAutoServiceHandle schSCManager(OpenSCManager(nullptr, nullptr,
SC_MANAGER_ALL_ACCESS)); SC_MANAGER_ALL_ACCESS));
if (!schSCManager) { if (!schSCManager) {
LOG_WARN(("Could not open service manager. (%d)", GetLastError())); LOG_WARN(("Could not open service manager. (%d)", GetLastError()));
@ -243,7 +243,7 @@ SvcInstall(SvcInstallAction action)
} }
WCHAR newServiceBinaryPath[MAX_PATH + 1]; WCHAR newServiceBinaryPath[MAX_PATH + 1];
if (!GetModuleFileNameW(NULL, newServiceBinaryPath, if (!GetModuleFileNameW(nullptr, newServiceBinaryPath,
sizeof(newServiceBinaryPath) / sizeof(newServiceBinaryPath) /
sizeof(newServiceBinaryPath[0]))) { sizeof(newServiceBinaryPath[0]))) {
LOG_WARN(("Could not obtain module filename when attempting to " LOG_WARN(("Could not obtain module filename when attempting to "
@ -276,7 +276,7 @@ SvcInstall(SvcInstallAction action)
// The service exists and we opened it // The service exists and we opened it
DWORD bytesNeeded; DWORD bytesNeeded;
if (!QueryServiceConfigW(schService, NULL, 0, &bytesNeeded) && if (!QueryServiceConfigW(schService, nullptr, 0, &bytesNeeded) &&
GetLastError() != ERROR_INSUFFICIENT_BUFFER) { GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
LOG_WARN(("Could not determine buffer size for query service config. (%d)", LOG_WARN(("Could not determine buffer size for query service config. (%d)",
GetLastError())); GetLastError()));
@ -439,7 +439,8 @@ SvcInstall(SvcInstallAction action)
// We made a copy of ourselves to the existing location. // We made a copy of ourselves to the existing location.
// The tmp file (the process of which we are executing right now) will be // The tmp file (the process of which we are executing right now) will be
// left over. Attempt to delete the file on the next reboot. // left over. Attempt to delete the file on the next reboot.
if (MoveFileExW(newServiceBinaryPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { if (MoveFileExW(newServiceBinaryPath, nullptr,
MOVEFILE_DELAY_UNTIL_REBOOT)) {
LOG(("Deleting the old file path on the next reboot: %ls.", LOG(("Deleting the old file path on the next reboot: %ls.",
newServiceBinaryPath)); newServiceBinaryPath));
} else { } else {
@ -453,7 +454,7 @@ SvcInstall(SvcInstallAction action)
// We don't need to copy ourselves to the existing location. // We don't need to copy ourselves to the existing location.
// The tmp file (the process of which we are executing right now) will be // The tmp file (the process of which we are executing right now) will be
// left over. Attempt to delete the file on the next reboot. // left over. Attempt to delete the file on the next reboot.
MoveFileExW(newServiceBinaryPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); MoveFileExW(newServiceBinaryPath, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT);
// nothing to do, we already have a newer service installed // nothing to do, we already have a newer service installed
return TRUE; return TRUE;
@ -471,8 +472,8 @@ SvcInstall(SvcInstallAction action)
schService.own(CreateServiceW(schSCManager, SVC_NAME, SVC_DISPLAY_NAME, schService.own(CreateServiceW(schSCManager, SVC_NAME, SVC_DISPLAY_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
newServiceBinaryPath, NULL, NULL, NULL, newServiceBinaryPath, nullptr, nullptr,
NULL, NULL)); nullptr, nullptr, nullptr));
if (!schService) { if (!schService) {
LOG_WARN(("Could not create Windows service. " LOG_WARN(("Could not create Windows service. "
"This error should never happen since a service install " "This error should never happen since a service install "
@ -501,7 +502,7 @@ BOOL
StopService() StopService()
{ {
// Get a handle to the local computer SCM database with full access rights. // Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle schSCManager(OpenSCManager(NULL, NULL, nsAutoServiceHandle schSCManager(OpenSCManager(nullptr, nullptr,
SC_MANAGER_ALL_ACCESS)); SC_MANAGER_ALL_ACCESS));
if (!schSCManager) { if (!schSCManager) {
LOG_WARN(("Could not open service manager. (%d)", GetLastError())); LOG_WARN(("Could not open service manager. (%d)", GetLastError()));
@ -547,7 +548,7 @@ BOOL
SvcUninstall() SvcUninstall()
{ {
// Get a handle to the local computer SCM database with full access rights. // Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle schSCManager(OpenSCManager(NULL, NULL, nsAutoServiceHandle schSCManager(OpenSCManager(nullptr, nullptr,
SC_MANAGER_ALL_ACCESS)); SC_MANAGER_ALL_ACCESS));
if (!schSCManager) { if (!schSCManager) {
LOG_WARN(("Could not open service manager. (%d)", GetLastError())); LOG_WARN(("Could not open service manager. (%d)", GetLastError()));
@ -597,8 +598,8 @@ SvcUninstall()
BOOL BOOL
SetUserAccessServiceDACL(SC_HANDLE hService) SetUserAccessServiceDACL(SC_HANDLE hService)
{ {
PACL pNewAcl = NULL; PACL pNewAcl = nullptr;
PSECURITY_DESCRIPTOR psd = NULL; PSECURITY_DESCRIPTOR psd = nullptr;
DWORD lastError = SetUserAccessServiceDACL(hService, pNewAcl, psd); DWORD lastError = SetUserAccessServiceDACL(hService, pNewAcl, psd);
if (pNewAcl) { if (pNewAcl) {
LocalFree((HLOCAL)pNewAcl); LocalFree((HLOCAL)pNewAcl);
@ -649,7 +650,7 @@ SetUserAccessServiceDACL(SC_HANDLE hService, PACL &pNewAcl,
} }
// Get the current DACL from the security descriptor. // Get the current DACL from the security descriptor.
PACL pacl = NULL; PACL pacl = nullptr;
BOOL bDaclPresent = FALSE; BOOL bDaclPresent = FALSE;
BOOL bDaclDefaulted = FALSE; BOOL bDaclDefaulted = FALSE;
if ( !GetSecurityDescriptorDacl(psd, &bDaclPresent, &pacl, if ( !GetSecurityDescriptorDacl(psd, &bDaclPresent, &pacl,
@ -666,7 +667,7 @@ SetUserAccessServiceDACL(SC_HANDLE hService, PACL &pNewAcl,
return GetLastError(); return GetLastError();
} }
if (!CreateWellKnownSid(WinBuiltinUsersSid, NULL, sid, &SIDSize)) { if (!CreateWellKnownSid(WinBuiltinUsersSid, nullptr, sid, &SIDSize)) {
DWORD lastError = GetLastError(); DWORD lastError = GetLastError();
LOG_WARN(("Could not create well known SID. (%d)", lastError)); LOG_WARN(("Could not create well known SID. (%d)", lastError));
LocalFree(sid); LocalFree(sid);
@ -681,7 +682,7 @@ SetUserAccessServiceDACL(SC_HANDLE hService, PACL &pNewAcl,
WCHAR domainName[DNLEN + 1] = { L'\0' }; WCHAR domainName[DNLEN + 1] = { L'\0' };
DWORD accountNameSize = UNLEN + 1; DWORD accountNameSize = UNLEN + 1;
DWORD domainNameSize = DNLEN + 1; DWORD domainNameSize = DNLEN + 1;
if (!LookupAccountSidW(NULL, sid, accountName, if (!LookupAccountSidW(nullptr, sid, accountName,
&accountNameSize, &accountNameSize,
domainName, &domainNameSize, &accountType)) { domainName, &domainNameSize, &accountType)) {
LOG_WARN(("Could not lookup account Sid, will try Users. (%d)", LOG_WARN(("Could not lookup account Sid, will try Users. (%d)",
@ -691,7 +692,7 @@ SetUserAccessServiceDACL(SC_HANDLE hService, PACL &pNewAcl,
// We already have the group name so we can get rid of the SID // We already have the group name so we can get rid of the SID
FreeSid(sid); FreeSid(sid);
sid = NULL; sid = nullptr;
// Build the ACE, BuildExplicitAccessWithName cannot fail so it is not logged. // Build the ACE, BuildExplicitAccessWithName cannot fail so it is not logged.
EXPLICIT_ACCESS ea; EXPLICIT_ACCESS ea;