From b08627f310bb2e80bca50176e7a758182384735a Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Fri, 4 May 2018 19:23:10 +0900 Subject: [PATCH] Fix catching polymorphic type by value Replace catching polymorphic type std::bad_alloc 'by value' with 'by reference'. Pointed by gcc8 --- src/add-ons/disk_systems/bfs/BFSAddOn.cpp | 2 +- src/add-ons/disk_systems/fat/FATAddOn.cpp | 2 +- src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp | 2 +- src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp | 2 +- src/add-ons/disk_systems/ntfs/NTFSAddOn.cpp | 2 +- src/apps/activitymonitor/ActivityView.cpp | 2 +- src/apps/debugger/settings/DebuggerSettingsManager.cpp | 4 ++-- src/apps/installer/BlockingQueue.h | 2 +- src/bin/debug/profile/profile.cpp | 2 +- src/kits/debugger/arch/x86/ArchitectureX86.cpp | 2 +- src/kits/debugger/arch/x86_64/ArchitectureX8664.cpp | 2 +- src/kits/game/WindowScreen.cpp | 2 +- src/kits/package/hpkg/PackageWriterImpl.cpp | 10 +++++----- src/kits/package/hpkg/RepositoryWriterImpl.cpp | 8 ++++---- src/kits/storage/mime/InstalledTypes.cpp | 6 +++--- src/kits/storage/mime/Supertype.cpp | 2 +- src/kits/storage/storage_support.cpp | 2 +- src/servers/app/ServerPicture.cpp | 10 +++++----- 18 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp index 8fd7d64b3b..7267795538 100644 --- a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp +++ b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp @@ -179,7 +179,7 @@ BFSAddOn::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, if (type == B_INITIALIZE_PARAMETER_EDITOR) { try { *editor = new InitializeBFSEditor(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } return B_OK; diff --git a/src/add-ons/disk_systems/fat/FATAddOn.cpp b/src/add-ons/disk_systems/fat/FATAddOn.cpp index 2110799455..2e64b67adf 100644 --- a/src/add-ons/disk_systems/fat/FATAddOn.cpp +++ b/src/add-ons/disk_systems/fat/FATAddOn.cpp @@ -132,7 +132,7 @@ FATAddOn::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, if (type == B_INITIALIZE_PARAMETER_EDITOR) { try { *editor = new InitializeFATEditor(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } return B_OK; diff --git a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp index 4c6ca66928..a25ddc3a56 100644 --- a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp +++ b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp @@ -155,7 +155,7 @@ GPTPartitionHandle::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, if (type == B_CREATE_PARAMETER_EDITOR) { try { *editor = new BPartitionParameterEditor(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } return B_OK; diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp index d9c1450048..f75ee09d02 100644 --- a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp +++ b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp @@ -302,7 +302,7 @@ PartitionMapHandle::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, || type == B_PROPERTIES_PARAMETER_EDITOR) { try { *editor = new PrimaryPartitionEditor(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } return B_OK; diff --git a/src/add-ons/disk_systems/ntfs/NTFSAddOn.cpp b/src/add-ons/disk_systems/ntfs/NTFSAddOn.cpp index cde20e614e..3c3901dcb3 100644 --- a/src/add-ons/disk_systems/ntfs/NTFSAddOn.cpp +++ b/src/add-ons/disk_systems/ntfs/NTFSAddOn.cpp @@ -133,7 +133,7 @@ NTFSAddOn::GetParameterEditor(B_PARAMETER_EDITOR_TYPE type, if (type == B_INITIALIZE_PARAMETER_EDITOR) { try { *editor = new InitializeNTFSEditor(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } return B_OK; diff --git a/src/apps/activitymonitor/ActivityView.cpp b/src/apps/activitymonitor/ActivityView.cpp index e744a96453..4c22486741 100644 --- a/src/apps/activitymonitor/ActivityView.cpp +++ b/src/apps/activitymonitor/ActivityView.cpp @@ -1423,7 +1423,7 @@ ActivityView::_DrawHistory(bool drawBackground) prev.Set(x, y); } - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { // Not enough memory to allocate the line array. // TODO we could try to draw using the slower but less memory // consuming solution using StrokeLine. diff --git a/src/apps/debugger/settings/DebuggerSettingsManager.cpp b/src/apps/debugger/settings/DebuggerSettingsManager.cpp index 00aa08a4d0..eed7021e88 100644 --- a/src/apps/debugger/settings/DebuggerSettingsManager.cpp +++ b/src/apps/debugger/settings/DebuggerSettingsManager.cpp @@ -78,7 +78,7 @@ DebuggerSettingsManager::LoadTeamSettings(const char* teamName, TeamSettings& se try { settings = *fRecentTeamSettings.ItemAt(index); return B_OK; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } } @@ -112,7 +112,7 @@ DebuggerSettingsManager::SaveTeamSettings(const TeamSettings& _settings) settingsDeleter.Detach(); return _SaveSettings(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } } diff --git a/src/apps/installer/BlockingQueue.h b/src/apps/installer/BlockingQueue.h index 56a9d53ddb..bedc0ef868 100644 --- a/src/apps/installer/BlockingQueue.h +++ b/src/apps/installer/BlockingQueue.h @@ -118,7 +118,7 @@ BlockingQueue::Push(Element* element) return B_NO_INIT; try { fElements.push_back(element); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } status_t error = release_sem(fElementSemaphore); diff --git a/src/bin/debug/profile/profile.cpp b/src/bin/debug/profile/profile.cpp index 22f6338be3..a4d5d8e635 100644 --- a/src/bin/debug/profile/profile.cpp +++ b/src/bin/debug/profile/profile.cpp @@ -477,7 +477,7 @@ private: try { fImages[sharedImage->Name()] = sharedImage; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } diff --git a/src/kits/debugger/arch/x86/ArchitectureX86.cpp b/src/kits/debugger/arch/x86/ArchitectureX86.cpp index 8f0ddb2215..529490bc89 100644 --- a/src/kits/debugger/arch/x86/ArchitectureX86.cpp +++ b/src/kits/debugger/arch/x86/ArchitectureX86.cpp @@ -245,7 +245,7 @@ ArchitectureX86::Init() sizeof(x86_xmm_register)); } - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } diff --git a/src/kits/debugger/arch/x86_64/ArchitectureX8664.cpp b/src/kits/debugger/arch/x86_64/ArchitectureX8664.cpp index c6208b6503..cb03343633 100644 --- a/src/kits/debugger/arch/x86_64/ArchitectureX8664.cpp +++ b/src/kits/debugger/arch/x86_64/ArchitectureX8664.cpp @@ -273,7 +273,7 @@ ArchitectureX8664::Init() _AddSIMDRegister(X86_64_REGISTER_XMM15, "xmm15", sizeof(x86_64_xmm_register)); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } diff --git a/src/kits/game/WindowScreen.cpp b/src/kits/game/WindowScreen.cpp index a5773de891..ffc0026b94 100644 --- a/src/kits/game/WindowScreen.cpp +++ b/src/kits/game/WindowScreen.cpp @@ -623,7 +623,7 @@ BWindowScreen::_InitData(uint32 space, uint32 attributes) fWorkState = true; status = B_OK; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { status = B_NO_MEMORY; } catch (status_t error) { status = error; diff --git a/src/kits/package/hpkg/PackageWriterImpl.cpp b/src/kits/package/hpkg/PackageWriterImpl.cpp index 9ba1d4252a..94bdb7308d 100644 --- a/src/kits/package/hpkg/PackageWriterImpl.cpp +++ b/src/kits/package/hpkg/PackageWriterImpl.cpp @@ -467,7 +467,7 @@ PackageWriterImpl::Init(const char* fileName, return _Init(NULL, false, fileName, parameters); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -482,7 +482,7 @@ PackageWriterImpl::Init(BPositionIO* file, bool keepFile, return _Init(file, keepFile, NULL, parameters); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -574,7 +574,7 @@ PackageWriterImpl::AddEntry(const char* fileName, int fd) return _RegisterEntry(fileName, fd); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -614,7 +614,7 @@ PackageWriterImpl::Finish() return _Finish(); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -631,7 +631,7 @@ PackageWriterImpl::Recompress(BPositionIO* inputFile) return _Recompress(inputFile); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } diff --git a/src/kits/package/hpkg/RepositoryWriterImpl.cpp b/src/kits/package/hpkg/RepositoryWriterImpl.cpp index 305d68c1ca..50d2fc6d41 100644 --- a/src/kits/package/hpkg/RepositoryWriterImpl.cpp +++ b/src/kits/package/hpkg/RepositoryWriterImpl.cpp @@ -212,7 +212,7 @@ RepositoryWriterImpl::Init(const char* fileName) return _Init(fileName); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -226,7 +226,7 @@ RepositoryWriterImpl::AddPackage(const BEntry& packageEntry) return _AddPackage(packageEntry); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -240,7 +240,7 @@ RepositoryWriterImpl::AddPackageInfo(const BPackageInfo& packageInfo) return _AddPackageInfo(packageInfo); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } @@ -254,7 +254,7 @@ RepositoryWriterImpl::Finish() return _Finish(); } catch (status_t error) { return error; - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { fListener->PrintError("Out of memory!\n"); return B_NO_MEMORY; } diff --git a/src/kits/storage/mime/InstalledTypes.cpp b/src/kits/storage/mime/InstalledTypes.cpp index 2961796cdc..81cf03c2c2 100644 --- a/src/kits/storage/mime/InstalledTypes.cpp +++ b/src/kits/storage/mime/InstalledTypes.cpp @@ -380,7 +380,7 @@ InstalledTypes::_BuildInstalledTypesList() try { fCachedMessage = new BMessage(); fCachedSupertypesMessage = new BMessage(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { err = B_NO_MEMORY; } @@ -479,7 +479,7 @@ InstalledTypes::_CreateMessageWithTypes(BMessage **_result) const // Alloc the message try { *_result = new BMessage(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { err = B_NO_MEMORY; } @@ -511,7 +511,7 @@ InstalledTypes::_CreateMessageWithSupertypes(BMessage **_result) const // Alloc the message try { *_result = new BMessage(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { err = B_NO_MEMORY; } diff --git a/src/kits/storage/mime/Supertype.cpp b/src/kits/storage/mime/Supertype.cpp index 9f9cd1681f..ca4ae3dbd3 100644 --- a/src/kits/storage/mime/Supertype.cpp +++ b/src/kits/storage/mime/Supertype.cpp @@ -153,7 +153,7 @@ Supertype::CreateMessageWithTypes(BMessage **result) const if (!err) { try { *result = new BMessage(); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { err = B_NO_MEMORY; } } diff --git a/src/kits/storage/storage_support.cpp b/src/kits/storage/storage_support.cpp index 8b6618a9e5..bafa960e54 100644 --- a/src/kits/storage/storage_support.cpp +++ b/src/kits/storage/storage_support.cpp @@ -272,7 +272,7 @@ split_path(const char *fullPath, char **path, char **leaf) memcpy(*leaf, fullPath + leafStart, len); (*leaf)[len] = 0; } - } catch (std::bad_alloc exception) { + } catch (std::bad_alloc& exception) { if (path) delete[] *path; if (leaf) diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 01808141a0..058ac653e5 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -94,7 +94,7 @@ ShapePainter::IterateMoveTo(BPoint* point) try { fOpStack.push(OP_MOVETO); fPtStack.push(*point); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } @@ -109,7 +109,7 @@ ShapePainter::IterateLineTo(int32 lineCount, BPoint* linePts) fOpStack.push(OP_LINETO | lineCount); for (int32 i = 0; i < lineCount; i++) fPtStack.push(linePts[i]); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } @@ -125,7 +125,7 @@ ShapePainter::IterateBezierTo(int32 bezierCount, BPoint* bezierPts) fOpStack.push(OP_BEZIERTO | bezierCount); for (int32 i = 0; i < bezierCount; i++) fPtStack.push(bezierPts[i]); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } @@ -155,7 +155,7 @@ ShapePainter::IterateArcTo(float& rx, float& ry, fPtStack.push(BPoint(rx, ry)); fPtStack.push(BPoint(angle, 0)); fPtStack.push(point); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; } @@ -168,7 +168,7 @@ ShapePainter::IterateClose() { try { fOpStack.push(OP_CLOSE); - } catch (std::bad_alloc) { + } catch (std::bad_alloc&) { return B_NO_MEMORY; }