Closed Bug 1258339 Opened 4 years ago Closed 4 years ago

[Static Analysis][Unused value] In function CustomCleanupCallback::Cleanup

Categories

(Core :: Storage: IndexedDB, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1357091)

Attachments

(1 file)

The Static Analysis tool Coverity added that |rv| is assigned a value that afterwards in never used:

>>      if (aFileManager->EnforcingQuota()) {
>>        rv = file->GetFileSize(&fileSize);
>>        if (NS_WARN_IF(!file)) {
>>          return NS_ERROR_FAILURE;
>>        }
>>      }

I consider that in case of GetFileSize fails the correct behavior would be:

>>      if (aFileManager->EnforcingQuota()) {
>>        rv = file->GetFileSize(&fileSize);
>>        if (NS_WARN_IF(NS_FAILED(rv))) {
>>          return rv;
>>        }
>>      }

In case GetFileSize gets called we are safe to assume that file is a valid nsCOMPtr<nsIFile> because of the earlier checker from the start of the function:

>>      nsCOMPtr<nsIFile> file = aFileManager->GetFileForId(mDirectory, aId);
>>      if (NS_WARN_IF(!file)) {
>>        return NS_ERROR_FAILURE;
>>      }

so checking again the validity of file is useless.
Yes, you are right.
that was wicked fast Jan :)
Comment on attachment 8732828 [details]
MozReview Request: Bug 1258339 - check return value of GetFileSize. r?janv

https://reviewboard.mozilla.org/r/41391/#review37863

r=me, Thanks!
Attachment #8732828 - Flags: review?(jvarga) → review+
https://hg.mozilla.org/mozilla-central/rev/a84154aad442
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.