[FFmpeg-devel] [PATCH] qsv: fix the dangerous macro definitions

Mark Thompson sw at jkqxz.net
Thu Mar 28 00:23:28 EET 2019


On 27/03/2019 10:24, Zhong Li wrote:
> Signed-off-by: Zhong Li <zhong.li at intel.com>
> ---
>  libavcodec/qsv_internal.h | 8 ++++----
>  libavfilter/qsvvpp.h      | 8 ++++----
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index 394c558883..86a5dbad98 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -35,12 +35,12 @@
>  #define QSV_MAX_ENC_PAYLOAD 2       // # of mfxEncodeCtrl payloads supported
>  
>  #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
> -    (MFX_VERSION_MAJOR > (MAJOR) ||         \
> -     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> +    ((MFX_VERSION_MAJOR > (MAJOR) ||         \
> +     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)))

I don't understand why this makes a difference?

Removing the whitespace, I see:

-  (MFX_VERSION_MAJOR > (MAJOR) || MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
+ ((MFX_VERSION_MAJOR > (MAJOR) || MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)))

which looks like you've just added redundant parentheses around the whole thing which already had them?

(Alternative question: what case is this trying to fix?  I could see a problem if the MFX_VERSION_* fields were macros expanding to something containing operators with lower precedence than relationals, but that doesn't change with what you've done here.)

- Mark


More information about the ffmpeg-devel mailing list