Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [RFC] Remove use of av_uninit
@ 2025-04-11 10:32 Zhao Zhili
  2025-04-11 11:24 ` Nicolas George
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Zhili @ 2025-04-11 10:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Background:

1. There is a av_uninit macro which suppress uninitialized variable warning

#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
#    define av_uninit(x) x=x
#else
#    define av_uninit(x) x
#endif

2. Declaration after statement coding style is allowed now

3. There is a crash fixed by ab792634197 which is related to av_uninit, and I have confronted it again recently

commit ab792634197e364ca1bb194f9abe36836e42f12d
Date:   Mon Oct 18 12:31:38 2021 +0300

    seek: Fix crashes in ff_seek_frame_binary if built with latest Clang 14

------------------------------------------------------------------------
What I suggests:

1. Deprecated av_uninit and removed it in the future

2. Remove usage in current code

3. When there is uninitiated variable warning

a. Declare variable when need if it’s possible, so it can be initiated at the same time
b. Use valid default value if there is
c. If there is no valid default value, or you think the variable never being used uninitialized, assign an insane value and add assert before use if

av_assert1(value != invalid_value);

Note:
1. I’m not suggesting always initialize variables
2. I’m suggesting remove av_uninit, until someone has an idea to make it more useful and less harmful.

Let’s ensure we stay on track and maintain focus on the central issue.

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [RFC] Remove use of av_uninit
  2025-04-11 10:32 [FFmpeg-devel] [RFC] Remove use of av_uninit Zhao Zhili
@ 2025-04-11 11:24 ` Nicolas George
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas George @ 2025-04-11 11:24 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Zhao Zhili (HE12025-04-11):
> Background:
> 
> 1. There is a av_uninit macro which suppress uninitialized variable warning
> 
> #if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
> #    define av_uninit(x) x=x
> #else
> #    define av_uninit(x) x
> #endif

Yes.

> 2. Declaration after statement coding style is allowed now

I fail to see the connection. Oh, reading further, I guess you think
moving the declaration of the variable will be enough to let the
compiler know the variable is not used and silence the warning. I
strongly doubt it might have that effect.

> 3. There is a crash fixed by ab792634197 which is related to av_uninit, and I have confronted it again recently

So, what does it prove? It proves that 16 years ago (e658657528d) Diego
silenced a warning without making sure the logic itself was sound.

Which is exactly what you are proposing to do right now in a different
way.

> 1. Deprecated av_uninit and removed it in the future
> 
> 2. Remove usage in current code

Not before or without 3.

> 3. When there is uninitiated variable warning
> 
> a. Declare variable when need if it’s possible, so it can be initiated at the same time
> b. Use valid default value if there is
> c. If there is no valid default value, or you think the variable never being used uninitialized, assign an insane value and add assert before use if
> 
> av_assert1(value != invalid_value);

Are you volunteering to do that huge work?

Running FATE with valgrind and no optimization seems like a quicker way
of finding the real bugs.

Regards,

-- 
  Nicolas George
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-11 11:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11 10:32 [FFmpeg-devel] [RFC] Remove use of av_uninit Zhao Zhili
2025-04-11 11:24 ` Nicolas George

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git