Notification::CloseInternal: warning: ‘rv’ may be used uninitialized in this function [-Wmaybe-uninitialized]

RESOLVED FIXED in mozilla32

Status

()

defect
RESOLVED FIXED
5 years ago
5 months ago

People

(Reporter: froydnj, Assigned: froydnj)

Tracking

(Blocks 1 bug)

unspecified
mozilla32
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

This warning is completely legitimate:

    nsresult rv;
    // Don't bail out if notification storage fails, since we still
    // want to send the close event through the alert service.
    nsCOMPtr<nsINotificationStorage> notificationStorage =
      do_GetService(NS_NOTIFICATION_STORAGE_CONTRACTID);
    if (notificationStorage) {
      nsString origin;
      rv = GetOrigin(GetOwner(), origin);
      if (NS_SUCCEEDED(rv)) {
        notificationStorage->Delete(origin, mID);
      }
    }

    nsCOMPtr<nsIAlertsService> alertService =
      do_GetService(NS_ALERTSERVICE_CONTRACTID);
    if (alertService) {
      if (NS_SUCCEEDED(rv)) { // This is the uninitialized use.
        alertService->CloseAlert(mAlertName, GetPrincipal());
      }
    }

The first comment suggests that we want to always send the alert, so I guess we should just delete the NS_SUCCEEDED check?
Given the initial comment about always wanting to send the close event, we
shouldn't need the NS_SUCCEEDED check.
Attachment #8425443 - Flags: review?(mhenretty)
Here, have a version of the patch without a silly typo.
Attachment #8425443 - Attachment is obsolete: true
Attachment #8425443 - Flags: review?(mhenretty)
Attachment #8426399 - Flags: review?(mhenretty)
Comment on attachment 8426399 [details] [diff] [review]
fix -Wmaybe-uninitialized warning in Notification.cpp

Review of attachment 8426399 [details] [diff] [review]:
-----------------------------------------------------------------

Good catch! Thanks.
Attachment #8426399 - Flags: review?(mhenretty) → review+
https://hg.mozilla.org/mozilla-central/rev/1dfe3f782b41
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Assignee: nobody → nfroyd
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.