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) if (result != B_OK)
return result; return result;
fTargetEntry.SetTo(&fTargetDirectory, repoInfo.Name().String()); result = fTargetEntry.SetTo(&fTargetDirectory, repoInfo.Name().String());
if (result != B_OK)
return result;
if (fTargetEntry.Exists()) { if (fTargetEntry.Exists()) {
BString description = BString("A repository configuration for ") BString description = BString("A repository configuration for ")
<< repoInfo.Name() << " already exists."; << repoInfo.Name() << " already exists.";

View File

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

View File

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

View File

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

View File

@ -74,7 +74,11 @@ BRefreshRepositoryRequest::CreateInitialJobs()
BRepositoryCache repoCache; BRepositoryCache repoCache;
BPackageRoster roster; BPackageRoster roster;
roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache); result = roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache);
if (result != B_OK) {
delete fetchChecksumJob;
return result;
}
ValidateChecksumJob* validateChecksumJob ValidateChecksumJob* validateChecksumJob
= new (std::nothrow) ValidateChecksumJob(fContext, = 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 // Before we begin flush any pending data, so we don't need any special
// handling and also can use the pending data buffer. // 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 // 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 // to the end (minus the removed ranges, of course). As a basic algorithm we