linmaogithub / pdfium

Automatically exported from code.google.com/p/pdfium
0 stars 0 forks source link

FXSYS_strlen return type always requires cast. #153

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/chromium/codesearch#search/&q=%5B%5E)%5DFXSYS_strlen&s
q=package:chromium&type=cs returns 5 places where it's not cast.  Of these, 
most should actually be cast.

https://code.google.com/p/chromium/codesearch#search/&q=%5C)FXSYS_strlen&sq=pack
age:chromium&type=cs where it is.

Probably should include a checked conversion in the definition itself and kill 
the casts.

Original issue reported on code.google.com by tsepez@chromium.org on 6 May 2015 at 7:58

GoogleCodeExporter commented 9 years ago
So now that we have a checked cast in fx_system.h, it include 
third_party/base/numerics/safe_conversions.h basically everywhere, which then 
pulls in third_party/base/logging.h, which has a CHECK() and NOTREACHED() 
macro. This becomes a problem when we include a PDFium .h file in Chromium 
code, where we also have Chromium's base/logging.h.

https://codereview.chromium.org/1132673002/ is one possible solution.

The alternative is to:
- remove the third_party/base/numerics/safe_conversions.h include from 
fx_system.h.
- move all FXSYS_strlen() and FXSYS_wcslen() calls out of header files like 
fx_string.h, and into .cpp files.
- include third_party/base/numerics/safe_conversions.h in all .cpp files that 
call FXSYS_strlen() or FXSYS_wcslen().
- avoid writing a template function in a header file that uses FXSYS_strlen() / 
FXSYS_wcslen().

Original comment by thestig@chromium.org on 8 May 2015 at 4:16