[FFmpeg-devel] [PATCH] "assert(a && b)" --> "assert(a); assert(b)" for more precise diagnostics, except for libformat

Michael Niedermayer michael at niedermayer.cc
Mon May 13 11:19:04 EEST 2019


On Sun, May 12, 2019 at 08:24:11AM -0700, Adam Richter wrote:
> This patch separates statements of the form "assert(a && b);" into
> "assert(a);" and "assert(b);", typically involving an assertion
> function like av_assert0.
> 
> This patch covers all of ffmpeg, except for the libavformat, which I
> have already submitted separately.
> 
> I have not tested this patch other than observing that ffmpeg still
> builds without any apparent new complaints, that no complaints in the
> build contain "assert", and that "make fate" seems to succeed.
> 
> Thanks in advance for considering the attached patch.
> 
> Adam

>  fftools/cmdutils.c                    |    3 +-
>  fftools/ffmpeg.c                      |    3 +-
>  libavcodec/4xm.c                      |   12 ++++++---
>  libavcodec/aaccoder_twoloop.h         |    3 +-
>  libavcodec/aacenc.c                   |    3 +-
>  libavcodec/aacenc_quantization_misc.h |    3 +-
>  libavcodec/aacpsy.c                   |    6 +++-
>  libavcodec/ac3enc.c                   |   15 ++++++++----
>  libavcodec/acelp_filters.c            |    3 +-
>  libavcodec/amfenc.c                   |    5 ++--
>  libavcodec/amrnbdec.c                 |    3 +-
>  libavcodec/av1_frame_split_bsf.c      |    3 +-
>  libavcodec/avpacket.c                 |    3 +-
>  libavcodec/cbs.c                      |   42 ++++++++++++++++++++++------------
>  libavcodec/cbs_av1.c                  |    9 ++++---
>  libavcodec/cbs_av1_syntax_template.c  |    3 +-
>  libavcodec/cbs_h2645.c                |   10 ++++----
>  libavcodec/cbs_mpeg2.c                |    4 +--
>  libavcodec/cbs_vp9.c                  |    8 ++++--
>  libavcodec/celp_filters.c             |    3 +-
>  libavcodec/dca_core.c                 |    3 +-
>  libavcodec/decode.c                   |    4 +--
>  libavcodec/dvdsubdec.c                |    3 +-
>  libavcodec/dvenc.c                    |    3 +-
>  libavcodec/dxva2_h264.c               |    3 +-
>  libavcodec/dxva2_hevc.c               |    3 +-
>  libavcodec/dxva2_vp9.c                |    3 +-
>  libavcodec/error_resilience.c         |    3 +-
>  libavcodec/ffv1dec.c                  |    3 +-
>  libavcodec/flacenc.c                  |    6 +++-
>  libavcodec/get_bits.h                 |   35 +++++++++++++++++++---------
>  libavcodec/h263dec.c                  |    3 +-
>  libavcodec/h2645_parse.c              |    6 +++-
>  libavcodec/h264_refs.c                |    3 +-
>  libavcodec/h264_slice.c               |    3 +-
>  libavcodec/h264chroma_template.c      |   20 ++++++++++++----
>  libavcodec/hevc_filter.c              |    6 +++-
>  libavcodec/huffyuv.c                  |    3 +-
>  libavcodec/huffyuvenc.c               |    5 +++-
>  libavcodec/ituh263enc.c               |    3 +-
>  libavcodec/ivi.c                      |    4 ++-
>  libavcodec/jpeg2000dec.c              |    3 +-
>  libavcodec/lclenc.c                   |    3 +-
>  libavcodec/lpc.c                      |    5 ++--
>  libavcodec/lzwenc.c                   |    9 ++++---
>  libavcodec/mips/h264chroma_msa.c      |   31 +++++++++++++++++++------
>  libavcodec/mips/vc1dsp_mmi.c          |   20 ++++++++++++----
>  libavcodec/mjpegdec.c                 |   11 +++++---
>  libavcodec/motion_est.c               |   12 ++++++++-
>  libavcodec/motion_est_template.c      |   10 ++++++--
>  libavcodec/mpeg12.c                   |    3 +-
>  libavcodec/mpeg12enc.c                |    6 +++-
>  libavcodec/mpeg4videoenc.c            |    6 +++-
>  libavcodec/mpegaudiodec_template.c    |    3 +-
>  libavcodec/mpegaudioenc_template.c    |    6 +++-
>  libavcodec/mpegutils.c                |    6 +++-
>  libavcodec/mpegvideo_enc.c            |    9 ++++---
>  libavcodec/mpegvideo_xvmc.c           |    3 +-
>  libavcodec/mpegvideoencdsp.c          |    3 +-
>  libavcodec/mqcenc.c                   |    3 +-
>  libavcodec/put_bits.h                 |    9 ++++---
>  libavcodec/rv34.c                     |    3 +-
>  libavcodec/rv40dsp.c                  |   10 ++++++--
>  libavcodec/sanm.c                     |    3 +-
>  libavcodec/sinewin_tablegen.h         |    3 +-
>  libavcodec/snow.c                     |    3 +-
>  libavcodec/snow.h                     |    3 +-
>  libavcodec/snow_dwt.c                 |    3 +-
>  libavcodec/snowenc.c                  |   14 +++++++----
>  libavcodec/svq1enc.c                  |   24 ++++++++++++-------
>  libavcodec/vaapi_encode.c             |    8 ++++--
>  libavcodec/vaapi_encode_h264.c        |    3 +-
>  libavcodec/vaapi_encode_h265.c        |    6 +++-
>  libavcodec/vaapi_encode_vp9.c         |    4 +--
>  libavcodec/vc1_pred.c                 |    3 +-
>  libavcodec/vc1dsp.c                   |   20 ++++++++++++----
>  libavcodec/videodsp_template.c        |    6 +++-
>  libavcodec/vp9.c                      |    3 +-
>  libavcodec/vp9recon.c                 |    3 +-
>  libavcodec/wmaenc.c                   |    6 +++-
>  libavcodec/x86/videodsp_init.c        |    6 +++-
>  libavdevice/avdevice.c                |    3 +-
>  libavdevice/opengl_enc.c              |    3 +-
>  libavfilter/af_atempo.c               |    9 ++++---
>  libavfilter/af_dynaudnorm.c           |    3 +-
>  libavfilter/af_surround.c             |    8 ++++--
>  libavfilter/asrc_sinc.c               |    3 +-
>  libavfilter/avfilter.c                |    3 +-
>  libavfilter/colorspacedsp_template.c  |    3 +-
>  libavfilter/transform.c               |    6 +++-
>  libavfilter/vf_curves.c               |    7 ++++-
>  libavfilter/vf_fieldmatch.c           |    4 ++-
>  libavfilter/vf_lut3d.c                |    3 +-
>  libavfilter/vf_mergeplanes.c          |    3 +-
>  libavfilter/vf_nlmeans.c              |    4 ++-
>  libavfilter/vsrc_testsrc.c            |    3 +-
>  libavutil/frame.c                     |    6 +++-
>  libavutil/hwcontext_opencl.c          |    4 +--
>  libavutil/integer.c                   |    3 +-
>  libavutil/mathematics.c               |    3 +-
>  libavutil/pixdesc.c                   |   12 +++++++--
>  libavutil/rational.c                  |    3 +-
>  libavutil/softfloat.h                 |    3 +-
>  libswresample/resample.c              |    3 +-
>  libswscale/swscale_unscaled.c         |    7 ++++-
>  libswscale/utils.c                    |    3 +-
>  libswscale/vscale.c                   |    3 +-
>  tests/checkasm/vf_nlmeans.c           |    3 +-
>  108 files changed, 471 insertions(+), 211 deletions(-)
> 725d72dbcf528676417e50eac7e0c55becd05474  0003-assert-a-b-assert-a-assert-b-for-more-precise-diagno.patch
> From f815a2481a19cfd191b9f97e246b307b71d6c790 Mon Sep 17 00:00:00 2001
> From: Adam Richter <adamrichter4 at gmail.com>
> Date: Sun, 12 May 2019 08:02:51 -0700
> Subject: [PATCH] "assert(a && b)" --> "assert(a); assert(b)" for more
>  precise diagnostics, except for libformat.
> 
> This patch separates statements of the form "assert(a && b);" into
> "assert(a);" and "assert(b);", for more precise diagnostics when
> an assertion fails, which can be especially important in cases where
> the problem may not be easily reproducible and save developer time.
> Usually, this involves functions like av_assert0.
> 
> There are a couple of cases that this patch does not change:
> (1) assert conjunctions of the form assert(condition && "string literal
>     to pass to the user as a helpful tip."), and
> (2) assert condjunctions where the first part contained a variable
>     assignment that was used in the second part of the assertion and
>     not outside the assert (so that the variable assignment be elided
>     if the assertion checking omitted).
> 
> This patch covers all of ffmpeg except for libavformat, which was
> covered in a patch that I previously submitted separately.
> 
> These changes build without any new complaints that I noticed, and
> "make fate" succeeds, but I have not otherwise tested them.
> 
> Signed-off-by: Adam Richter <adamrichter4 at gmail.com>
> ---
>  fftools/cmdutils.c                    |  3 +-
>  fftools/ffmpeg.c                      |  3 +-
>  libavcodec/4xm.c                      | 12 +++++---
>  libavcodec/aaccoder_twoloop.h         |  3 +-
>  libavcodec/aacenc.c                   |  3 +-
>  libavcodec/aacenc_quantization_misc.h |  3 +-
>  libavcodec/aacpsy.c                   |  6 ++--
>  libavcodec/ac3enc.c                   | 15 ++++++----
>  libavcodec/acelp_filters.c            |  3 +-
>  libavcodec/amfenc.c                   |  5 ++--
>  libavcodec/amrnbdec.c                 |  3 +-
>  libavcodec/av1_frame_split_bsf.c      |  3 +-
>  libavcodec/avpacket.c                 |  3 +-
>  libavcodec/cbs.c                      | 42 ++++++++++++++++++---------
>  libavcodec/cbs_av1.c                  |  9 ++++--
>  libavcodec/cbs_av1_syntax_template.c  |  3 +-
>  libavcodec/cbs_h2645.c                | 10 ++++---
>  libavcodec/cbs_mpeg2.c                |  4 +--
>  libavcodec/cbs_vp9.c                  |  8 +++--
>  libavcodec/celp_filters.c             |  3 +-
>  libavcodec/dca_core.c                 |  3 +-
>  libavcodec/decode.c                   |  4 +--
>  libavcodec/dvdsubdec.c                |  3 +-
>  libavcodec/dvenc.c                    |  3 +-
>  libavcodec/dxva2_h264.c               |  3 +-
>  libavcodec/dxva2_hevc.c               |  3 +-
>  libavcodec/dxva2_vp9.c                |  3 +-
>  libavcodec/error_resilience.c         |  3 +-
>  libavcodec/ffv1dec.c                  |  3 +-
>  libavcodec/flacenc.c                  |  6 ++--
>  libavcodec/get_bits.h                 | 35 +++++++++++++++-------
>  libavcodec/h263dec.c                  |  3 +-
>  libavcodec/h2645_parse.c              |  6 ++--
>  libavcodec/h264_refs.c                |  3 +-
>  libavcodec/h264_slice.c               |  3 +-
>  libavcodec/h264chroma_template.c      | 20 ++++++++++---
>  libavcodec/hevc_filter.c              |  6 ++--
>  libavcodec/huffyuv.c                  |  3 +-
>  libavcodec/huffyuvenc.c               |  5 +++-
>  libavcodec/ituh263enc.c               |  3 +-
>  libavcodec/ivi.c                      |  4 ++-
>  libavcodec/jpeg2000dec.c              |  3 +-
>  libavcodec/lclenc.c                   |  3 +-
>  libavcodec/lpc.c                      |  5 ++--
>  libavcodec/lzwenc.c                   |  9 ++++--
>  libavcodec/mips/h264chroma_msa.c      | 31 +++++++++++++++-----
>  libavcodec/mips/vc1dsp_mmi.c          | 20 ++++++++++---
>  libavcodec/mjpegdec.c                 | 11 ++++---
>  libavcodec/motion_est.c               | 12 ++++++--
>  libavcodec/motion_est_template.c      | 10 +++++--
>  libavcodec/mpeg12.c                   |  3 +-
>  libavcodec/mpeg12enc.c                |  6 ++--
>  libavcodec/mpeg4videoenc.c            |  6 ++--
>  libavcodec/mpegaudiodec_template.c    |  3 +-
>  libavcodec/mpegaudioenc_template.c    |  6 ++--
>  libavcodec/mpegutils.c                |  6 ++--
>  libavcodec/mpegvideo_enc.c            |  9 ++++--
>  libavcodec/mpegvideo_xvmc.c           |  3 +-
>  libavcodec/mpegvideoencdsp.c          |  3 +-
>  libavcodec/mqcenc.c                   |  3 +-
>  libavcodec/put_bits.h                 |  9 ++++--
>  libavcodec/rv34.c                     |  3 +-
>  libavcodec/rv40dsp.c                  | 10 +++++--
>  libavcodec/sanm.c                     |  3 +-
>  libavcodec/sinewin_tablegen.h         |  3 +-
>  libavcodec/snow.c                     |  3 +-
>  libavcodec/snow.h                     |  3 +-
>  libavcodec/snow_dwt.c                 |  3 +-
>  libavcodec/snowenc.c                  | 14 +++++----
>  libavcodec/svq1enc.c                  | 24 ++++++++++-----
>  libavcodec/vaapi_encode.c             |  8 +++--
>  libavcodec/vaapi_encode_h264.c        |  3 +-
>  libavcodec/vaapi_encode_h265.c        |  6 ++--
>  libavcodec/vaapi_encode_vp9.c         |  4 +--
>  libavcodec/vc1_pred.c                 |  3 +-
>  libavcodec/vc1dsp.c                   | 20 ++++++++++---
>  libavcodec/videodsp_template.c        |  6 ++--
>  libavcodec/vp9.c                      |  3 +-
>  libavcodec/vp9recon.c                 |  3 +-
>  libavcodec/wmaenc.c                   |  6 ++--
>  libavcodec/x86/videodsp_init.c        |  6 ++--
>  libavdevice/avdevice.c                |  3 +-
>  libavdevice/opengl_enc.c              |  3 +-
>  libavfilter/af_atempo.c               |  9 +++---
>  libavfilter/af_dynaudnorm.c           |  3 +-
>  libavfilter/af_surround.c             |  8 +++--
>  libavfilter/asrc_sinc.c               |  3 +-
>  libavfilter/avfilter.c                |  3 +-
>  libavfilter/colorspacedsp_template.c  |  3 +-
>  libavfilter/transform.c               |  6 ++--
>  libavfilter/vf_curves.c               |  7 +++--
>  libavfilter/vf_fieldmatch.c           |  4 ++-
>  libavfilter/vf_lut3d.c                |  3 +-
>  libavfilter/vf_mergeplanes.c          |  3 +-
>  libavfilter/vf_nlmeans.c              |  4 ++-
>  libavfilter/vsrc_testsrc.c            |  3 +-
>  libavutil/frame.c                     |  6 ++--
>  libavutil/hwcontext_opencl.c          |  4 +--
>  libavutil/integer.c                   |  3 +-
>  libavutil/mathematics.c               |  3 +-
>  libavutil/pixdesc.c                   | 12 ++++++--
>  libavutil/rational.c                  |  3 +-
>  libavutil/softfloat.h                 |  3 +-
>  libswresample/resample.c              |  3 +-
>  libswscale/swscale_unscaled.c         |  7 +++--
>  libswscale/utils.c                    |  3 +-
>  libswscale/vscale.c                   |  3 +-
>  tests/checkasm/vf_nlmeans.c           |  3 +-
>  108 files changed, 471 insertions(+), 211 deletions(-)

patch looks good to me, but others maybe dislike it (so i am not
applying it, just saying that from my point of view the change
is fine)

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190513/04ad2a1f/attachment.sig>


More information about the ffmpeg-devel mailing list