Closed Bug 1013263 Opened 10 years ago Closed 10 years ago

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

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: froydnj, Assigned: froydnj)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

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: 10 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.

Attachment

General

Created:
Updated:
Size: