[FFmpeg-devel] [PATCH] avformat/protocols: check protocol name before foreach

Liu Steven lq at chinaffmpeg.org
Sat Feb 1 01:38:43 EET 2020



> 在 2020年1月31日,下午11:24,Nicolas George <george at nsup.org> 写道:
> 
> Liu Steven (12020-01-31):
>> Just more safe than without check.
> 
> This is a mistake, a common one: this is not safer, it is less: the
> caller has the incorrect assumption that their pointer is not NULL, and
> you are letting them keep it, and even in some extents validating it.
> 
>> I think if it return -EINVAL maybe better than NULL, is it?
> 
> If it was possible (you accurately noticed that not), it would be
> actually worse because it introduce a extra case for something that is
> not supposed to happen in the first place.
> 
> Remember, FFmpeg is programmed in C, not Java or Python: when the
> programmers do something stupid, like dividing by 0 or dereferencing
> NULL, the program crashes: this is the correct behavior.
> 
> Unless there is a useful semantic to give to the NULL case, crashing
> immediately is the right behavior. And saying the user "the protocol you
> specified does not exist" when the issue is they did not specify a
> protocol is not a useful semantic.

There have two way for this:
1. make same with other help message, for example:
StevenLiu:dash StevenLiu$ ./ffmpeg -hide_banner -h demuxer
Unknown format '(null)'.
StevenLiu:dash StevenLiu$
StevenLiu:dash StevenLiu$ ./ffmpeg -hide_banner -h muxer
Unknown format '(null)’.

2. i submmit patch to make demuxer mixer help message same as for unified message.
"the demuxer you specified does not exist”
"the muxer you specified does not exist”

two patch to choose, 1st is this patch, 2nd it the new patch https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200131233704.38591-1-lq@chinaffmpeg.org/

> 
> Regards,
> 
> -- 
>  Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

Steven
Thanks





More information about the ffmpeg-devel mailing list