Bug 190907

Summary: Fix clang static analyzer warning in StyleBuilderConverter.h
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: CSSAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, don.olmstead, joepeck, koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1 none

Description David Kilzer (:ddkilzer) 2018-10-25 10:54:05 PDT
Fix the following clang static warning in StyleBuilderConverter.h:
    Value stored to 'autoFlow' during its initialization is never read
Comment 1 David Kilzer (:ddkilzer) 2018-10-25 11:03:07 PDT
Created attachment 353094 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2018-10-25 11:15:52 PDT
This fixes 7 clang static analyzer warnings in WebCore where this code is inlined.
Comment 3 David Kilzer (:ddkilzer) 2018-10-25 12:03:40 PDT
Comment on attachment 353094 [details]
Patch v1

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

> Source/WebCore/css/StyleBuilderConverter.h:1069
>      case CSSValueDense:
>          if (second && second->valueID() == CSSValueColumn)
> -            return AutoFlowColumnDense;
> -        return AutoFlowRowDense;
> +            autoFlow = AutoFlowColumnDense;
> +        else
> +            autoFlow = AutoFlowRowDense;
> +        break;

BTW, if the preference is to change this `switch` statement to use early returns everywhere, I'm happy to do that instead.
Comment 4 Don Olmstead 2018-10-25 16:06:49 PDT
(In reply to David Kilzer (:ddkilzer) from comment #3)
> Comment on attachment 353094 [details]
> Patch v1
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=353094&action=review
> 
> > Source/WebCore/css/StyleBuilderConverter.h:1069
> >      case CSSValueDense:
> >          if (second && second->valueID() == CSSValueColumn)
> > -            return AutoFlowColumnDense;
> > -        return AutoFlowRowDense;
> > +            autoFlow = AutoFlowColumnDense;
> > +        else
> > +            autoFlow = AutoFlowRowDense;
> > +        break;
> 
> BTW, if the preference is to change this `switch` statement to use early
> returns everywhere, I'm happy to do that instead.

Patch looks good to me since its keeping with the style in the rest of the method.

If you're going to do the early return maybe change them to use a ternary?
Comment 5 Antti Koivisto 2018-10-29 10:28:39 PDT
Looks fine, stylistic improvements can be done separately.
Comment 6 WebKit Commit Bot 2018-10-29 10:53:53 PDT
Comment on attachment 353094 [details]
Patch v1

Clearing flags on attachment: 353094

Committed r237557: <https://trac.webkit.org/changeset/237557>
Comment 7 WebKit Commit Bot 2018-10-29 10:53:55 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2018-10-29 13:32:14 PDT
<rdar://problem/45647183>