From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C5E8442FC9 for ; Tue, 17 May 2022 13:22:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C465968B327; Tue, 17 May 2022 16:22:40 +0300 (EEST) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8698968B1FC for ; Tue, 17 May 2022 16:22:33 +0300 (EEST) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 6D609100011 for ; Tue, 17 May 2022 13:22:31 +0000 (UTC) Date: Tue, 17 May 2022 15:22:30 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220517132230.GQ396728@pb2> References: <20220516011605.18792-1-michael@niedermayer.cc> <20220516011605.18792-3-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 3/3] avcodec/mpeg4videodec: Replace always true check by assert X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============1015099140872113896==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1015099140872113896== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TSQPSNmi3T91JED+" Content-Disposition: inline --TSQPSNmi3T91JED+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 16, 2022 at 01:05:28PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Maybe helps coverity > > Helps: CID1433771 > >=20 > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/mpeg4videodec.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > >=20 > > diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c > > index e2bde73639..715cb606c9 100644 > > --- a/libavcodec/mpeg4videodec.c > > +++ b/libavcodec/mpeg4videodec.c > > @@ -1981,7 +1981,8 @@ static int mpeg4_decode_studio_block(MpegEncConte= xt *s, int32_t block[64], int n > > return AVERROR_INVALIDDATA; > > j =3D scantable[idx++]; > > block[j] =3D get_xbits(&s->gb, additional_code_len); > > - } else if (group =3D=3D 21) { > > + } else { > > + av_assert2(group =3D=3D 21); > > /* Escape */ > > if (idx > 63) > > return AVERROR_INVALIDDATA; >=20 > This also reminds me of an old attempt of mine to add an AV_UNREACHABLE > macro for such scenarios: > https://github.com/mkver/FFmpeg/commits/unreachable. There are two > reasons why I never sent it to the ML: > a) It uses ASSERT_LEVEL (i.e. with a high ASSERT_LEVEL it degenarates > into an actual assert). But this is only defined internally, so useless > to an API user. Therefore I wonder whether this should be in a public > header (the same issue exists for av_assert1 and av_assert2). for av_assertX to be usefull to a user app, the developer of that app needs to be able to set ASSERT_LEVEL. It would be less useful if it was fixed to the value ffmpeg used in its built The developer should be able to set ASSERT_LEVEL before the include or with -D but some other way could be added too > b) Both Clang and MSVC have something more, namely a > __builtin_assume(cond) resp. __assume(cond). I was unsure whether this > should not be added, too. It could be translated to "if (!(cond)) > __builtin_unreachable()" to GCC, but would be more natural in general. > (Of course, cond must not have any side effects.) [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Nations do behave wisely once they have exhausted all other alternatives.= =20 -- Abba Eban --TSQPSNmi3T91JED+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYoOhkwAKCRBhHseHBAsP q9MqAKCXlj7zwjMSRkJo5tzUOMS7jajtXwCfTcjxKtMi22xhzXJqBMPtlVBTkOo= =LJK/ -----END PGP SIGNATURE----- --TSQPSNmi3T91JED+-- --===============1015099140872113896== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============1015099140872113896==--