Closed
Bug 836455
Opened 8 years ago
Closed 8 years ago
nptest.cpp:1392:48: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
Categories
(Core :: Plug-ins, defect, P3)
Core
Plug-ins
Tracking
()
RESOLVED
FIXED
People
(Reporter: dholbert, Assigned: dholbert)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
1.19 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
When I try to do a local opt build w/ --enable-warnings-as-errors, I get this build error: { dom/plugins/test/testplugin/nptest.cpp: In function ‘void NPP_StreamAsFile(NPP, NPStream*, const char*)’: plugins/test/testplugin/nptest.cpp:1392:48: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result] } Looks like we need to just sanity-check the return value of fread().
Assignee | ||
Comment 2•8 years ago
|
||
We apparently tried that before, and it triggers linking errors. See bug 754198 comment 9. Might as well just fix this the "right" way (checking the return value), and not worry about those linking errors.
Assignee | ||
Comment 3•8 years ago
|
||
Attachment #708281 -
Flags: review?(benjamin)
Assignee | ||
Comment 4•8 years ago
|
||
Comment on attachment 708281 [details] [diff] [review] fix >- fread(instanceData->fileBuf, 1, size, file); >+ size_t sizeRead = fread(instanceData->fileBuf, 1, size, file); >+ if (sizeRead != size) { Just to decode this, if you don't know fread()'s parameters by heart: We're attempting to read 'size' chunks of data, w/ each chunk having a length of '1', from file, into fileBuf. So, read 'size' bytes. The return value is the number of chunks read -- so, i.e. the number of bytes read, since our chunk size is 1. So if all is well, it should return 'size'.
Updated•8 years ago
|
Attachment #708281 -
Flags: review?(benjamin) → review+
Assignee | ||
Comment 5•8 years ago
|
||
Green linux/mac try run: https://tbpl.mozilla.org/?tree=Try&rev=517774a31e08 Landed: https://hg.mozilla.org/mozilla-central/rev/96c341954032
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Flags: in-testsuite-
OS: Linux → All
Hardware: x86_64 → All
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•