Bug 225593 - Remove unnecessary comparison and casting in GlyphBuffer.h
Summary: Remove unnecessary comparison and casting in GlyphBuffer.h
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Trivial
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-10 05:54 PDT by Eleni Maria Stea
Modified: 2022-03-14 08:56 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.48 KB, patch)
2021-05-10 06:03 PDT, Eleni Maria Stea
sam: review-
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eleni Maria Stea 2021-05-10 05:54:09 PDT
Variable result in checkedStringOffsetAt in GlyphBuffer.h is unsigned. Therefore, it can never be < 0 and static cast to unsigned before comparison is unnecessary.
Comment 1 Eleni Maria Stea 2021-05-10 06:03:39 PDT
Created attachment 428166 [details]
Patch
Comment 2 Eleni Maria Stea 2021-05-10 07:17:18 PDT
I had only built this on Linux/GCC and received warnings about unsigned which were fixed when I removed the cast. But it seems that it was required (EWS failure) above.

This bug report is invalid.
Comment 3 Sam Weinig 2021-05-10 09:05:05 PDT
Comment on attachment 428166 [details]
Patch

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

> Source/WebCore/platform/graphics/GlyphBuffer.h:81
> -        if (result < 0 || static_cast<unsigned>(result) >= stringLength)
> +        if (result >= stringLength)

This is not true on all platforms. When USE(CG) is true, GlyphBufferStringOffset (the type of result) is CFIndex which is 'signed long'.

The real issue that we should try to solve is using the same types here if we can.
Comment 4 Sam Weinig 2021-05-10 09:05:36 PDT
Re-opening, I think we should at least see if we can converge on the same type.
Comment 5 Sam Weinig 2021-05-10 09:08:19 PDT Comment hidden (obsolete)
Comment 6 Sam Weinig 2021-05-10 09:08:52 PDT
Myles, can you think of anything good we can do to make it so non-CG ports and CG ports can use these types consistently?
Comment 7 Eleni Maria Stea 2021-05-10 11:57:21 PDT
I agree, sorry I closed it. Besides I think that at least the part where we check it's < 0 should be removed because we always use unsigned: either unsigned int or unsigned long
Comment 8 e.barg0089 2021-05-10 13:23:36 PDT
Comment on attachment 428166 [details]
Patch

Remove bug
Comment 9 e.barg0089 2021-05-10 13:25:22 PDT
Comment on attachment 428166 [details]
Patch

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

> Source/WebCore/platform/graphics/GlyphBuffer.h:79
>      {

Revert all properties
Comment 10 Sam Weinig 2021-05-10 14:24:05 PDT
Well, as I said above, USE(CG) uses CFIndex which is signed (either signed long or signed long long).
Comment 11 Radar WebKit Bug Importer 2022-03-14 08:56:39 PDT
<rdar://problem/90248625>