From: RĂ©mi Denis-Courmont Date: Sat, 5 Jul 2008 18:37:49 +0000 (+0300) Subject: V4L2: error handling X-Git-Tag: 0.9.0-test2~213 X-Git-Url: https://git.sesse.net/?p=vlc;a=commitdiff_plain;h=e00e13dbbef8d29716b133298f95ffb72079e886 V4L2: error handling confere posix_memalign documentation --- diff --git a/modules/access/v4l2/v4l2.c b/modules/access/v4l2/v4l2.c index 6b7c7e6a13..2b03f911ed 100644 --- a/modules/access/v4l2/v4l2.c +++ b/modules/access/v4l2/v4l2.c @@ -1761,32 +1761,25 @@ static int InitUserP( demux_t *p_demux, int i_fd, unsigned int i_buffer_size ) if( ioctl( i_fd, VIDIOC_REQBUFS, &req ) < 0 ) { msg_Err( p_demux, "device does not support user pointer i/o" ); - goto open_failed; + return VLC_EGENERIC; } p_sys->p_buffers = calloc( 4, sizeof( *p_sys->p_buffers ) ); if( !p_sys->p_buffers ) - { - msg_Err( p_demux, "Out of memory" ); goto open_failed; - } for( p_sys->i_nbuffers = 0; p_sys->i_nbuffers < 4; ++p_sys->i_nbuffers ) { p_sys->p_buffers[p_sys->i_nbuffers].length = i_buffer_size; - posix_memalign( &p_sys->p_buffers[p_sys->i_nbuffers].start, - /* boundary */ i_page_size, i_buffer_size ); - - if( !p_sys->p_buffers[p_sys->i_nbuffers].start ) - { - msg_Err( p_demux, "out of memory" ); + if( posix_memalign( &p_sys->p_buffers[p_sys->i_nbuffers].start, + /* boundary */ i_page_size, i_buffer_size ) ) goto open_failed; - } } return VLC_SUCCESS; open_failed: + free( p_sys->p_buffers ); return VLC_EGENERIC; }