Bug 65807

Summary: Should not use C-style cast in CSSParser.cpp
Product: WebKit Reporter: Kenichi Ishibashi <bashi>
Component: CSSAssignee: Kenichi Ishibashi <bashi>
Status: RESOLVED FIXED    
Severity: Normal CC: hamaji, mrowe, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch V1
none
Patch V2
none
Patch V3 none

Description Kenichi Ishibashi 2011-08-05 19:41:13 PDT
I submitted r92528, which adds a C-style cast to fix build failure.  However, I should have used C++-style cast.
Comment 1 Kenichi Ishibashi 2011-08-05 19:44:39 PDT
Created attachment 103140 [details]
Patch
Comment 2 Kenichi Ishibashi 2011-08-05 19:47:51 PDT
(Cc'ed Mark just in a case)

Hamaji-san, this is a trivial patch. Could you take a look when you have time?

Thanks,
Comment 3 Shinichiro Hamaji 2011-08-05 23:20:52 PDT
Comment on attachment 103140 [details]
Patch

OK
Comment 4 WebKit Review Bot 2011-08-06 03:02:52 PDT
Comment on attachment 103140 [details]
Patch

Clearing flags on attachment: 103140

Committed r92549: <http://trac.webkit.org/changeset/92549>
Comment 5 WebKit Review Bot 2011-08-06 03:02:57 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Alexey Proskuryakov 2011-08-06 18:42:21 PDT
Comment on attachment 103140 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:3287
> +        numSteps = static_cast<int>(min(v->fValue, (double)INT_MAX));

(double) is still a C-style cast.
Comment 7 Kent Tamura 2011-08-07 17:40:22 PDT
Comment on attachment 103140 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:3287
> -        numSteps = (int) min(v->fValue, (double)INT_MAX);
> +        numSteps = static_cast<int>(min(v->fValue, (double)INT_MAX));

You might want to use clampToInteger() in wtf/MathExtras.h.
Comment 8 Kenichi Ishibashi 2011-08-07 23:22:54 PDT
(In reply to comment #7)
> (From update of attachment 103140 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=103140&action=review
> 
> > Source/WebCore/css/CSSParser.cpp:3287
> > -        numSteps = (int) min(v->fValue, (double)INT_MAX);
> > +        numSteps = static_cast<int>(min(v->fValue, (double)INT_MAX));
> 
> You might want to use clampToInteger() in wtf/MathExtras.h.

Thank you for pointing this out. Reopening this bug and will fix it with clampToInteger().
Comment 9 Kenichi Ishibashi 2011-08-07 23:28:08 PDT
Created attachment 103204 [details]
Patch V1
Comment 10 Kent Tamura 2011-08-07 23:35:36 PDT
Comment on attachment 103204 [details]
Patch V1

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

> Source/WebCore/css/CSSParser.cpp:6336
> -            tagValue = static_cast<int>(value->fValue);
> -            if (tagValue < 0)
> -                return false;
> +            tagValue = clampToInteger(value->fValue);

Do you mean clampToPositiveInteger()?
Comment 11 Kent Tamura 2011-08-07 23:37:01 PDT
Comment on attachment 103204 [details]
Patch V1

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

>> Source/WebCore/css/CSSParser.cpp:6336
>> +            tagValue = clampToInteger(value->fValue);
> 
> Do you mean clampToPositiveInteger()?

Is it ok not to return false in a case of negative value?
Comment 12 Kenichi Ishibashi 2011-08-07 23:48:31 PDT
Created attachment 103207 [details]
Patch V2
Comment 13 Kenichi Ishibashi 2011-08-07 23:56:32 PDT
Created attachment 103209 [details]
Patch V3
Comment 14 Kenichi Ishibashi 2011-08-07 23:58:05 PDT
(In reply to comment #11)
> (From update of attachment 103204 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=103204&action=review
> 
> >> Source/WebCore/css/CSSParser.cpp:6336
> >> +            tagValue = clampToInteger(value->fValue);
> > 
> > Do you mean clampToPositiveInteger()?
> 
> Is it ok not to return false in a case of negative value?

Should return false in a case of negative value.  Revised the patch.  Thanks!
Comment 15 Kent Tamura 2011-08-08 00:05:22 PDT
Comment on attachment 103209 [details]
Patch V3

ok
Comment 16 WebKit Review Bot 2011-08-08 01:42:31 PDT
Comment on attachment 103209 [details]
Patch V3

Clearing flags on attachment: 103209

Committed r92588: <http://trac.webkit.org/changeset/92588>
Comment 17 WebKit Review Bot 2011-08-08 01:42:37 PDT
All reviewed patches have been landed.  Closing bug.