Message ID | CAB0OVGqMzUd1Jr4PMc-8M8ZMCoq+p-SEyBuk7KsU699pU9m+vg@mail.gmail.com |
---|---|
State | Accepted |
Headers | show |
On Fri, Feb 01, 2019 at 10:37:22PM +0100, Carl Eugen Hoyos wrote: > Hi! > > Attached patch fixes a warning with clang. > > Please comment, Carl Eugen > imgutils.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > d1c5f9eb38d36664164f3df0170eb946b6d4f1cd 0001-lavu-imgutils-Use-llabs-for-ptrdiff_t.patch > From 5218c47a129a927dd3de781cdd66d2250955b2cb Mon Sep 17 00:00:00 2001 > From: Carl Eugen Hoyos <ceffmpeg@gmail.com> > Date: Fri, 1 Feb 2019 22:34:51 +0100 > Subject: [PATCH] lavu/imgutils: Use llabs() for ptrdiff_t. > > Fixes a warning with clang: > libavutil/imgutils.c:314:16: warning: absolute value function 'abs' given an argument of type 'ptrdiff_t' (aka 'long') but has parameter > of type 'int' which may cause truncation of value > --- > libavutil/imgutils.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c > index afc73e2..82c26c3 100644 > --- a/libavutil/imgutils.c > +++ b/libavutil/imgutils.c > @@ -311,8 +311,8 @@ static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, > { > if (!dst || !src) > return; > - av_assert0(abs(src_linesize) >= bytewidth); > - av_assert0(abs(dst_linesize) >= bytewidth); > + av_assert0(llabs(src_linesize) >= bytewidth); > + av_assert0(llabs(dst_linesize) >= bytewidth); I think FFABS() is (theoretically) more correct thx [...]
2019-02-01 22:58 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>: > On Fri, Feb 01, 2019 at 10:37:22PM +0100, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch fixes a warning with clang. >> >> Please comment, Carl Eugen > >> imgutils.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> d1c5f9eb38d36664164f3df0170eb946b6d4f1cd >> 0001-lavu-imgutils-Use-llabs-for-ptrdiff_t.patch >> From 5218c47a129a927dd3de781cdd66d2250955b2cb Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos <ceffmpeg@gmail.com> >> Date: Fri, 1 Feb 2019 22:34:51 +0100 >> Subject: [PATCH] lavu/imgutils: Use llabs() for ptrdiff_t. >> >> Fixes a warning with clang: >> libavutil/imgutils.c:314:16: warning: absolute value function 'abs' given >> an argument of type 'ptrdiff_t' (aka 'long') but has parameter >> of type 'int' which may cause truncation of value >> --- >> libavutil/imgutils.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c >> index afc73e2..82c26c3 100644 >> --- a/libavutil/imgutils.c >> +++ b/libavutil/imgutils.c >> @@ -311,8 +311,8 @@ static void image_copy_plane(uint8_t *dst, >> ptrdiff_t dst_linesize, >> { >> if (!dst || !src) >> return; >> - av_assert0(abs(src_linesize) >= bytewidth); >> - av_assert0(abs(dst_linesize) >= bytewidth); >> + av_assert0(llabs(src_linesize) >= bytewidth); >> + av_assert0(llabs(dst_linesize) >= bytewidth); > > I think FFABS() is (theoretically) more correct Applied with FFABS(). Thank you, Carl Eugen
From 5218c47a129a927dd3de781cdd66d2250955b2cb Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos <ceffmpeg@gmail.com> Date: Fri, 1 Feb 2019 22:34:51 +0100 Subject: [PATCH] lavu/imgutils: Use llabs() for ptrdiff_t. Fixes a warning with clang: libavutil/imgutils.c:314:16: warning: absolute value function 'abs' given an argument of type 'ptrdiff_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value --- libavutil/imgutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index afc73e2..82c26c3 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -311,8 +311,8 @@ static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, { if (!dst || !src) return; - av_assert0(abs(src_linesize) >= bytewidth); - av_assert0(abs(dst_linesize) >= bytewidth); + av_assert0(llabs(src_linesize) >= bytewidth); + av_assert0(llabs(dst_linesize) >= bytewidth); for (;height > 0; height--) { memcpy(dst, src, bytewidth); dst += dst_linesize; -- 1.7.10.4