Bug 1651016 - Convert remaining NS_ENSURE_SUCCESS to QM_TRY in FileStreams.cpp; r=dom-workers-and-storage-reviewers,ttung,sg

Differential Revision: https://phabricator.services.mozilla.com/D84312
This commit is contained in:
Jan Varga 2020-07-23 09:18:22 +00:00
Родитель d380b48ae6
Коммит 82f28d2c55
1 изменённых файлов: 15 добавлений и 20 удалений

Просмотреть файл

@ -13,13 +13,11 @@ BEGIN_QUOTA_NAMESPACE
template <class FileStreamBase> template <class FileStreamBase>
NS_IMETHODIMP FileQuotaStream<FileStreamBase>::SetEOF() { NS_IMETHODIMP FileQuotaStream<FileStreamBase>::SetEOF() {
nsresult rv = FileStreamBase::SetEOF(); QM_TRY(FileStreamBase::SetEOF());
NS_ENSURE_SUCCESS(rv, rv);
if (mQuotaObject) { if (mQuotaObject) {
int64_t offset; int64_t offset;
nsresult rv = FileStreamBase::Tell(&offset); QM_TRY(FileStreamBase::Tell(&offset));
NS_ENSURE_SUCCESS(rv, rv);
DebugOnly<bool> res = DebugOnly<bool> res =
mQuotaObject->MaybeUpdateSize(offset, /* aTruncate */ true); mQuotaObject->MaybeUpdateSize(offset, /* aTruncate */ true);
@ -31,8 +29,7 @@ NS_IMETHODIMP FileQuotaStream<FileStreamBase>::SetEOF() {
template <class FileStreamBase> template <class FileStreamBase>
NS_IMETHODIMP FileQuotaStream<FileStreamBase>::Close() { NS_IMETHODIMP FileQuotaStream<FileStreamBase>::Close() {
nsresult rv = FileStreamBase::Close(); QM_TRY(FileStreamBase::Close());
NS_ENSURE_SUCCESS(rv, rv);
mQuotaObject = nullptr; mQuotaObject = nullptr;
@ -49,8 +46,7 @@ nsresult FileQuotaStream<FileStreamBase>::DoOpen() {
mPersistenceType, mGroup, mOrigin, mClientType, mPersistenceType, mGroup, mOrigin, mClientType,
FileStreamBase::mOpenParams.localFile); FileStreamBase::mOpenParams.localFile);
nsresult rv = FileStreamBase::DoOpen(); QM_TRY(FileStreamBase::DoOpen());
NS_ENSURE_SUCCESS(rv, rv);
if (mQuotaObject && (FileStreamBase::mOpenParams.ioFlags & PR_TRUNCATE)) { if (mQuotaObject && (FileStreamBase::mOpenParams.ioFlags & PR_TRUNCATE)) {
DebugOnly<bool> res = DebugOnly<bool> res =
@ -64,12 +60,9 @@ nsresult FileQuotaStream<FileStreamBase>::DoOpen() {
template <class FileStreamBase> template <class FileStreamBase>
NS_IMETHODIMP FileQuotaStreamWithWrite<FileStreamBase>::Write( NS_IMETHODIMP FileQuotaStreamWithWrite<FileStreamBase>::Write(
const char* aBuf, uint32_t aCount, uint32_t* _retval) { const char* aBuf, uint32_t aCount, uint32_t* _retval) {
nsresult rv;
if (FileQuotaStreamWithWrite::mQuotaObject) { if (FileQuotaStreamWithWrite::mQuotaObject) {
int64_t offset; int64_t offset;
rv = FileStreamBase::Tell(&offset); QM_TRY(FileStreamBase::Tell(&offset));
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(INT64_MAX - offset >= int64_t(aCount)); MOZ_ASSERT(INT64_MAX - offset >= int64_t(aCount));
@ -80,8 +73,7 @@ NS_IMETHODIMP FileQuotaStreamWithWrite<FileStreamBase>::Write(
} }
} }
rv = FileStreamBase::Write(aBuf, aCount, _retval); QM_TRY(FileStreamBase::Write(aBuf, aCount, _retval));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
} }
@ -92,8 +84,9 @@ already_AddRefed<FileInputStream> CreateFileInputStream(
int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) { int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) {
RefPtr<FileInputStream> stream = RefPtr<FileInputStream> stream =
new FileInputStream(aPersistenceType, aGroup, aOrigin, aClientType); new FileInputStream(aPersistenceType, aGroup, aOrigin, aClientType);
nsresult rv = stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
NS_ENSURE_SUCCESS(rv, nullptr); QM_TRY(stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags), nullptr);
return stream.forget(); return stream.forget();
} }
@ -103,8 +96,9 @@ already_AddRefed<FileOutputStream> CreateFileOutputStream(
int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) { int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) {
RefPtr<FileOutputStream> stream = RefPtr<FileOutputStream> stream =
new FileOutputStream(aPersistenceType, aGroup, aOrigin, aClientType); new FileOutputStream(aPersistenceType, aGroup, aOrigin, aClientType);
nsresult rv = stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
NS_ENSURE_SUCCESS(rv, nullptr); QM_TRY(stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags), nullptr);
return stream.forget(); return stream.forget();
} }
@ -114,8 +108,9 @@ already_AddRefed<FileStream> CreateFileStream(
int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) { int32_t aIOFlags, int32_t aPerm, int32_t aBehaviorFlags) {
RefPtr<FileStream> stream = RefPtr<FileStream> stream =
new FileStream(aPersistenceType, aGroup, aOrigin, aClientType); new FileStream(aPersistenceType, aGroup, aOrigin, aClientType);
nsresult rv = stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
NS_ENSURE_SUCCESS(rv, nullptr); QM_TRY(stream->Init(aFile, aIOFlags, aPerm, aBehaviorFlags), nullptr);
return stream.forget(); return stream.forget();
} }