[haiku-commits] haiku: hrev53744 - in src: apps/haikudepot/model kits/debug apps/softwareupdater apps/haikudepot/server kits/storage

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 21 Jan 2020 14:26:26 -0500 (EST)

hrev53744 adds 1 changeset to branch 'master'
old head: 654135466f2ad0a080c41ddda423291a14e5fe61
new head: 992ae400ec160a3e2ef6ad71c011cd688c9f2476
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=992ae400ec16+%5E654135466f2a

----------------------------------------------------------------------------

992ae400ec16: Fix catching by value
  
  Pointed out by LGTM.
  Change-Id: I223655c728305f6f45b3738553da5b7d7a69e8c8
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2134
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                      [ Murai Takashi <tmurai01@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53744
Commit:      992ae400ec160a3e2ef6ad71c011cd688c9f2476
URL:         https://git.haiku-os.org/haiku/commit/?id=992ae400ec16
Author:      Murai Takashi <tmurai01@xxxxxxxxx>
Date:        Sat Jan 18 20:15:45 2020 UTC
Committer:   Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Tue Jan 21 19:26:22 2020 UTC

----------------------------------------------------------------------------

15 files changed, 47 insertions(+), 47 deletions(-)
src/add-ons/print/drivers/gutenprint/GPJob.cpp   |  2 +-
src/apps/deskcalc/CalcView.cpp                   |  2 +-
src/apps/deskcalc/DeskCalc.cpp                   |  2 +-
src/apps/haikudepot/model/PackageManager.cpp     | 24 ++++++++++----------
.../server/LocalPkgDataLoadProcess.cpp           | 10 ++++----
.../server/LocalRepositoryUpdateProcess.cpp      |  6 ++---
src/apps/softwareupdater/CheckAction.cpp         |  8 +++----
src/apps/softwareupdater/UpdateAction.cpp        |  8 +++----
src/kits/debug/SymbolLookup.cpp                  |  2 +-
src/kits/debug/debug_support.cpp                 | 10 ++++----
.../source_language/c_family/CLanguageFamily.cpp |  4 ++--
src/kits/storage/ResourceFile.cpp                |  8 +++----
src/kits/tracker/FSUtils.cpp                     |  4 ++--
.../get_package_dependencies.cpp                 |  2 +-
src/tools/set_haiku_revision.cpp                 |  2 +-

----------------------------------------------------------------------------

diff --git a/src/add-ons/print/drivers/gutenprint/GPJob.cpp 
b/src/add-ons/print/drivers/gutenprint/GPJob.cpp
index d0519ad5bb..a6c5c8bc6d 100644
--- a/src/add-ons/print/drivers/gutenprint/GPJob.cpp
+++ b/src/add-ons/print/drivers/gutenprint/GPJob.cpp
@@ -518,7 +518,7 @@ GPJob::Write(const char* data, size_t size)
 {
        try {
                fOutputStream->Write(data, size);
-       } catch (TransportException e) {
+       } catch (TransportException& e) {
                fStatus = B_IO_ERROR;
        }
 }
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index b138c482d9..bd6006c3f2 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -1124,7 +1124,7 @@ CalcView::_EvaluateThread(void* data)
                BString expression(calcView->fExpressionTextView->Text());
                try {
                        result = parser.Evaluate(expression.String());
-               } catch (ParseException e) {
+               } catch (ParseException& e) {
                        result << e.message.String() << " at " << (e.position + 
1);
                        status = B_ERROR;
                }
diff --git a/src/apps/deskcalc/DeskCalc.cpp b/src/apps/deskcalc/DeskCalc.cpp
index af78d8ebe3..1e4471d877 100644
--- a/src/apps/deskcalc/DeskCalc.cpp
+++ b/src/apps/deskcalc/DeskCalc.cpp
@@ -37,7 +37,7 @@ main(int argc, char* argv[])
                        ExpressionParser parser;
                        BString result = parser.Evaluate(expression.String());
                        printf("%s\n", result.String());
-               } catch (ParseException e) {
+               } catch (ParseException& e) {
                        printf("%s at %" B_PRId32 "\n", e.message.String(), 
e.position + 1);
                        return 1;
                }
diff --git a/src/apps/haikudepot/model/PackageManager.cpp 
b/src/apps/haikudepot/model/PackageManager.cpp
index c9703c88d1..e84e704dc7 100644
--- a/src/apps/haikudepot/model/PackageManager.cpp
+++ b/src/apps/haikudepot/model/PackageManager.cpp
@@ -148,7 +148,7 @@ public:
                const char* packageNameString = packageName.String();
                try {
                        fPackageManager->Install(&packageNameString, 1);
-               } catch (BFatalErrorException ex) {
+               } catch (BFatalErrorException& ex) {
                        BString errorString;
                        errorString.SetToFormat(
                                "Fatal error occurred while installing package 
%s: "
@@ -162,18 +162,18 @@ public:
                        _SetDownloadedPackagesState(NONE);
                        ref->SetState(state);
                        return ex.Error();
-               } catch (BAbortedByUserException ex) {
+               } catch (BAbortedByUserException& ex) {
                        fprintf(stderr, "Installation of package "
                                "%s aborted by user: %s\n", packageNameString,
                                ex.Message().String());
                        _SetDownloadedPackagesState(NONE);
                        ref->SetState(state);
                        return B_OK;
-               } catch (BNothingToDoException ex) {
+               } catch (BNothingToDoException& ex) {
                        fprintf(stderr, "Nothing to do while installing package 
"
                                "%s: %s\n", packageNameString, 
ex.Message().String());
                        return B_OK;
-               } catch (BException ex) {
+               } catch (BException& ex) {
                        fprintf(stderr, "Exception occurred while installing 
package "
                                "%s: %s\n", packageNameString, 
ex.Message().String());
                        _SetDownloadedPackagesState(NONE);
@@ -273,7 +273,7 @@ public:
                const char* packageName = ref->Name().String();
                try {
                        fPackageManager->Uninstall(&packageName, 1);
-               } catch (BFatalErrorException ex) {
+               } catch (BFatalErrorException& ex) {
                        BString errorString;
                        errorString.SetToFormat(
                                "Fatal error occurred while uninstalling 
package %s: "
@@ -286,11 +286,11 @@ public:
                                alert->Go();
                        ref->SetState(state);
                        return ex.Error();
-               } catch (BAbortedByUserException ex) {
+               } catch (BAbortedByUserException& ex) {
                        return B_OK;
-               } catch (BNothingToDoException ex) {
+               } catch (BNothingToDoException& ex) {
                        return B_OK;
-               } catch (BException ex) {
+               } catch (BException& ex) {
                        fprintf(stderr, "Exception occurred while uninstalling 
package "
                                "%s: %s\n", packageName, ex.Message().String());
                        ref->SetState(state);
@@ -634,11 +634,11 @@ PackageManager::RefreshRepository(const 
BRepositoryConfig& repoConfig)
        status_t result;
        try {
                result = BPackageManager::RefreshRepository(repoConfig);
-       } catch (BFatalErrorException ex) {
+       } catch (BFatalErrorException& ex) {
                fprintf(stderr, "Fatal error occurred while refreshing 
repository: "
                        "%s (%s)\n", ex.Message().String(), 
ex.Details().String());
                result = ex.Error();
-       } catch (BException ex) {
+       } catch (BException& ex) {
                fprintf(stderr, "Exception occurred while refreshing "
                        "repository: %s\n", ex.Message().String());
                result = B_ERROR;
@@ -656,12 +656,12 @@ PackageManager::DownloadPackage(const BString& fileURL,
        try {
                result = BPackageManager::DownloadPackage(fileURL, targetEntry,
                        checksum);
-       } catch (BFatalErrorException ex) {
+       } catch (BFatalErrorException& ex) {
                fprintf(stderr, "Fatal error occurred while downloading 
package: "
                        "%s: %s (%s)\n", fileURL.String(), 
ex.Message().String(),
                        ex.Details().String());
                result = ex.Error();
-       } catch (BException ex) {
+       } catch (BException& ex) {
                fprintf(stderr, "Exception occurred while downloading package "
                        "%s: %s\n", fileURL.String(), ex.Message().String());
                result = B_ERROR;
diff --git a/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp 
b/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp
index 878e12f89a..47c01de7d1 100644
--- a/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp
+++ b/src/apps/haikudepot/server/LocalPkgDataLoadProcess.cpp
@@ -130,7 +130,7 @@ LocalPkgDataLoadProcess::RunInternal()
        try {
                manager.Init(PackageManager::B_ADD_INSTALLED_REPOSITORIES
                        | PackageManager::B_ADD_REMOTE_REPOSITORIES);
-       } catch (BException ex) {
+       } catch (BException& ex) {
                BString message(B_TRANSLATE("An error occurred while "
                        "initializing the package manager: %message%"));
                message.ReplaceFirst("%message%", ex.Message());
@@ -362,12 +362,12 @@ LocalPkgDataLoadProcess::RunInternal()
                                        it->second->SetSystemDependency(true);
                        }
                }
-       } catch (BFatalErrorException ex) {
+       } catch (BFatalErrorException& ex) {
                printf("Fatal exception occurred while resolving system 
dependencies: "
                        "%s, details: %s\n", strerror(ex.Error()), 
ex.Details().String());
-       } catch (BNothingToDoException) {
+       } catch (BNothingToDoException&) {
                // do nothing
-       } catch (BException ex) {
+       } catch (BException& ex) {
                printf("Exception occurred while resolving system dependencies: 
%s\n",
                        ex.Message().String());
        } catch (...) {
@@ -390,4 +390,4 @@ LocalPkgDataLoadProcess::_NotifyError(const BString& 
messageText) const
        AppUtils::NotifySimpleError(
                B_TRANSLATE("Local repository load error"),
                messageText);
-}
\ No newline at end of file
+}
diff --git a/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp 
b/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp
index 1c03ae90f6..9e1fc09cab 100644
--- a/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp
+++ b/src/apps/haikudepot/server/LocalRepositoryUpdateProcess.cpp
@@ -112,9 +112,9 @@ LocalRepositoryUpdateProcess::_RunForRepositoryName(const 
BString& repoName,
                                BRefreshRepositoryRequest 
refreshRequest(context, repoConfig);
                                result = refreshRequest.Process();
                                result = B_OK;
-                       } catch (BFatalErrorException ex) {
+                       } catch (BFatalErrorException& ex) {
                                _NotifyError(ex.Message(), ex.Details());
-                       } catch (BException ex) {
+                       } catch (BException& ex) {
                                _NotifyError(ex.Message());
                        }
                }
@@ -153,4 +153,4 @@ LocalRepositoryUpdateProcess::_NotifyError(const BString& 
error,
        AppUtils::NotifySimpleError(
                B_TRANSLATE("Repository update error"),
                alertText);
-}
\ No newline at end of file
+}
diff --git a/src/apps/softwareupdater/CheckAction.cpp 
b/src/apps/softwareupdater/CheckAction.cpp
index c5a2770705..47c1cfd6ea 100644
--- a/src/apps/softwareupdater/CheckAction.cpp
+++ b/src/apps/softwareupdater/CheckAction.cpp
@@ -51,21 +51,21 @@ CheckAction::Perform()
                int packageCount = 0;
                const char* const packages = "";
                fCheckManager->Update(&packages, packageCount);
-       } catch (BFatalErrorException ex) {
+       } catch (BFatalErrorException& ex) {
                fprintf(stderr, B_TRANSLATE(
                                "Fatal error while checking for updates: %s\n"),
                        ex.Message().String());
                be_app->PostMessage(kMsgFinalQuit);
                return ex.Error();
-       } catch (BAbortedByUserException ex) {
+       } catch (BAbortedByUserException& ex) {
                be_app->PostMessage(kMsgFinalQuit);
                return B_OK;
-       } catch (BNothingToDoException ex) {
+       } catch (BNothingToDoException& ex) {
                puts(B_TRANSLATE("There were no updates found."));
                fCheckManager->NoUpdatesNotification();
                be_app->PostMessage(kMsgFinalQuit);
                return B_OK;
-       } catch (BException ex) {
+       } catch (BException& ex) {
                fprintf(stderr, B_TRANSLATE(
                                "Exception occurred while checking for updates: 
%s\n"),
                        ex.Message().String());
diff --git a/src/apps/softwareupdater/UpdateAction.cpp 
b/src/apps/softwareupdater/UpdateAction.cpp
index 259ae6caae..619216ce9d 100644
--- a/src/apps/softwareupdater/UpdateAction.cpp
+++ b/src/apps/softwareupdater/UpdateAction.cpp
@@ -73,25 +73,25 @@ UpdateAction::Perform(update_type action_request)
                        throw BException(B_TRANSLATE(
                                "Invalid update type, cannot continue with 
updates"));
        
-       } catch (BFatalErrorException ex) {
+       } catch (BFatalErrorException& ex) {
                fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not 
complete"),
                        ex.Message());
                return ex.Error();
-       } catch (BAbortedByUserException ex) {
+       } catch (BAbortedByUserException& ex) {
                if (fVerbose)
                        fprintf(stderr, "Updates aborted by user: %s\n",
                                ex.Message().String());
                // No need for a final message since user initiated cancel 
request
                be_app->PostMessage(kMsgFinalQuit);
                return B_OK;
-       } catch (BNothingToDoException ex) {
+       } catch (BNothingToDoException& ex) {
                if (fVerbose)
                        fprintf(stderr, "Nothing to do while updating packages 
: %s\n",
                                ex.Message().String());
                fUpdateManager->FinalUpdate(B_TRANSLATE("No updates available"),
                        B_TRANSLATE("There were no updates found."));
                return B_OK;
-       } catch (BException ex) {
+       } catch (BException& ex) {
                if (fVerbose)
                        fprintf(stderr, B_TRANSLATE(
                                "Exception occurred while updating packages : 
%s\n"),
diff --git a/src/kits/debug/SymbolLookup.cpp b/src/kits/debug/SymbolLookup.cpp
index 53f41d78ad..d741b11eb3 100644
--- a/src/kits/debug/SymbolLookup.cpp
+++ b/src/kits/debug/SymbolLookup.cpp
@@ -278,7 +278,7 @@ SymbolLookup::Init()
                                TRACE(("SymbolLookup::Init(): translated debug 
area is at: %p, "
                                        "loaded_images: %p\n", fDebugArea, 
fDebugArea->loaded_images));
                        }
-               } catch (Exception exception) {
+               } catch (Exception& exception) {
                        // we can live without the debug area
                }
        }
diff --git a/src/kits/debug/debug_support.cpp b/src/kits/debug/debug_support.cpp
index fdc231d3a9..e6277d1976 100644
--- a/src/kits/debug/debug_support.cpp
+++ b/src/kits/debug/debug_support.cpp
@@ -368,7 +368,7 @@ debug_create_symbol_lookup_context(team_id team, image_id 
image,
                status_t error = lookup->Init();
                if (error != B_OK)
                        return error;
-       } catch (BPrivate::Debug::Exception exception) {
+       } catch (BPrivate::Debug::Exception& exception) {
                return exception.Error();
        }
 
@@ -429,7 +429,7 @@ debug_lookup_symbol_address(debug_symbol_lookup_context 
*lookupContext,
                        exactMatch);
                if (error != B_OK)
                        return error;
-       } catch (BPrivate::Debug::Exception exception) {
+       } catch (BPrivate::Debug::Exception& exception) {
                return exception.Error();
        }
 
@@ -470,7 +470,7 @@ 
debug_create_image_symbol_iterator(debug_symbol_lookup_context* lookupContext,
        status_t error;
        try {
                error = lookup->InitSymbolIterator(imageID, *iterator);
-       } catch (BPrivate::Debug::Exception exception) {
+       } catch (BPrivate::Debug::Exception& exception) {
                error = exception.Error();
        }
 
@@ -488,7 +488,7 @@ 
debug_create_image_symbol_iterator(debug_symbol_lookup_context* lookupContext,
                        try {
                                error = lookup->InitSymbolIteratorByAddress(
                                        (addr_t)imageInfo.text, *iterator);
-                       } catch (BPrivate::Debug::Exception exception) {
+                       } catch (BPrivate::Debug::Exception& exception) {
                                error = exception.Error();
                        }
                }
@@ -565,7 +565,7 @@ debug_next_image_symbol(debug_symbol_iterator* iterator, 
char* nameBuffer,
                        _symbolType);
                if (error != B_OK)
                        return error;
-       } catch (BPrivate::Debug::Exception exception) {
+       } catch (BPrivate::Debug::Exception& exception) {
                return exception.Error();
        }
 
diff --git a/src/kits/debugger/source_language/c_family/CLanguageFamily.cpp 
b/src/kits/debugger/source_language/c_family/CLanguageFamily.cpp
index 707c09d5a5..d8018138b9 100644
--- a/src/kits/debugger/source_language/c_family/CLanguageFamily.cpp
+++ b/src/kits/debugger/source_language/c_family/CLanguageFamily.cpp
@@ -51,7 +51,7 @@ CLanguageFamily::EvaluateExpression(const BString& expression,
        try {
                _output = evaluator.Evaluate(expression, manager, info);
                return B_OK;
-       } catch (ParseException ex) {
+       } catch (ParseException& ex) {
                BString error;
                error.SetToFormat("Parse error at position %" B_PRId32 ": %s",
                        ex.position, ex.message.String());
@@ -64,7 +64,7 @@ CLanguageFamily::EvaluateExpression(const BString& expression,
                        return B_NO_MEMORY;
                _output->SetToPrimitive(value);
                return B_BAD_DATA;
-       } catch (ValueNeededException ex) {
+       } catch (ValueNeededException& ex) {
                _neededNode = ex.value;
        }
 
diff --git a/src/kits/storage/ResourceFile.cpp 
b/src/kits/storage/ResourceFile.cpp
index fc79456705..add3c7daa0 100644
--- a/src/kits/storage/ResourceFile.cpp
+++ b/src/kits/storage/ResourceFile.cpp
@@ -244,7 +244,7 @@ ResourceFile::SetTo(BFile* file, bool clobber)
        if (error == B_OK) {
                try {
                        _InitFile(*file, clobber);
-               } catch (Exception exception) {
+               } catch (Exception& exception) {
                        Unset();
                        if (exception.Error() != B_OK)
                                error = exception.Error();
@@ -295,7 +295,7 @@ ResourceFile::InitContainer(ResourcesContainer& container)
                        _ReadIndex(parseInfo);
                        _ReadInfoTable(parseInfo);
                        container.SetModified(false);
-               } catch (Exception exception) {
+               } catch (Exception& exception) {
                        if (exception.Error() != B_OK)
                                error = exception.Error();
                        else
@@ -1272,7 +1272,7 @@ ResourceFile::_WriteResources(ResourcesContainer& 
container)
                tableEnd->rite_terminator = 0;
                write_exactly(fFile, infoTableOffset, buffer, infoTableSize,
                        "Failed to write info table.");
-       } catch (Exception exception) {
+       } catch (Exception& exception) {
                if (exception.Error() != B_OK)
                        error = exception.Error();
                else
@@ -1302,7 +1302,7 @@ ResourceFile::_MakeEmptyResourceFile()
                        fFileType = FILE_TYPE_X86_RESOURCE;
                        fFile.SetTo(file, kX86ResourcesOffset);
                        fEmptyResources = true;
-               } catch (Exception exception) {
+               } catch (Exception& exception) {
                        if (exception.Error() != B_OK)
                                error = exception.Error();
                        else
diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp
index 2603d62b50..8cfc7a8a9b 100644
--- a/src/kits/tracker/FSUtils.cpp
+++ b/src/kits/tracker/FSUtils.cpp
@@ -1788,7 +1788,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, 
uint32 moveMode,
        } catch (status_t error) {
                // no alert, was already taken care of before
                return error;
-       } catch (MoveError error) {
+       } catch (MoveError& error) {
                BString errorString(B_TRANSLATE("Error moving \"%name\""));
                errorString.ReplaceFirst("%name", ref.name);
                BAlert* alert = new BAlert("", errorString.String(), 
B_TRANSLATE("OK"),
@@ -1796,7 +1796,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, 
uint32 moveMode,
                alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
                alert->Go();
                return error.fError;
-       } catch (FailWithAlert error) {
+       } catch (FailWithAlert& error) {
                BString buffer(error.fString);
                if (error.fName != NULL)
                        buffer.ReplaceFirst("%name", error.fName);
diff --git a/src/tools/get_package_dependencies/get_package_dependencies.cpp 
b/src/tools/get_package_dependencies/get_package_dependencies.cpp
index 9da69d4c82..e016d0a4a7 100644
--- a/src/tools/get_package_dependencies/get_package_dependencies.cpp
+++ b/src/tools/get_package_dependencies/get_package_dependencies.cpp
@@ -90,7 +90,7 @@ main(int argc, const char* const* argv)
                for (int i = 0; i < packageCount; i++)
                        installedRepositoryBuilder.AddPackage(packages[i]);
                installedRepositoryBuilder.AddToSolver(solver, true);
-       } catch (BFatalErrorException e) {
+       } catch (BFatalErrorException& e) {
                DIE(e.Error(), "%s %s", e.Message().String(), 
e.Details().String());
        }
 
diff --git a/src/tools/set_haiku_revision.cpp b/src/tools/set_haiku_revision.cpp
index 88c4704e04..9ec29706e6 100644
--- a/src/tools/set_haiku_revision.cpp
+++ b/src/tools/set_haiku_revision.cpp
@@ -696,7 +696,7 @@ main(int argc, const char* const* argv)
                        min((size_t)SYSTEM_REVISION_LENGTH, 
strlen(revisionString) + 1),
                        "Failed to write revision.");
 
-       } catch (Exception exception) {
+       } catch (Exception& exception) {
                if (exception.Description() == "") {
                        fprintf(stderr, "%s\n", strerror(exception.Error()));
                } else {


Other related posts:

  • » [haiku-commits] haiku: hrev53744 - in src: apps/haikudepot/model kits/debug apps/softwareupdater apps/haikudepot/server kits/storage - Jérôme Duval