[Static Analysis] DEAD_STORE errors in toolkit/xre/ProfileReset.cpp

RESOLVED FIXED in Firefox 63

Status

()

enhancement
P3
normal
RESOLVED FIXED
11 months ago
11 months ago

People

(Reporter: rbartlensky, Assigned: rbartlensky)

Tracking

unspecified
mozilla63
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox63 fixed)

Details

Attachments

(1 attachment)

toolkit/xre/ProfileReset.cpp:84: error: DEAD_STORE
  The value written to &rv (type int) is never used.
  82.
  83.     nsCOMPtr<nsIStringBundle> sb;
  84. >   rv = sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
  85.     if (!sb) return NS_ERROR_FAILURE;
  86.

toolkit/xre/ProfileReset.cpp:93: error: DEAD_STORE
  The value written to &rv (type int) is never used.
  91.
  92.     static const char* kResetBackupDirectory = "resetBackupDirectory";
  93. >   rv = sb->FormatStringFromName(kResetBackupDirectory, params, 2,
  94.                                   resetBackupDirectoryName);
  95.

rv is certainly not used in any of those cases, could we drop the return value of the function instead of assigning it?
Assignee

Updated

11 months ago
Blocks: infer
Comment hidden (mozreview-request)

Comment 2

11 months ago
mozreview-review
Comment on attachment 8992402 [details]
Bug 1475282: Fix DEAD_STORE issues in ProfileReset.

https://reviewboard.mozilla.org/r/257280/#review264094

Thanks for the cleanup, just a few minor requests.

::: commit-message-2ed15:1
(Diff revision 1)
> +Bug 1475282: Remove unnecessary assingments. r?erahm

nit: 'assignments'. Can you expand this to be a little more explicit, ie "... in ProfileReset"

::: netwerk/mime/nsMIMEHeaderParamImpl.cpp:455
(Diff revision 1)
>    while (*str) {
>      // find name/value
>  
>      const char *nameStart = str;
>      const char *nameEnd = nullptr;
> -    const char *valueStart = str;
> +    const char *valueStart = nullptr;

This should be in a separate bug and a [necko peer](https://wiki.mozilla.org/Modules/Core#Necko) will probably want to review it.

::: toolkit/xre/ProfileReset.cpp:84
(Diff revision 1)
>    // Get the friendly name for the backup directory.
>    nsCOMPtr<nsIStringBundleService> sbs = mozilla::services::GetStringBundleService();
>    if (!sbs) return NS_ERROR_FAILURE;
>  
>    nsCOMPtr<nsIStringBundle> sb;
> -  rv = sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
> +  sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));

Please use `Unused <<` here.

::: toolkit/xre/ProfileReset.cpp:94
(Diff revision 1)
>  
>    nsAutoString resetBackupDirectoryName;
>  
>    static const char* kResetBackupDirectory = "resetBackupDirectory";
> -  rv = sb->FormatStringFromName(kResetBackupDirectory, params, 2,
> +  sb->FormatStringFromName(kResetBackupDirectory, params, 2,
> -                                resetBackupDirectoryName);
> +                           resetBackupDirectoryName);

Please convert this to check `rv` and return on failure.
Attachment #8992402 - Flags: review?(erahm) → review-
Assignee

Comment 3

11 months ago
mozreview-review-reply
Comment on attachment 8992402 [details]
Bug 1475282: Fix DEAD_STORE issues in ProfileReset.

https://reviewboard.mozilla.org/r/257280/#review264094

> This should be in a separate bug and a [necko peer](https://wiki.mozilla.org/Modules/Core#Necko) will probably want to review it.

I am not sure how this slipped in, I have a separate bug for that, thank you for pointing it out!
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 6

11 months ago
mozreview-review
Comment on attachment 8992402 [details]
Bug 1475282: Fix DEAD_STORE issues in ProfileReset.

https://reviewboard.mozilla.org/r/257280/#review264436

Looks good, thanks for the fix.
Attachment #8992402 - Flags: review?(erahm) → review+
Assignee

Updated

11 months ago
Keywords: checkin-needed

Comment 7

11 months ago
Pushed by ebalazs@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bce13e8f7d19
Fix DEAD_STORE issues in ProfileReset. r=erahm
Keywords: checkin-needed

Comment 8

11 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/bce13e8f7d19
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.