Bug 167844 - Static Analyzer: Value stored to 'prev' is never read
Summary: Static Analyzer: Value stored to 'prev' is never read
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-04 16:38 PST by Joseph Pecoraro
Modified: 2017-02-04 17:27 PST (History)
6 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (2.40 KB, patch)
2017-02-04 16:39 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2017-02-04 16:38:30 PST
Seeing this static analyzer warning all over JavaScriptCore:

Source/JavaScriptCore/runtime/JSMapIterator.h:60:13: warning: Value stored to 'prev' is never read
            prev = bucket;
            ^      ~~~~~~
Source/JavaScriptCore/runtime/JSSetIterator.h:60:13: warning: Value stored to 'prev' is never read
            prev = bucket;
            ^      ~~~~~~
2 warnings generated.
Comment 1 Joseph Pecoraro 2017-02-04 16:39:17 PST
Created attachment 300646 [details]
[PATCH] Proposed Fix
Comment 2 Saam Barati 2017-02-04 16:47:39 PST
Comment on attachment 300646 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=300646&action=review

r=me

> Source/JavaScriptCore/runtime/JSMapIterator.h:59
> +        while (bucket && bucket->deleted())

Oh wow. Can you add a test that would cause this to infinite loop? I don't think it'd be hard. Perhaps something like this:
- add three entries to a map
- get an iterator to give result of the first entry
- delete all entries
- call next
Comment 3 Radar WebKit Bug Importer 2017-02-04 16:48:21 PST
<rdar://problem/30364994>
Comment 4 Saam Barati 2017-02-04 17:02:46 PST
Comment on attachment 300646 [details]
[PATCH] Proposed Fix

Ignore my previous comment, I misread the diff, thinking that bucket = bucket->next() was only just now added.
Comment 5 WebKit Commit Bot 2017-02-04 17:27:54 PST
Comment on attachment 300646 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 300646

Committed r211675: <http://trac.webkit.org/changeset/211675>
Comment 6 WebKit Commit Bot 2017-02-04 17:27:58 PST
All reviewed patches have been landed.  Closing bug.