Bug 214441 - Fix -Wformat= warnings when passing enum to integer specifiers
Summary: Fix -Wformat= warnings when passing enum to integer specifiers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Lauro Moura
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-16 20:00 PDT by Lauro Moura
Modified: 2020-07-17 14:29 PDT (History)
13 users (show)

See Also:


Attachments
Patch (3.78 KB, patch)
2020-07-16 20:02 PDT, Lauro Moura
no flags Details | Formatted Diff | Diff
Patch using uint8_t as underlying type (5.31 KB, patch)
2020-07-16 21:31 PDT, Lauro Moura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lauro Moura 2020-07-16 20:00:16 PDT
Fix -Wformat= warnings when passing enum to integer specifiers
Comment 1 Lauro Moura 2020-07-16 20:02:40 PDT
Created attachment 404524 [details]
Patch
Comment 2 Darin Adler 2020-07-16 20:48:19 PDT
Comment on attachment 404524 [details]
Patch

Those all look good. But I wonder if we could use a specific integer type as underlying type for the enumeration instead.
Comment 3 Lauro Moura 2020-07-16 21:31:39 PDT
Created attachment 404535 [details]
Patch using uint8_t as underlying type

The fast/mediastream tests worked as expected here with both enums (WebCore::MediaConstraintType and WebCore::MediaConstraint::DataType) using uint8_t as underlying type, but I'm not sure if there is any uncovered case where it could be an issue.
Comment 4 Darin Adler 2020-07-17 14:01:52 PDT
Comment on attachment 404535 [details]
Patch using uint8_t as underlying type

Seems OK. Awkward to have to write static_cast<int> out each time. Would have thought that an underlying type would help, and there would be some simple format string we could use, but not really sure how that all works with integer type promotion and all the PRIxx stuff.
Comment 5 Lauro Moura 2020-07-17 14:15:08 PDT
Comment on attachment 404535 [details]
Patch using uint8_t as underlying type

I also thought it would end up not needing the casts but both clang and GCC complained.

Thanks for the review.

(Regarding the red bubbles, other builds from the same time also failed in the same tests)
Comment 6 EWS 2020-07-17 14:28:48 PDT
Committed r264534: <https://trac.webkit.org/changeset/264534>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 404535 [details].
Comment 7 Radar WebKit Bug Importer 2020-07-17 14:29:41 PDT
<rdar://problem/65744259>