All users were logged out of Bugzilla on October 13th, 2018

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

RESOLVED FIXED in Firefox 48

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: andi, Assigned: andi)

Tracking

(Blocks: 1 bug, {coverity})

Trunk
mozilla48
coverity
Points:
---

Firefox Tracking Flags

(firefox48 fixed)

Details

(Whiteboard: CID 1357091)

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
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.

Comment 1

3 years ago
Yes, you are right.
(Assignee)

Comment 2

3 years ago
Created attachment 8732828 [details]
MozReview Request: Bug 1258339 - check return value of GetFileSize. r?janv

Review commit: https://reviewboard.mozilla.org/r/41391/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/41391/
Attachment #8732828 - Flags: review?(jvarga)
(Assignee)

Comment 3

3 years ago
that was wicked fast Jan :)

Comment 4

3 years ago
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+

Comment 6

3 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/a84154aad442
Status: NEW → RESOLVED
Last Resolved: 3 years ago
status-firefox48: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.