[FFmpeg-devel] [PATCH] Fix MSVC warnings about possible value truncation.
pkasting at google.com
Wed Sep 3 01:57:02 CEST 2014
On Tue, Sep 2, 2014 at 4:46 PM, wm4 <nfxjfg at googlemail.com> wrote:
> > I tried not to "just plaster things with casts", but as I said, I was
> > counting on review feedback to help me understand where changes would be
> > fixing real problems or hiding real problems, as opposed to just
> > warnings. The ultimate goal, of both this patch and of enabling these
> > sorts of warnings in general, is to find and fix the real problems, hide
> > problems, and hopefully not cost too much in terms of additional code
> > to "silence" non-problem cases.
> That is perfectly fine. I just wanted to express my opinion that
> silencing compiler warnings for the sake of silencing compiler warnings
> by adding casts is not a good idea. (And in general, compiler warnings
> that produce large amounts of false positives are a bad idea, because
> they just drain developer time, or encourage bad practices.)
I fully agree on all counts.
In the end, if we do decide to enable this warning, we will have to insert
some casts that are clearly safe, e.g.
if (x > INT_MAX)
int y = (int)x;
Indeed, if all of the nontrivial issues are fixed, those sorts of casts are
presumably the majority of the trivial changes we'd have to introduce.
However, on reaching that point, I'll be able to more clearly say, "here
are the patches needed to enable this warning, and here are the functional
code changes we made based on what this warning originally pointed out",
and it will be clearer what the cost/benefit ratio is.
Thanks again for the time you took to review, I appreciate it very much.
More information about the ffmpeg-devel