WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
144439
[ARM] Don't compare unsigned chars to EOF (-1)
https://bugs.webkit.org/show_bug.cgi?id=144439
Summary
[ARM] Don't compare unsigned chars to EOF (-1)
Csaba Osztrogonác
Reported
2015-04-30 02:21:50 PDT
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.
Attachments
Patch
(2.78 KB, patch)
2015-04-30 02:39 PDT
,
Csaba Osztrogonác
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Csaba Osztrogonác
Comment 1
2015-04-30 02:36:56 PDT
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.
Csaba Osztrogonác
Comment 2
2015-04-30 02:39:58 PDT
Created
attachment 252048
[details]
Patch
Geoffrey Garen
Comment 3
2015-04-30 10:41:36 PDT
Comment on
attachment 252048
[details]
Patch r=me
Csaba Osztrogonác
Comment 4
2015-05-04 01:43:49 PDT
Comment on
attachment 252048
[details]
Patch Clearing flags on attachment: 252048 Committed
r183740
: <
http://trac.webkit.org/changeset/183740
>
Csaba Osztrogonác
Comment 5
2015-05-04 01:43:57 PDT
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 6
2015-05-11 02:18:47 PDT
***
Bug 104613
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug