diff options
author | Tom Sepez <tsepez@chromium.org> | 2014-09-02 10:27:47 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2014-09-02 10:27:47 -0700 |
commit | 49c41ac846ed685439b3b5ea9c9037bf4bba2365 (patch) | |
tree | bc0a12035e9e0978680f01953e952f3dd65f7d6e /build | |
parent | 9f810e7216c2dbb1a1ab090f1bee4207ecd871c0 (diff) | |
download | pdfium-49c41ac846ed685439b3b5ea9c9037bf4bba2365.tar.xz |
Tidy up opj_ callback functions in fx_codec_jpx_obj.cpp
This is code cleanup rather than bug fixing.
The motivation for this was to fix the casts at line 97 of the original file. These are wrong; you cannot correct via casting a function signature mismatch when passing a function as an argument. In theory, there's no reason to believe that the compiler will pass args in the same manner for a function of type (void*, size_t, void*) as for a function of type (void*, size_t, some_struct*). The cast will suppress the compile error, but you can't be assured the call will work as intended. In practice, it does, since the last architecture where a void* had a different representation than a struct* went extinct in the late 80s.
In the functions themselves, note that we currently bail out if srcData->offset >= srcData->src_size, so the expression
bufferLength = (OPJ_SIZE_T)(srcData->src_size - srcData->offset)
will always be > 0. Hence the check
if(bufferLength <= 0)
is pointless, esp. since bufferLength is a signed type and < 0 makes no sense.
The opj_seek_from_memory() has a bool return value, so returning -1 on error doesn't seem reasonable. Change this to TRUE/FALSE, and return false on seek past end.
If we're truly passing readonly data, then perhaps it makes sense to make the write() function always return -1. I didn't do this.
Lastly, I capitalize "DecodeData" so that it looks like a struct, and change its members to be size_t's to avoid casting back and forth.
R=jun_fang@foxitsoftware.com
Review URL: https://codereview.chromium.org/507273003
Diffstat (limited to 'build')
0 files changed, 0 insertions, 0 deletions