| Summary: | [ARM] Don't compare unsigned chars to EOF (-1) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Csaba Osztrogonác <ossy> | ||||
| Component: | New Bugs | Assignee: | Csaba Osztrogonác <ossy> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | changseok, jungjik.lee, kenneth, laszlo.gombos, ossy, svillar | ||||
| Priority: | P2 | ||||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 108645 | ||||||
| Attachments: |
|
||||||
Just to document, http://trac.webkit.org/changeset/127195 added the Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp change and http://trac.webkit.org/changeset/177216 added (copied) this bug into Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp. Created attachment 252048 [details]
Patch
Comment on attachment 252048 [details]
Patch
r=me
Comment on attachment 252048 [details] Patch Clearing flags on attachment: 252048 Committed r183740: <http://trac.webkit.org/changeset/183740> All reviewed patches have been landed. Closing bug. *** Bug 104613 has been marked as a duplicate of this bug. *** |
build error no1: ----------------- ../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp: In function 'WTF::String WebCore::nextToken(FILE*)': ../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:69:16: error: comparison is always false due to limited range of data type [-Werror=type-limits] if (ch == EOF || (isASCIISpace(ch) && index)) // Break on non-initial ASCII space. ^ cc1plus: all warnings being treated as errors build error no2: ----------------- ../../Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp: In function 'WTF::String WebKit::nextToken(FILE*)': ../../Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp:70:16: error: comparison is always false due to limited range of data type [-Werror=type-limits] if (ch == EOF || (isASCIISpace(ch) && index)) // Break on non-initial ASCII space. ^ cc1plus: all warnings being treated as errors ---- char ch = fgetc(file); ----> fgetc returns an int which is casted to char (signed char on X86_64 and unsigned char on ARM). EOF is defined as -1. (int) If fgetc returns with EOF, it will be 255 after casting unsigned char. When comparing the unsigned char 255 and the int -1, the unsigned char 255 will be casted to int 255 which will never be equal to -1. $ man fgetc [snip] fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error. [snip] The correct fix is to avoid casting the return value of fgetc.