Added instrumentation on SharedBuffer causes unnecessarily verbose callsites |
|||||
Issue descriptionIn https://codereview.chromium.org/1571233003 SharedBuffer was changed to use some new macros that try to restrict callers to only call with size_t. This is excessively strict for e.g. callers calling with literal values. For example, instead of: getSomeData(buffer, 0) Callers are now doing: getSomeData(buffer, static_cast<size_t>(0)); At the very least, all the STRICT_ARG_TYPEs should probably be changed to ALLOW_NUMERIC_ARG_TYPES_PROMOTABLE_TO. In general, though, the underlying pattern here is problematic. Unsafe type conversions are a potential source of bugs everywhere in the codebase. It doesn't really make sense to annotate one class in a way that tries to prevent one set of unsafe conversions. Annotating all the potential trouble points in the codebase would basically mean annotating everything everywhere to eliminate automatic type conversions. This is clearly infeasible. I think SharedBuffer is not a special snowflake in this regard, and we should remove these annotations for it. Instead, I suggest enabling the compiler warnings we have for unsafe type conversions in e.g. third_party/WebKit (it's not yet feasible to enable them across the whole codebase). This will let the compiler catch these for us across a much broader spectrum of cases, without the need for or downsides of the explicit annotations here. Bug 81439 is the MSVC side of enabling some of these warnings globally; in particular, you'd probably want to enable C4244 and C4267. I know gcc/clang have some warnings for this as well (that I don't think are part of -Wall), but I don't remember the details.
,
Mar 29 2016
Incidentally, MSVC warning C4267 is specifically for conversion from size_t to a smaller type, as you suggest. It's unlikely to be feasible to turn this on globally yet, but we could probably turn it on in all or part of Blink.
,
Mar 29 2016
That is very interesting. MSVC would give us coverage for a 64-bit build and a 32-bit build, which is pretty much all we need.
,
Mar 29 2016
,
Mar 29 2016
I would suggest picking a project or projects you think gives sufficient coverage to catch at least the SharedBuffer issues you saw, and try enabling this warning just for those, plus disable warnings-as-errors for the same projects. Run the change through the trybots (or build locally if you have a Windows machine) and see how many errors you get (hence the disabling warnings-as-errors, so the build doesn't terminate). If the number is reasonably small, fix those and turn the warning on for those projects, and eliminate the changes previously made here. If the number is large, send the list to me for help and we can figure something out.
,
Nov 29 2016
,
Nov 1 2017
,
Jul 25
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by junov@chromium.org
, Mar 29 2016