Bug 214441

Summary: Fix -Wformat= warnings when passing enum to integer specifiers
Product: WebKit Reporter: Lauro Moura <lmoura>
Component: New BugsAssignee: Lauro Moura <lmoura>
Status: RESOLVED FIXED    
Severity: Normal CC: calvaris, darin, eric.carlson, ews-watchlist, glenn, hta, jer.noble, philipj, pnormand, sergio, tommyw, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch using uint8_t as underlying type none

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>