[Spice-devel] [PATCH] gstreamer-encoder: fix compiler warning
Kevin Pouget
kpouget at redhat.com
Mon Jul 1 12:49:29 UTC 2019
On Mon, Jul 1, 2019 at 2:33 PM Christophe de Dinechin
<christophe.de.dinechin at gmail.com> wrote:
>
>
> Kevin Pouget writes:
>
> > this warning is failing my build, I assume it comes from a new version
> > of the compiler catching the useless call to abs().
>
> Is it useless, or is there a signed/unsigned mismatch?
>
> I suspect the intent is more something like:
>
> abs((int64) (bit_rate - encoder->video_bit_rate))
>
> in order to catch the delta in bitrate in either direction.
good point, a type error makes more sense that a useless abs() call, I
should have thought twice about it!
> >
> > ---
> >
> >> error: taking the absolute value of unsigned type 'uint64_t'
> >> {aka 'long unsigned int'} has no effect [-Werror=absolute-value]
> > ---
> > server/gstreamer-encoder.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> > index 6416b688..dbd4b11d 100644
> > --- a/server/gstreamer-encoder.c
> > +++ b/server/gstreamer-encoder.c
> > @@ -515,7 +515,7 @@ static void set_video_bit_rate(SpiceGstEncoder *encoder, uint64_t bit_rate)
> > encoder->video_bit_rate = bit_rate;
> > set_gstenc_bitrate(encoder);
> >
> > - } else if (abs(bit_rate - encoder->video_bit_rate) > encoder->video_bit_rate * SPICE_GST_VIDEO_BITRATE_MARGIN) {
> > + } else if ((bit_rate - encoder->video_bit_rate) > encoder->video_bit_rate * SPICE_GST_VIDEO_BITRATE_MARGIN) {
> > encoder->video_bit_rate = bit_rate;
> > set_pipeline_changes(encoder, SPICE_GST_VIDEO_PIPELINE_BITRATE);
> > }
>
>
> --
> Cheers,
> Christophe de Dinechin (IRC c3d)
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list