Bug 137526

Summary: [Win] Resolve various static analyzer warnings in WebCore
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebCore Misc.Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, mmaxfield, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=192805
Attachments:
Description Flags
Patch dino: review+

Description Brent Fulgham 2014-10-08 10:28:45 PDT
This patch corrects a set of issues found by the MSVC static analyzer.
Comment 1 Brent Fulgham 2014-10-08 10:30:20 PDT
Created attachment 239480 [details]
Patch
Comment 2 Myles C. Maxfield 2014-10-08 10:51:04 PDT
Comment on attachment 239480 [details]
Patch

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

> Source/WebCore/page/SessionIDHash.h:45
> +    static void constructDeletedValue(WebCore::SessionID& slot) { slot = WebCore::SessionID(static_cast<uint64_t>(-2)); }

This is confusing even though I know it's correct. Perhaps this is worth pulling out the -2 into a static const variable, and maybe setting it to something like 0xFFFFFFFFFFFFFFFE
Comment 3 Brent Fulgham 2014-10-08 10:59:12 PDT
(In reply to comment #2)
> (From update of attachment 239480 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=239480&action=review
> 
> > Source/WebCore/page/SessionIDHash.h:45
> > +    static void constructDeletedValue(WebCore::SessionID& slot) { slot = WebCore::SessionID(static_cast<uint64_t>(-2)); }
> 
> This is confusing even though I know it's correct. Perhaps this is worth pulling out the -2 into a static const variable, and maybe setting it to something like 0xFFFFFFFFFFFFFFFE

Yeah, we have a few places where an unsigned value is initialized with a negative number as a sentinel value... I'm not sure what the right thing to do is in this case.
Comment 4 Dean Jackson 2014-10-08 11:01:27 PDT
Comment on attachment 239480 [details]
Patch

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

>> Source/WebCore/page/SessionIDHash.h:45
>> +    static void constructDeletedValue(WebCore::SessionID& slot) { slot = WebCore::SessionID(static_cast<uint64_t>(-2)); }
> 
> This is confusing even though I know it's correct. Perhaps this is worth pulling out the -2 into a static const variable, and maybe setting it to something like 0xFFFFFFFFFFFFFFFE

I agree with Myles that it is weird looking.
Comment 5 Brent Fulgham 2014-10-08 11:33:20 PDT
Committed r174465: <http://trac.webkit.org/changeset/174465>