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 8C58D4AFFB for ; Sun, 26 May 2024 00:22:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 911F768D4C1; Sun, 26 May 2024 03:22:48 +0300 (EEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A10B368C4E3 for ; Sun, 26 May 2024 03:22:41 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BE533FF802 for ; Sun, 26 May 2024 00:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1716682960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RJh4RwqpDhqSXbDy4wx6ZyaBxW3Pgcgbz+1HRlKJIyY=; b=Q8oThxLDVMi+QXFrC6NQ/+gdLhOKAfwUSJvV4ux56zXmx864k/8Ua4wkYiHXKAQfkS0qck 56inHQjQhEL+sNzHE+i7oldVPF5a29p1ZG85n7v27aNmuyK1bK+tM1MOX2TmtVO2r1esff udQ0cQpL7jdDjx4A4YajQGuGtT5cJ96Hl5cm5bOEViZ4Zr0G3n+DxUbFd2NRWrWGNyT/zM F4gHaN+i5FIwNNb21vN0et8b5c1hGWyC+jrpNAsY3Va+NJXRJAaxIeIt8jasls4QpI74mT 2jTIDaSgy+DqbmMlrwPmwEAZKvPBfN1R2chMRwWiDCYkhxT0SbYK3abDYZJctA== Date: Sun, 26 May 2024 02:22:39 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240526002239.GG2821752@pb2> References: MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 01/12] avutil/avassert: Add av_unreachable and av_assume() macros 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="===============4470200368784930675==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4470200368784930675== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="r21wuLfwIlf/vvzy" Content-Disposition: inline --r21wuLfwIlf/vvzy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi On Fri, May 24, 2024 at 11:58:21PM +0200, Andreas Rheinhardt wrote: > Useful to let the compiler and static analyzers know that > something is unreachable without adding an av_assert > (which would be either dead for the compiler or add runtime > overhead) for this. >=20 > Signed-off-by: Andreas Rheinhardt > --- > I can add more macros if it is desired to differentiate between > ASSERT_LEVEL =3D=3D 1 and ASSERT_LEVEL > 1. >=20 > doc/APIchanges | 3 +++ > libavutil/avassert.h | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+) >=20 > diff --git a/doc/APIchanges b/doc/APIchanges > index 60f056b863..5a3ae37999 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-= 03-07 > =20 > API changes, most recent first: > =20 > +2024-05-24 - xxxxxxxxxx - lavu 59.xx.100 - avassert.h > + Add av_unreachable and av_assume() macros. > + > 2024-05-23 - xxxxxxxxxx - lavu 59.20.100 - channel_layout.h > Add av_channel_layout_ambisonic_order(). > =20 > diff --git a/libavutil/avassert.h b/libavutil/avassert.h > index 1895fb7551..41e29c7687 100644 > --- a/libavutil/avassert.h > +++ b/libavutil/avassert.h > @@ -31,6 +31,7 @@ > #ifdef HAVE_AV_CONFIG_H > # include "config.h" > #endif > +#include "attributes.h" > #include "log.h" > #include "macros.h" > =20 > @@ -68,6 +69,38 @@ > #define av_assert2_fpu() ((void)0) > #endif > =20 > +/** > + * Asserts that are used as compiler optimization hints depending > + * upon ASSERT_LEVEL and NBDEBUG. > + * > + * Undefined behaviour occurs if execution reaches a point marked > + * with av_unreachable or if a condition used with av_assume() > + * is false. > + * > + * The condition used with av_assume() should not have side-effects > + * and should be visible to the compiler. > + */ this feels wrong We have 3 assert functions one for security relevant code or other things we always want to check and = not play around one for speed relevant code where we dont want to check in production code.= But may want to do checks if we are debuging. and one for the cases between What is an assert ? Its a statement about a condition that is true unless t= he code is broken. Its never correct to use an assert to check for a condition that= is known to be false for some input. So a assert really already is either A. Check, print, abort or B. undefined if false But if an assert already is "undefined if false" then what you add is not usefull, just add the compiler specific "assume" code to the disabled asser= ts This would also keep the API simpler thx [..] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable --r21wuLfwIlf/vvzy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZlKAzAAKCRBhHseHBAsP qwuAAJ9IBD9GkkGzGiDal4qsxOlQBVPLSACfdZpHCYjeZRa4SCdPQirWprnhW5s= =crja -----END PGP SIGNATURE----- --r21wuLfwIlf/vvzy-- --===============4470200368784930675== 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". --===============4470200368784930675==--