Package Kit: Avoid discarding potential error values.

Spotted by Clang and the [[nodiscard]] patch.
This commit is contained in:
Augustin Cavalier 2019-08-02 19:14:42 -04:00
parent a4a538db9f
commit dfbf1c8a0a
6 changed files with 36 additions and 36 deletions

View File

@ -46,7 +46,10 @@ ActivateRepositoryConfigJob::Execute()
if (result != B_OK)
return result;
fTargetEntry.SetTo(&fTargetDirectory, repoInfo.Name().String());
result = fTargetEntry.SetTo(&fTargetDirectory, repoInfo.Name().String());
if (result != B_OK)
return result;
if (fTargetEntry.Exists()) {
BString description = BString("A repository configuration for ")
<< repoInfo.Name() << " already exists.";

View File

@ -77,7 +77,9 @@ AddRepositoryRequest::CreateInitialJobs()
tempEntry, fRepositoryBaseURL, targetDirectory);
if (activateJob == NULL)
return B_NO_MEMORY;
activateJob->AddDependency(fetchJob);
result = activateJob->AddDependency(fetchJob);
if (result != B_OK)
return result;
if ((result = QueueJob(activateJob)) != B_OK) {
delete activateJob;
return result;

View File

@ -92,44 +92,34 @@ BPackageInfoContentHandler::HandlePackageAttribute(
break;
case B_PACKAGE_INFO_COPYRIGHTS:
fPackageInfo.AddCopyright(value.string);
break;
return fPackageInfo.AddCopyright(value.string);
case B_PACKAGE_INFO_LICENSES:
fPackageInfo.AddLicense(value.string);
break;
return fPackageInfo.AddLicense(value.string);
case B_PACKAGE_INFO_PROVIDES:
fPackageInfo.AddProvides(value.resolvable);
break;
return fPackageInfo.AddProvides(value.resolvable);
case B_PACKAGE_INFO_REQUIRES:
fPackageInfo.AddRequires(value.resolvableExpression);
break;
return fPackageInfo.AddRequires(value.resolvableExpression);
case B_PACKAGE_INFO_SUPPLEMENTS:
fPackageInfo.AddSupplements(value.resolvableExpression);
break;
return fPackageInfo.AddSupplements(value.resolvableExpression);
case B_PACKAGE_INFO_CONFLICTS:
fPackageInfo.AddConflicts(value.resolvableExpression);
break;
return fPackageInfo.AddConflicts(value.resolvableExpression);
case B_PACKAGE_INFO_FRESHENS:
fPackageInfo.AddFreshens(value.resolvableExpression);
break;
return fPackageInfo.AddFreshens(value.resolvableExpression);
case B_PACKAGE_INFO_REPLACES:
fPackageInfo.AddReplaces(value.string);
break;
return fPackageInfo.AddReplaces(value.string);
case B_PACKAGE_INFO_URLS:
fPackageInfo.AddURL(value.string);
break;
return fPackageInfo.AddURL(value.string);
case B_PACKAGE_INFO_SOURCE_URLS:
fPackageInfo.AddSourceURL(value.string);
break;
return fPackageInfo.AddSourceURL(value.string);
case B_PACKAGE_INFO_CHECKSUM:
fPackageInfo.SetChecksum(value.string);
@ -144,25 +134,20 @@ BPackageInfoContentHandler::HandlePackageAttribute(
break;
case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES:
fPackageInfo.AddGlobalWritableFileInfo(
return fPackageInfo.AddGlobalWritableFileInfo(
value.globalWritableFileInfo);
break;
case B_PACKAGE_INFO_USER_SETTINGS_FILES:
fPackageInfo.AddUserSettingsFileInfo(value.userSettingsFileInfo);
break;
return fPackageInfo.AddUserSettingsFileInfo(value.userSettingsFileInfo);
case B_PACKAGE_INFO_USERS:
fPackageInfo.AddUser(value.user);
break;
return fPackageInfo.AddUser(value.user);
case B_PACKAGE_INFO_GROUPS:
fPackageInfo.AddGroup(value.string);
break;
return fPackageInfo.AddGroup(value.string);
case B_PACKAGE_INFO_POST_INSTALL_SCRIPTS:
fPackageInfo.AddPostInstallScript(value.string);
break;
return fPackageInfo.AddPostInstallScript(value.string);
default:
if (fErrorOutput != NULL) {

View File

@ -181,7 +181,9 @@ BPackageRoster::GetRepositoryCache(const BString& name,
return result;
path.Append(name.String());
repoCacheEntry.SetTo(path.Path());
result = repoCacheEntry.SetTo(path.Path());
if (result != B_OK)
return result;
return repositoryCache->SetTo(repoCacheEntry);
}
@ -208,7 +210,9 @@ BPackageRoster::GetRepositoryConfig(const BString& name,
return result;
path.Append(name.String());
repoConfigEntry.SetTo(path.Path());
result = repoConfigEntry.SetTo(path.Path());
if (result != B_OK)
return result;
return repositoryConfig->SetTo(repoConfigEntry);
}

View File

@ -74,7 +74,11 @@ BRefreshRepositoryRequest::CreateInitialJobs()
BRepositoryCache repoCache;
BPackageRoster roster;
roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache);
result = roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache);
if (result != B_OK) {
delete fetchChecksumJob;
return result;
}
ValidateChecksumJob* validateChecksumJob
= new (std::nothrow) ValidateChecksumJob(fContext,

View File

@ -317,7 +317,9 @@ PackageFileHeapWriter::RemoveDataRanges(
// Before we begin flush any pending data, so we don't need any special
// handling and also can use the pending data buffer.
_FlushPendingData();
status_t status = _FlushPendingData();
if (status != B_OK)
throw status_t(status);
// We potentially have to recompress all data from the first affected chunk
// to the end (minus the removed ranges, of course). As a basic algorithm we