Fix catching polymorphic type by value

Replace catching polymorphic type std::bad_alloc 'by value'
with 'by reference'.
Pointed by gcc8
This commit is contained in:
Murai Takashi
2018-05-16 13:49:46 +00:00
committed by Adrien Destugues
parent c7c3973e09
commit b08627f310
18 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
@@ -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;
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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.
@@ -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;
}
}
+1 -1
View File
@@ -118,7 +118,7 @@ BlockingQueue<Element>::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);
+1 -1
View File
@@ -477,7 +477,7 @@ private:
try {
fImages[sharedImage->Name()] = sharedImage;
} catch (std::bad_alloc) {
} catch (std::bad_alloc&) {
return B_NO_MEMORY;
}
@@ -245,7 +245,7 @@ ArchitectureX86::Init()
sizeof(x86_xmm_register));
}
} catch (std::bad_alloc) {
} catch (std::bad_alloc&) {
return B_NO_MEMORY;
}
@@ -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;
}
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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;
}
@@ -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;
}
+3 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
}
+1 -1
View File
@@ -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)
+5 -5
View File
@@ -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;
}