[FFmpeg-devel] [PATCH] oss_audio: check all ioctl() return codes

Michael Niedermayer michaelni at gmx.at
Fri Jul 18 16:54:53 CEST 2014


On Thu, Jul 17, 2014 at 05:59:43PM -0700, Timothy Gu wrote:
> Also uses a macro to simplify.
> 
> Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
> ---
> 
> Found with clang's static analyzer.
> 
> ---
>  libavdevice/oss_audio.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c
> index 734e565..3c5065c 100644
> --- a/libavdevice/oss_audio.c
> +++ b/libavdevice/oss_audio.c
> @@ -87,8 +87,15 @@ static int audio_open(AVFormatContext *s1, int is_output, const char *audio_devi
>  
>      s->frame_size = AUDIO_BLOCK_SIZE;
>  
> +#define CHECK_IOCTL_ERROR(event)                                              \
> +    if (err < 0) {                                                            \
> +        av_log(s1, AV_LOG_ERROR, #event ": %s\n", strerror(errno));         \
> +        goto fail;                                                            \
> +    }
> +

>      /* select format : favour native format */
>      err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
> +    CHECK_IOCTL_ERROR(SNDCTL_DSP_GETFMTS)
>  
>  #if HAVE_BIGENDIAN

i think failure of SNDCTL_DSP_GETFMTS, does not need to lead to
failure of audio_open()
simply trying SNDCTL_DSP_SETFMT with some format in case of
SNDCTL_DSP_GETFMTS fails is better

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140718/27d4e0cc/attachment.asc>


More information about the ffmpeg-devel mailing list