1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-21 07:24:15 +02:00

Use vlc_close()

This commit is contained in:
Rémi Denis-Courmont 2016-04-22 00:11:43 +03:00
parent 582355f965
commit 8f2e1e57cf
46 changed files with 127 additions and 115 deletions

View File

@ -140,7 +140,9 @@ VLC_API ssize_t net_vaPrintf( vlc_object_t *p_this, int fd, const char *psz_fmt,
# define SHUT_WR 1 # define SHUT_WR 1
# define SHUT_RDWR 2 # define SHUT_RDWR 2
# endif # endif
# define net_Close( fd ) (void)close (fd)
VLC_API int vlc_close(int);
# define net_Close( fd ) (void)vlc_close (fd)
#endif #endif
/* Portable network names/addresses resolution layer */ /* Portable network names/addresses resolution layer */

View File

@ -610,7 +610,7 @@ static int probeFile(const char *psz_name)
ret = VLC_SUCCESS; ret = VLC_SUCCESS;
bailout: bailout:
close(fd); vlc_close(fd);
return ret; return ret;
} }

View File

@ -28,6 +28,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_fs.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
@ -2625,6 +2626,6 @@ void en50221_End( cam_t * p_cam )
} }
} }
close( p_cam->fd ); vlc_close( p_cam->fd );
free( p_cam ); free( p_cam );
} }

View File

@ -215,7 +215,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj)
{ {
msg_Err (obj, "cannot access demultiplexer: %s", msg_Err (obj, "cannot access demultiplexer: %s",
vlc_strerror_c(errno)); vlc_strerror_c(errno));
close (d->dir); vlc_close (d->dir);
free (d); free (d);
return NULL; return NULL;
} }
@ -249,7 +249,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj)
if (d->demux == -1) if (d->demux == -1)
{ {
msg_Err (obj, "cannot access DVR: %s", vlc_strerror_c(errno)); msg_Err (obj, "cannot access DVR: %s", vlc_strerror_c(errno));
close (d->dir); vlc_close (d->dir);
free (d); free (d);
return NULL; return NULL;
} }
@ -261,7 +261,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj)
{ {
d->cam = en50221_Init (obj, ca); d->cam = en50221_Init (obj, ca);
if (d->cam == NULL) if (d->cam == NULL)
close (ca); vlc_close (ca);
} }
else else
msg_Dbg (obj, "conditional access module not available: %s", msg_Dbg (obj, "conditional access module not available: %s",
@ -280,15 +280,15 @@ void dvb_close (dvb_device_t *d)
{ {
for (size_t i = 0; i < MAX_PIDS; i++) for (size_t i = 0; i < MAX_PIDS; i++)
if (d->pids[i].fd != -1) if (d->pids[i].fd != -1)
close (d->pids[i].fd); vlc_close (d->pids[i].fd);
} }
#endif #endif
if (d->cam != NULL) if (d->cam != NULL)
en50221_End (d->cam); en50221_End (d->cam);
if (d->frontend != -1) if (d->frontend != -1)
close (d->frontend); vlc_close (d->frontend);
close (d->demux); vlc_close (d->demux);
close (d->dir); vlc_close (d->dir);
free (d); free (d);
} }
@ -406,7 +406,7 @@ int dvb_add_pid (dvb_device_t *d, uint16_t pid)
param.flags = DMX_IMMEDIATE_START; param.flags = DMX_IMMEDIATE_START;
if (ioctl (fd, DMX_SET_PES_FILTER, &param) < 0) if (ioctl (fd, DMX_SET_PES_FILTER, &param) < 0)
{ {
close (fd); vlc_close (fd);
goto error; goto error;
} }
d->pids[i].fd = fd; d->pids[i].fd = fd;
@ -433,7 +433,7 @@ void dvb_remove_pid (dvb_device_t *d, uint16_t pid)
{ {
if (d->pids[i].pid == pid) if (d->pids[i].pid == pid)
{ {
close (d->pids[i].fd); vlc_close (d->pids[i].fd);
d->pids[i].pid = d->pids[i].fd = -1; d->pids[i].pid = d->pids[i].fd = -1;
return; return;
} }

View File

@ -110,7 +110,7 @@ int FrontendOpen( access_t *p_access )
if( FrontendInfo( p_access ) < 0 ) if( FrontendInfo( p_access ) < 0 )
{ {
close( p_sys->i_frontend_handle ); vlc_close( p_sys->i_frontend_handle );
free( p_frontend ); free( p_frontend );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -165,7 +165,7 @@ int FrontendOpen( access_t *p_access )
{ {
msg_Err( p_access, "requested type %s not supported by %s tuner", msg_Err( p_access, "requested type %s not supported by %s tuner",
psz_expected, psz_real ); psz_expected, psz_real );
close( p_sys->i_frontend_handle ); vlc_close( p_sys->i_frontend_handle );
free( p_frontend ); free( p_frontend );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -202,7 +202,7 @@ void FrontendClose( access_t *p_access )
if( p_sys->p_frontend ) if( p_sys->p_frontend )
{ {
close( p_sys->i_frontend_handle ); vlc_close( p_sys->i_frontend_handle );
free( p_sys->p_frontend ); free( p_sys->p_frontend );
p_sys->p_frontend = NULL; p_sys->p_frontend = NULL;
@ -1216,7 +1216,7 @@ int DMXUnsetFilter( access_t * p_access, int i_fd )
} }
msg_Dbg( p_access, "DMXUnsetFilter: closing demux %d", i_fd ); msg_Dbg( p_access, "DMXUnsetFilter: closing demux %d", i_fd );
close( i_fd ); vlc_close( i_fd );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
@ -1268,5 +1268,5 @@ void DVRClose( access_t * p_access )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
close( p_sys->i_handle ); vlc_close( p_sys->i_handle );
} }

View File

@ -1608,6 +1608,6 @@ static int ProbeDVD( const char *psz_name )
&& GetWLE( &anchor ) == 2 ) && GetWLE( &anchor ) == 2 )
ret = VLC_SUCCESS; /* Found a potential anchor */ ret = VLC_SUCCESS; /* Found a potential anchor */
bailout: bailout:
close( fd ); vlc_close( fd );
return ret; return ret;
} }

View File

@ -180,7 +180,7 @@ static int Open(vlc_object_t *p_this)
if (bind(publicSock, (struct sockaddr *)&publicAddr, sizeof(struct sockaddr_un)) == -1) { if (bind(publicSock, (struct sockaddr *)&publicAddr, sizeof(struct sockaddr_un)) == -1) {
msg_Err(p_access, "bind local socket failed (errno=%d)", errno); msg_Err(p_access, "bind local socket failed (errno=%d)", errno);
close(publicSock); vlc_close(publicSock);
free(p_sys); free(p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -188,7 +188,7 @@ static int Open(vlc_object_t *p_this)
/* we are not expecting more than one connection */ /* we are not expecting more than one connection */
if (listen(publicSock, 1) == -1) { if (listen(publicSock, 1) == -1) {
msg_Err(p_access, "cannot accept connection (errno=%d)", errno); msg_Err(p_access, "cannot accept connection (errno=%d)", errno);
close(publicSock); vlc_close(publicSock);
free(p_sys); free(p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} else { } else {
@ -207,7 +207,7 @@ static int Open(vlc_object_t *p_this)
peerSock = accept(publicSock, (struct sockaddr *)&peerAddr, &peerSockLen); peerSock = accept(publicSock, (struct sockaddr *)&peerAddr, &peerSockLen);
if (peerSock == -1) { if (peerSock == -1) {
msg_Err(p_access, "cannot wait for connection (errno=%d)", errno); msg_Err(p_access, "cannot wait for connection (errno=%d)", errno);
close(publicSock); vlc_close(publicSock);
free(p_sys); free(p_sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -217,7 +217,7 @@ static int Open(vlc_object_t *p_this)
p_sys->eyetvSock = peerSock; p_sys->eyetvSock = peerSock;
/* remove public access */ /* remove public access */
close(publicSock); vlc_close(publicSock);
unlink(publicAddr.sun_path); unlink(publicAddr.sun_path);
} }
return VLC_SUCCESS; return VLC_SUCCESS;
@ -241,7 +241,7 @@ static void Close(vlc_object_t *p_this)
TRUE); TRUE);
msg_Dbg(p_access, "plugin notified"); msg_Dbg(p_access, "plugin notified");
close(p_sys->eyetvSock); vlc_close(p_sys->eyetvSock);
msg_Dbg(p_access, "msg port closed and freed"); msg_Dbg(p_access, "msg port closed and freed");
free(p_sys); free(p_sys);

View File

@ -249,7 +249,7 @@ int FileOpen( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
close (fd); vlc_close (fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -268,7 +268,7 @@ void FileClose (vlc_object_t * p_this)
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
close (p_sys->fd); vlc_close (p_sys->fd);
free (p_sys); free (p_sys);
} }

View File

@ -76,7 +76,7 @@ static void conn_destroy(void)
{ {
conn_shutdown(SHUT_WR); conn_shutdown(SHUT_WR);
vlc_http_conn_release(conn); vlc_http_conn_release(conn);
close(external_fd); vlc_close(external_fd);
} }
static struct vlc_http_stream *stream_open(void) static struct vlc_http_stream *stream_open(void)

View File

@ -113,7 +113,7 @@ static void conn_destroy(void)
{ {
shutdown(external_fd, SHUT_WR); shutdown(external_fd, SHUT_WR);
vlc_http_conn_release(conn); vlc_http_conn_release(conn);
close(external_fd); vlc_close(external_fd);
} }
static struct vlc_http_stream *stream_open(void) static struct vlc_http_stream *stream_open(void)

View File

@ -98,7 +98,7 @@ static void *proxy_thread(void *data)
int canc = vlc_savecancel(); int canc = vlc_savecancel();
proxy_client_process(cfd); proxy_client_process(cfd);
close(cfd); vlc_close(cfd);
connection_count++; connection_count++;
vlc_restorecancel(canc); vlc_restorecancel(canc);
} }
@ -123,7 +123,7 @@ static int server_socket(unsigned *port)
if (bind(fd, (struct sockaddr *)&addr, addrlen) if (bind(fd, (struct sockaddr *)&addr, addrlen)
|| getsockname(fd, (struct sockaddr *)&addr, &addrlen)) || getsockname(fd, (struct sockaddr *)&addr, &addrlen))
{ {
close(fd); vlc_close(fd);
return -1; return -1;
} }
@ -157,7 +157,7 @@ int main(void)
if (listen(lfd, 255)) if (listen(lfd, 255))
{ {
close(lfd); vlc_close(lfd);
return 77; return 77;
} }
@ -173,5 +173,5 @@ int main(void)
vlc_join(th, NULL); vlc_join(th, NULL);
assert(connection_count > 0); assert(connection_count > 0);
free(url); free(url);
close(lfd); vlc_close(lfd);
} }

View File

@ -253,7 +253,7 @@ static int Open( vlc_object_t *p_this )
if( pthread_create( &p_sys->thread, NULL, Demux, p_demux ) ) if( pthread_create( &p_sys->thread, NULL, Demux, p_demux ) )
{ {
close( p_sys->evfd ); vlc_close( p_sys->evfd );
goto error; goto error;
} }
@ -275,7 +275,7 @@ static void Close( vlc_object_t *p_this )
write( p_sys->evfd, &(uint64_t){ 1 }, sizeof (uint64_t)); write( p_sys->evfd, &(uint64_t){ 1 }, sizeof (uint64_t));
pthread_join( p_sys->thread, NULL ); pthread_join( p_sys->thread, NULL );
close( p_sys->evfd ); vlc_close( p_sys->evfd );
free( p_sys ); free( p_sys );
} }
@ -667,7 +667,7 @@ static ssize_t WriteULSysfs( const char *psz_fmt, unsigned int i_link,
return i_fd; return i_fd;
i_ret = write( i_fd, psz_data, strlen(psz_data) + 1 ); i_ret = write( i_fd, psz_data, strlen(psz_data) + 1 );
close( i_fd ); vlc_close( i_fd );
return i_ret; return i_ret;
} }
@ -727,7 +727,7 @@ static int InitCapture( demux_t *p_demux )
if( pfd[1].revents ) if( pfd[1].revents )
{ {
close( p_sys->i_vfd ); vlc_close( p_sys->i_vfd );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
@ -737,10 +737,10 @@ static int InitCapture( demux_t *p_demux )
{ {
msg_Warn( p_demux, "couldn't SDIVIDEO_IOC_RXGETVIDSTATUS: %s", msg_Warn( p_demux, "couldn't SDIVIDEO_IOC_RXGETVIDSTATUS: %s",
vlc_strerror_c(errno) ); vlc_strerror_c(errno) );
close( p_sys->i_vfd ); vlc_close( p_sys->i_vfd );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
close( p_sys->i_vfd ); vlc_close( p_sys->i_vfd );
if ( InitVideo( p_demux ) != VLC_SUCCESS ) if ( InitVideo( p_demux ) != VLC_SUCCESS )
return VLC_EGENERIC; return VLC_EGENERIC;
@ -789,7 +789,7 @@ static int InitCapture( demux_t *p_demux )
msg_Err( p_demux, "unknown sample rate %u", i_rate ); msg_Err( p_demux, "unknown sample rate %u", i_rate );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
close( p_sys->i_afd ); vlc_close( p_sys->i_afd );
if ( InitAudio( p_demux ) != VLC_SUCCESS ) if ( InitAudio( p_demux ) != VLC_SUCCESS )
return VLC_EGENERIC; return VLC_EGENERIC;
@ -925,7 +925,7 @@ static void CloseCapture( demux_t *p_demux )
munmap( p_sys->pp_vbuffers[i], p_sys->i_vbuffer_size ); munmap( p_sys->pp_vbuffers[i], p_sys->i_vbuffer_size );
free( p_sys->pp_vbuffers ); free( p_sys->pp_vbuffers );
#endif #endif
close( p_sys->i_vfd ); vlc_close( p_sys->i_vfd );
if ( p_sys->i_max_channel != -1 ) if ( p_sys->i_max_channel != -1 )
{ {
#ifdef HAVE_MMAP_SDIAUDIO #ifdef HAVE_MMAP_SDIAUDIO
@ -933,7 +933,7 @@ static void CloseCapture( demux_t *p_demux )
munmap( p_sys->pp_abuffers[i], p_sys->i_abuffer_size ); munmap( p_sys->pp_abuffers[i], p_sys->i_abuffer_size );
free( p_sys->pp_abuffers ); free( p_sys->pp_abuffers );
#endif #endif
close( p_sys->i_afd ); vlc_close( p_sys->i_afd );
} }
} }

View File

@ -1765,7 +1765,7 @@ static void CloseCapture( demux_t *p_demux )
StopDecode( p_demux ); StopDecode( p_demux );
for ( unsigned int i = 0; i < p_sys->i_buffers; i++ ) for ( unsigned int i = 0; i < p_sys->i_buffers; i++ )
munmap( p_sys->pp_buffers[i], p_sys->i_buffer_size ); munmap( p_sys->pp_buffers[i], p_sys->i_buffer_size );
close( p_sys->i_fd ); vlc_close( p_sys->i_fd );
free( p_sys->pp_buffers ); free( p_sys->pp_buffers );
} }

View File

@ -164,7 +164,7 @@ static void Close( vlc_object_t * p_this )
access_t *p_access = ( access_t* )p_this; access_t *p_access = ( access_t* )p_this;
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
close ( p_sys->fd ); vlc_close ( p_sys->fd );
if( vlc_unlink( p_access->psz_filepath ) != 0 ) if( vlc_unlink( p_access->psz_filepath ) != 0 )
msg_Err( p_access, "Error deleting file %s, %s", msg_Err( p_access, "Error deleting file %s, %s",
p_access->psz_filepath, vlc_strerror_c(errno) ); p_access->psz_filepath, vlc_strerror_c(errno) );

View File

@ -192,7 +192,8 @@ static void DemuxClose( vlc_object_t *p_this )
demux_t *p_demux = (demux_t *)p_this; demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
if( p_sys->i_fd >= 0 ) close( p_sys->i_fd ); if( p_sys->i_fd >= 0 )
vlc_close( p_sys->i_fd );
if( p_sys->p_block ) block_Release( p_sys->p_block ); if( p_sys->p_block ) block_Release( p_sys->p_block );
free( p_sys ); free( p_sys );
@ -376,7 +377,8 @@ static int OpenAudioDevOss( demux_t *p_demux )
adev_fail: adev_fail:
if( i_fd >= 0 ) close( i_fd ); if( i_fd >= 0 )
vlc_close( i_fd );
return -1; return -1;
} }
@ -432,11 +434,13 @@ static bool ProbeAudioDevOss( demux_t *p_demux, const char *psz_device )
goto open_failed; goto open_failed;
} }
if( i_fd >= 0 ) close( i_fd ); if( i_fd >= 0 )
vlc_close( i_fd );
return true; return true;
open_failed: open_failed:
if( i_fd >= 0 ) close( i_fd ); if( i_fd >= 0 )
vöc_close( i_fd );
return false; return false;
} }

View File

@ -219,7 +219,7 @@ static block_t *Shoot(demux_t *demux)
} }
out: out:
close(fd); vlc_close(fd);
return block; return block;
} }

View File

@ -341,7 +341,7 @@ static void DemuxFile (void *data)
static void CloseFile (demux_sys_t *sys) static void CloseFile (demux_sys_t *sys)
{ {
close (sys->fd); vlc_close (sys->fd);
} }
#ifdef HAVE_SYS_SHM_H #ifdef HAVE_SYS_SHM_H

View File

@ -72,7 +72,7 @@ vlc_v4l2_vbi_t *OpenVBI (demux_t *demux, const char *psz_device)
{ {
msg_Err (demux, "cannot capture VBI data: %s", errstr); msg_Err (demux, "cannot capture VBI data: %s", errstr);
free (errstr); free (errstr);
close (rawfd); vlc_close (rawfd);
goto err; goto err;
} }
@ -155,7 +155,7 @@ void GrabVBI (demux_t *p_demux, vlc_v4l2_vbi_t *vbi)
void CloseVBI (vlc_v4l2_vbi_t *vbi) void CloseVBI (vlc_v4l2_vbi_t *vbi)
{ {
close (vbi_capture_fd (vbi->cap)); vlc_close (vbi_capture_fd (vbi->cap));
vbi_capture_delete (vbi->cap); vbi_capture_delete (vbi->cap);
free (vbi); free (vbi);
} }

View File

@ -248,7 +248,7 @@ void ioctl_Close( vlc_object_t * p_this, vcddev_t *p_vcddev )
DosClose( p_vcddev->hcd ); DosClose( p_vcddev->hcd );
#else #else
if( p_vcddev->i_device_handle != -1 ) if( p_vcddev->i_device_handle != -1 )
close( p_vcddev->i_device_handle ); vlc_close( p_vcddev->i_device_handle );
#endif #endif
free( p_vcddev ); free( p_vcddev );
} }
@ -919,7 +919,7 @@ static void CloseVCDImage( vlc_object_t * p_this, vcddev_t *p_vcddev )
{ {
VLC_UNUSED( p_this ); VLC_UNUSED( p_this );
if( p_vcddev->i_vcdimage_handle != -1 ) if( p_vcddev->i_vcdimage_handle != -1 )
close( p_vcddev->i_vcdimage_handle ); vlc_close( p_vcddev->i_vcdimage_handle );
else else
return; return;

View File

@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this )
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
if( p_sys->fd != -1 ) if( p_sys->fd != -1 )
close( p_sys->fd ); vlc_close( p_sys->fd );
ARRAY_RESET( p_sys->file_sizes ); ARRAY_RESET( p_sys->file_sizes );
if( p_sys->p_meta ) if( p_sys->p_meta )
@ -504,7 +504,7 @@ static bool SwitchFile( access_t *p_access, unsigned i_file )
/* close old file */ /* close old file */
if( p_sys->fd != -1 ) if( p_sys->fd != -1 )
{ {
close( p_sys->fd ); vlc_close( p_sys->fd );
p_sys->fd = -1; p_sys->fd = -1;
} }
@ -545,7 +545,7 @@ error:
" open the file \"%s\" (%s)."), psz_path, vlc_strerror(errno) ); " open the file \"%s\" (%s)."), psz_path, vlc_strerror(errno) );
if( p_sys->fd != -1 ) if( p_sys->fd != -1 )
{ {
close( p_sys->fd ); vlc_close( p_sys->fd );
p_sys->fd = -1; p_sys->fd = -1;
} }
free( psz_path ); free( psz_path );

View File

@ -334,7 +334,7 @@ static int Open( vlc_object_t *p_this )
if (fstat (fd, &st)) if (fstat (fd, &st))
{ {
msg_Err (p_access, "write error: %s", vlc_strerror_c(errno)); msg_Err (p_access, "write error: %s", vlc_strerror_c(errno));
close (fd); vlc_close (fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -374,7 +374,7 @@ static void Close( vlc_object_t * p_this )
{ {
sout_access_out_t *p_access = (sout_access_out_t*)p_this; sout_access_out_t *p_access = (sout_access_out_t*)p_this;
close( (intptr_t)p_access->p_sys ); vlc_close( (intptr_t)p_access->p_sys );
msg_Dbg( p_access, "file access output closed" ); msg_Dbg( p_access, "file access output closed" );
} }

View File

@ -355,7 +355,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
ssize_t keylen = read( keyfd, key, 16 ); ssize_t keylen = read( keyfd, key, 16 );
close( keyfd ); vlc_close( keyfd );
if( keylen < 16 ) if( keylen < 16 )
{ {
msg_Err( p_access, "No key at least 16 octects (you provided %zd), no encryption", keylen ); msg_Err( p_access, "No key at least 16 octects (you provided %zd), no encryption", keylen );
@ -732,7 +732,7 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
} }
close( p_sys->i_handle ); vlc_close( p_sys->i_handle );
p_sys->i_handle = -1; p_sys->i_handle = -1;
if( ! ( us_asprintf( &segment->psz_duration, "%.2f", p_sys->f_seglen ) ) ) if( ! ( us_asprintf( &segment->psz_duration, "%.2f", p_sys->f_seglen ) ) )

View File

@ -237,7 +237,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
sys->format = *fmt; sys->format = *fmt;
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
close (fd); vlc_close (fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -313,7 +313,7 @@ static void Stop (audio_output_t *aout)
int fd = sys->fd; int fd = sys->fd;
ioctl (fd, SNDCTL_DSP_HALT, NULL); ioctl (fd, SNDCTL_DSP_HALT, NULL);
close (fd); vlc_close (fd);
sys->fd = -1; sys->fd = -1;
} }
@ -356,7 +356,7 @@ static int DevicesEnum (audio_output_t *aout)
n++; n++;
} }
out: out:
close (fd); vlc_close (fd);
return n; return n;
} }

View File

@ -204,7 +204,7 @@ static void Delete( vlc_va_t *va, AVCodecContext *avctx )
XCloseDisplay( sys->p_display_x11 ); XCloseDisplay( sys->p_display_x11 );
#endif #endif
#ifdef VLC_VA_BACKEND_DRM #ifdef VLC_VA_BACKEND_DRM
close( sys->drm_fd ); vlc_close( sys->drm_fd );
#endif #endif
free( sys ); free( sys );
} }
@ -478,7 +478,7 @@ error:
#endif #endif
#ifdef VLC_VA_BACKEND_DRM #ifdef VLC_VA_BACKEND_DRM
if( sys->drm_fd != -1 ) if( sys->drm_fd != -1 )
close( sys->drm_fd ); vlc_close( sys->drm_fd );
#endif #endif
free( sys ); free( sys );
return VLC_EGENERIC; return VLC_EGENERIC;

View File

@ -182,8 +182,8 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_this, "Failed to connect to the D-Bus session daemon: %s", msg_Err( p_this, "Failed to connect to the D-Bus session daemon: %s",
error.message ); error.message );
dbus_error_free( &error ); dbus_error_free( &error );
close( p_sys->p_pipe_fds[1] ); vlc_close( p_sys->p_pipe_fds[1] );
close( p_sys->p_pipe_fds[0] ); vlc_close( p_sys->p_pipe_fds[0] );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -280,8 +280,8 @@ error:
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
close( p_sys->p_pipe_fds[1] ); vlc_close( p_sys->p_pipe_fds[1] );
close( p_sys->p_pipe_fds[0] ); vlc_close( p_sys->p_pipe_fds[0] );
free( p_sys ); free( p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
@ -333,8 +333,8 @@ static void Close ( vlc_object_t *p_this )
vlc_array_destroy( p_sys->p_events ); vlc_array_destroy( p_sys->p_events );
vlc_array_destroy( p_sys->p_timeouts ); vlc_array_destroy( p_sys->p_timeouts );
vlc_array_destroy( p_sys->p_watches ); vlc_array_destroy( p_sys->p_watches );
close( p_sys->p_pipe_fds[1] ); vlc_close( p_sys->p_pipe_fds[1] );
close( p_sys->p_pipe_fds[0] ); vlc_close( p_sys->p_pipe_fds[0] );
free( p_sys ); free( p_sys );
} }

View File

@ -167,10 +167,10 @@ static int intf_Eject( vlc_object_t *p_this, const char *psz_device )
# endif # endif
{ {
msg_Err( p_this, "could not eject %s", psz_device ); msg_Err( p_this, "could not eject %s", psz_device );
close( fd ); vlc_close( fd );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
close( fd ); vlc_close( fd );
return VLC_SUCCESS; return VLC_SUCCESS;
#else #else

View File

@ -529,7 +529,7 @@ int tar_open( TAR **t, char *pathname, int oflags )
if( f == NULL ) if( f == NULL )
{ {
fprintf( stderr, "Couldn't gzopen %s\n", pathname ); fprintf( stderr, "Couldn't gzopen %s\n", pathname );
close( fd ); vlc_close( fd );
return -1; return -1;
} }
@ -775,7 +775,7 @@ int gzopen_frontend( const char *pathname, int oflags, int mode )
if( !gzf ) if( !gzf )
{ {
errno = ENOMEM; errno = ENOMEM;
close( fd ); vlc_close( fd );
return -1; return -1;
} }

View File

@ -38,6 +38,7 @@
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
# include <vlc_modules.h> # include <vlc_modules.h>
#endif #endif
#include <vlc_fs.h>
#include <vlc_url.h> #include <vlc_url.h>
static int OpenV4L (vlc_object_t *); static int OpenV4L (vlc_object_t *);
@ -535,9 +536,9 @@ static char *disc_get_mrl (struct udev_device *dev)
val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_STATE"); val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_STATE");
if (val == NULL) if (val == NULL)
{ /* Force probing of the disc in the drive if any. */ { /* Force probing of the disc in the drive if any. */
int fd = open (node, O_RDONLY|O_CLOEXEC); int fd = vlc_open (node, O_RDONLY);
if (fd != -1) if (fd != -1)
close (fd); vlc_close (fd);
return NULL; return NULL;
} }
if (!strcmp (val, "blank")) if (!strcmp (val, "blank"))

View File

@ -178,7 +178,7 @@ static void *Thread (void *data)
msg_Dbg (stream, "compressed stream at EOF"); msg_Dbg (stream, "compressed stream at EOF");
/* Let child process know about EOF */ /* Let child process know about EOF */
p_sys->write_fd = -1; p_sys->write_fd = -1;
close (fd); vlc_close (fd);
return NULL; return NULL;
} }
@ -327,13 +327,13 @@ static int Open (stream_t *stream, const char *path)
ret = VLC_SUCCESS; ret = VLC_SUCCESS;
} }
#endif /* _POSIX_SPAWN < 0 */ #endif /* _POSIX_SPAWN < 0 */
close (uncomp[1]); vlc_close (uncomp[1]);
if (ret != VLC_SUCCESS) if (ret != VLC_SUCCESS)
close (uncomp[0]); vlc_close (uncomp[0]);
} }
close (comp[0]); vlc_close (comp[0]);
if (ret != VLC_SUCCESS) if (ret != VLC_SUCCESS)
close (comp[1]); vlc_close (comp[1]);
} }
if (ret != VLC_SUCCESS) if (ret != VLC_SUCCESS)
@ -363,11 +363,11 @@ static void Close (vlc_object_t *obj)
int status; int status;
vlc_cancel (p_sys->thread); vlc_cancel (p_sys->thread);
close (p_sys->read_fd); vlc_close (p_sys->read_fd);
vlc_join (p_sys->thread, NULL); vlc_join (p_sys->thread, NULL);
if (p_sys->write_fd != -1) if (p_sys->write_fd != -1)
/* Killed before EOF? */ /* Killed before EOF? */
close (p_sys->write_fd); vlc_close (p_sys->write_fd);
msg_Dbg (obj, "waiting for PID %u", (unsigned)p_sys->pid); msg_Dbg (obj, "waiting for PID %u", (unsigned)p_sys->pid);
while (waitpid (p_sys->pid, &status, 0) == -1); while (waitpid (p_sys->pid, &status, 0) == -1);

View File

@ -499,10 +499,10 @@ static int Open(vlc_object_t *obj)
|| mmap(sys->buffer + sys->buffer_size, sys->buffer_size, || mmap(sys->buffer + sys->buffer_size, sys->buffer_size,
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0) == MAP_FAILED) PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0) == MAP_FAILED)
{ {
close(fd); vlc_close(fd);
goto error; goto error;
} }
close(fd); vlc_close(fd);
#elif defined(__OS2__) #elif defined(__OS2__)
/* On OS/2 Warp, page size is 4K, but the smallest chunk size is 64K */ /* On OS/2 Warp, page size is 4K, but the smallest chunk size is 64K */
int page_size = 64 * 1024; int page_size = 64 * 1024;

View File

@ -217,7 +217,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
{ {
msg_Warn( p_filter, "Error on input file: %s", msg_Warn( p_filter, "Error on input file: %s",
vlc_strerror_c(errno) ); vlc_strerror_c(errno) );
close( p_sys->i_inputfd ); vlc_close( p_sys->i_inputfd );
p_sys->i_inputfd = -1; p_sys->i_inputfd = -1;
} }
} }
@ -324,7 +324,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
{ {
msg_Warn( p_filter, "Error on output file: %s", msg_Warn( p_filter, "Error on output file: %s",
vlc_strerror_c(errno) ); vlc_strerror_c(errno) );
close( p_sys->i_outputfd ); vlc_close( p_sys->i_outputfd );
p_sys->i_outputfd = -1; p_sys->i_outputfd = -1;
} }
} }

View File

@ -516,7 +516,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
/* Get framebuffer device information */ /* Get framebuffer device information */
if (ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) { if (ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) {
msg_Err(vd, "cannot get fb info (%s)", vlc_strerror_c(errno)); msg_Err(vd, "cannot get fb info (%s)", vlc_strerror_c(errno));
close(sys->fd); vlc_close(sys->fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
sys->old_info = sys->var_info; sys->old_info = sys->var_info;
@ -535,7 +535,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
if (ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->var_info)) { if (ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->var_info)) {
msg_Err(vd, "cannot set fb info (%s)", vlc_strerror_c(errno)); msg_Err(vd, "cannot set fb info (%s)", vlc_strerror_c(errno));
close(sys->fd); vlc_close(sys->fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -549,7 +549,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
/* Restore fb config */ /* Restore fb config */
ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
close(sys->fd); vlc_close(sys->fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -584,7 +584,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
/* Restore fb config */ /* Restore fb config */
ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
close(sys->fd); vlc_close(sys->fd);
return VLC_ENOMEM; return VLC_ENOMEM;
} }
sys->fb_cmap.start = 0; sys->fb_cmap.start = 0;
@ -620,7 +620,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
/* Restore fb config */ /* Restore fb config */
ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
close(sys->fd); vlc_close(sys->fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -641,7 +641,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
/* Restore fb config */ /* Restore fb config */
ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
close(sys->fd); vlc_close(sys->fd);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
@ -678,7 +678,7 @@ static void CloseDisplay(vout_display_t *vd)
ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
/* Close fb */ /* Close fb */
close(sys->fd); vlc_close(sys->fd);
} }
} }

View File

@ -124,7 +124,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req)
if (ftruncate(fd, length)) if (ftruncate(fd, length))
{ {
msg_Err(vd, "cannot allocate buffers: %s", vlc_strerror_c(errno)); msg_Err(vd, "cannot allocate buffers: %s", vlc_strerror_c(errno));
close(fd); vlc_close(fd);
return NULL; return NULL;
} }
@ -132,7 +132,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req)
if (base == MAP_FAILED) if (base == MAP_FAILED)
{ {
msg_Err(vd, "cannot map buffers: %s", vlc_strerror_c(errno)); msg_Err(vd, "cannot map buffers: %s", vlc_strerror_c(errno));
close(fd); vlc_close(fd);
return NULL; return NULL;
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -140,7 +140,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req)
#endif #endif
struct wl_shm_pool *shm_pool = wl_shm_create_pool(sys->shm, fd, length); struct wl_shm_pool *shm_pool = wl_shm_create_pool(sys->shm, fd, length);
close(fd); vlc_close(fd);
if (shm_pool == NULL) if (shm_pool == NULL)
{ {
munmap(base, length); munmap(base, length);

View File

@ -397,7 +397,7 @@ int config_SaveConfigFile (vlc_object_t *p_this)
msg_Err (p_this, "cannot create configuration file: %s", msg_Err (p_this, "cannot create configuration file: %s",
vlc_strerror_c(errno)); vlc_strerror_c(errno));
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
close (fd); vlc_close (fd);
vlc_mutex_unlock (&lock); vlc_mutex_unlock (&lock);
goto error; goto error;
} }

View File

@ -1110,7 +1110,7 @@ static ts_storage_t *TsStorageNew( const char *psz_tmp_path, int64_t i_tmp_size_
p_storage->p_filew = fdopen( fd, "w+b" ); p_storage->p_filew = fdopen( fd, "w+b" );
if( p_storage->p_filew == NULL ) if( p_storage->p_filew == NULL )
{ {
close( fd ); vlc_close( fd );
vlc_unlink( psz_file ); vlc_unlink( psz_file );
goto error; goto error;
} }

View File

@ -543,13 +543,13 @@ static int ExecuteLoad( vlm_t *p_vlm, const char *psz_path, vlm_message_t **pp_s
|| read( fd, psz_buffer, st.st_size ) < (ssize_t)st.st_size ) || read( fd, psz_buffer, st.st_size ) < (ssize_t)st.st_size )
{ {
free( psz_buffer ); free( psz_buffer );
close( fd ); vlc_close( fd );
*pp_status = vlm_MessageNew( "load", "Read file error" ); *pp_status = vlm_MessageNew( "load", "Read file error" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
close( fd ); vlc_close( fd );
psz_buffer[st.st_size] = '\0'; psz_buffer[st.st_size] = '\0';

View File

@ -442,6 +442,7 @@ us_atof
us_strtod us_strtod
us_strtof us_strtof
us_vasprintf us_vasprintf
vlc_close
vlc_fopen vlc_fopen
utf8_fprintf utf8_fprintf
vlc_loaddir vlc_loaddir

View File

@ -488,6 +488,6 @@ block_t *block_FilePath (const char *path)
return NULL; return NULL;
block_t *block = block_File (fd); block_t *block = block_File (fd);
close (fd); vlc_close (fd);
return block; return block;
} }

View File

@ -365,8 +365,8 @@ static void vlc_poll_i11e_cleanup(void *opaque)
vlc_interrupt_finish(ctx); vlc_interrupt_finish(ctx);
if (fd[1] != fd[0]) if (fd[1] != fd[0])
close(fd[1]); vlc_close(fd[1]);
close(fd[0]); vlc_close(fd[0]);
} }
static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds, static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds,
@ -426,8 +426,8 @@ static int vlc_poll_i11e_inner(struct pollfd *restrict fds, unsigned nfds,
canc = vlc_savecancel(); canc = vlc_savecancel();
if (fd[1] != fd[0]) if (fd[1] != fd[0])
close(fd[1]); vlc_close(fd[1]);
close(fd[0]); vlc_close(fd[0]);
vlc_restorecancel(canc); vlc_restorecancel(canc);
return ret; return ret;
} }

View File

@ -77,7 +77,7 @@ char *vlc_getProxyUrl(const char *url)
posix_spawnattr_destroy(&attr); posix_spawnattr_destroy(&attr);
posix_spawn_file_actions_destroy(&actions); posix_spawn_file_actions_destroy(&actions);
close(fd[1]); vlc_close(fd[1]);
if (pid != -1) if (pid != -1)
{ {
@ -93,7 +93,7 @@ char *vlc_getProxyUrl(const char *url)
} }
while (len < sizeof (buf)); while (len < sizeof (buf));
close(fd[0]); vlc_close(fd[0]);
while (waitpid(pid, &(int){ 0 }, 0) == -1); while (waitpid(pid, &(int){ 0 }, 0) == -1);
if (len >= 9 && !strncasecmp(buf, "direct://", 9)) if (len >= 9 && !strncasecmp(buf, "direct://", 9))
@ -108,7 +108,7 @@ char *vlc_getProxyUrl(const char *url)
/* Parse error: fallback (may be due to missing executable) */ /* Parse error: fallback (may be due to missing executable) */
} }
else else
close(fd[0]); vlc_close(fd[0]);
/* Fallback to environment variable */ /* Fallback to environment variable */
char *var = getenv("http_proxy"); char *var = getenv("http_proxy");

View File

@ -70,7 +70,7 @@ static void vlc_rand_init (void)
ikey[i] = key[i] ^ 0x36; ikey[i] = key[i] ^ 0x36;
} }
close (fd); vlc_close (fd);
} }

View File

@ -93,7 +93,7 @@ FILE *vlc_fopen (const char *filename, const char *mode)
FILE *stream = fdopen (fd, mode); FILE *stream = fdopen (fd, mode);
if (stream == NULL) if (stream == NULL)
close (fd); vlc_close (fd);
return stream; return stream;
} }

View File

@ -29,6 +29,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <vlc_threads.h> #include <vlc_threads.h>
#include <vlc_fs.h>
static void media_parse_ended(const libvlc_event_t *event, void *user_data) static void media_parse_ended(const libvlc_event_t *event, void *user_data)
{ {
@ -217,7 +218,7 @@ static void test_media_subitems(int argc, const char** argv)
assert (media != NULL); assert (media != NULL);
test_media_subitems_media (media, true, true); test_media_subitems_media (media, true, true);
libvlc_media_release (media); libvlc_media_release (media);
close (fd); vlc_close (fd);
#else #else
#warning not testing subitems list via a fd location #warning not testing subitems list via a fd location
#endif #endif

View File

@ -29,6 +29,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_modules.h> #include <vlc_modules.h>
#include <vlc_interrupt.h> #include <vlc_interrupt.h>
#include <vlc_fs.h>
#include <vlc_keystore.h> #include <vlc_keystore.h>
#undef NDEBUG #undef NDEBUG
@ -335,7 +336,7 @@ main(int i_argc, char *ppsz_argv[])
if (i_tmp_fd != -1) if (i_tmp_fd != -1)
{ {
close(i_tmp_fd); vlc_close(i_tmp_fd);
unlink(psz_tmp_path); unlink(psz_tmp_path);
} }
free(ppsz_vlc_argv[0]); free(ppsz_vlc_argv[0]);

View File

@ -132,7 +132,7 @@ static int securepair(vlc_thread_t *th, vlc_tls_t **restrict client,
alpnv[1], alp); alpnv[1], alp);
if (*client == NULL) if (*client == NULL)
{ {
val = close(insecurev[1]); val = vlc_close(insecurev[1]);
assert(val == 0); assert(val == 0);
vlc_join(*th, NULL); vlc_join(*th, NULL);
return -1; return -1;

View File

@ -31,6 +31,7 @@
#include <vlc_keystore.h> #include <vlc_keystore.h>
#include <vlc_dialog.h> #include <vlc_dialog.h>
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_fs.h>
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
@ -330,7 +331,7 @@ main(void)
} }
libvlc_release(p_libvlc); libvlc_release(p_libvlc);
close(i_tmp_fd); vlc_close(i_tmp_fd);
return 0; return 0;
} }