From 8f2e1e57cf9838ef9b1d17d4c5b7d3ce21e9339c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Fri, 22 Apr 2016 00:11:43 +0300 Subject: [PATCH] Use vlc_close() --- include/vlc_network.h | 4 +++- modules/access/bluray.c | 2 +- modules/access/dtv/en50221.c | 3 ++- modules/access/dtv/linux.c | 18 +++++++++--------- modules/access/dvb/linux_dvb.c | 10 +++++----- modules/access/dvdnav.c | 2 +- modules/access/eyetv.m | 10 +++++----- modules/access/file.c | 4 ++-- modules/access/http/h1conn_test.c | 2 +- modules/access/http/h2conn_test.c | 2 +- modules/access/http/tunnel_test.c | 8 ++++---- modules/access/linsys/linsys_hdsdi.c | 18 +++++++++--------- modules/access/linsys/linsys_sdi.c | 2 +- modules/access/mtp.c | 2 +- modules/access/oss.c | 12 ++++++++---- modules/access/screen/wayland.c | 2 +- modules/access/shm.c | 2 +- modules/access/v4l2/vbi.c | 4 ++-- modules/access/vcd/cdrom.c | 4 ++-- modules/access/vdr.c | 6 +++--- modules/access_output/file.c | 4 ++-- modules/access_output/livehttp.c | 4 ++-- modules/audio_output/oss.c | 6 +++--- modules/codec/avcodec/vaapi.c | 4 ++-- modules/control/dbus/dbus.c | 12 ++++++------ modules/gui/eject.c | 4 ++-- modules/gui/skins2/src/theme_loader.cpp | 4 ++-- modules/services_discovery/udev.c | 5 +++-- modules/stream_filter/decomp.c | 14 +++++++------- modules/stream_filter/prefetch.c | 4 ++-- .../dynamicoverlay/dynamicoverlay.c | 4 ++-- modules/video_output/fb.c | 14 +++++++------- modules/video_output/wayland/shm.c | 6 +++--- src/config/file.c | 2 +- src/input/es_out_timeshift.c | 2 +- src/input/vlmshell.c | 4 ++-- src/libvlccore.sym | 1 + src/misc/block.c | 2 +- src/misc/interrupt.c | 8 ++++---- src/posix/netconf.c | 6 +++--- src/posix/rand.c | 2 +- src/text/filesystem.c | 2 +- test/libvlc/media.c | 3 ++- test/modules/keystore/test.c | 3 ++- test/modules/misc/tls.c | 2 +- test/src/misc/keystore.c | 3 ++- 46 files changed, 127 insertions(+), 115 deletions(-) diff --git a/include/vlc_network.h b/include/vlc_network.h index bfb4274470..8779ad29de 100644 --- a/include/vlc_network.h +++ b/include/vlc_network.h @@ -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_RDWR 2 # endif -# define net_Close( fd ) (void)close (fd) + +VLC_API int vlc_close(int); +# define net_Close( fd ) (void)vlc_close (fd) #endif /* Portable network names/addresses resolution layer */ diff --git a/modules/access/bluray.c b/modules/access/bluray.c index b5ff919111..cb4c56cd5e 100644 --- a/modules/access/bluray.c +++ b/modules/access/bluray.c @@ -610,7 +610,7 @@ static int probeFile(const char *psz_name) ret = VLC_SUCCESS; bailout: - close(fd); + vlc_close(fd); return ret; } diff --git a/modules/access/dtv/en50221.c b/modules/access/dtv/en50221.c index 69cefa2451..cff984a7b0 100644 --- a/modules/access/dtv/en50221.c +++ b/modules/access/dtv/en50221.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -2625,6 +2626,6 @@ void en50221_End( cam_t * p_cam ) } } - close( p_cam->fd ); + vlc_close( p_cam->fd ); free( p_cam ); } diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c index a8ea5f1375..f0a7d7dbac 100644 --- a/modules/access/dtv/linux.c +++ b/modules/access/dtv/linux.c @@ -215,7 +215,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj) { msg_Err (obj, "cannot access demultiplexer: %s", vlc_strerror_c(errno)); - close (d->dir); + vlc_close (d->dir); free (d); return NULL; } @@ -249,7 +249,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj) if (d->demux == -1) { msg_Err (obj, "cannot access DVR: %s", vlc_strerror_c(errno)); - close (d->dir); + vlc_close (d->dir); free (d); return NULL; } @@ -261,7 +261,7 @@ dvb_device_t *dvb_open (vlc_object_t *obj) { d->cam = en50221_Init (obj, ca); if (d->cam == NULL) - close (ca); + vlc_close (ca); } else 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++) if (d->pids[i].fd != -1) - close (d->pids[i].fd); + vlc_close (d->pids[i].fd); } #endif if (d->cam != NULL) en50221_End (d->cam); if (d->frontend != -1) - close (d->frontend); - close (d->demux); - close (d->dir); + vlc_close (d->frontend); + vlc_close (d->demux); + vlc_close (d->dir); free (d); } @@ -406,7 +406,7 @@ int dvb_add_pid (dvb_device_t *d, uint16_t pid) param.flags = DMX_IMMEDIATE_START; if (ioctl (fd, DMX_SET_PES_FILTER, ¶m) < 0) { - close (fd); + vlc_close (fd); goto error; } 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) { - close (d->pids[i].fd); + vlc_close (d->pids[i].fd); d->pids[i].pid = d->pids[i].fd = -1; return; } diff --git a/modules/access/dvb/linux_dvb.c b/modules/access/dvb/linux_dvb.c index 8bc68e981b..f2e4f94d57 100644 --- a/modules/access/dvb/linux_dvb.c +++ b/modules/access/dvb/linux_dvb.c @@ -110,7 +110,7 @@ int FrontendOpen( access_t *p_access ) if( FrontendInfo( p_access ) < 0 ) { - close( p_sys->i_frontend_handle ); + vlc_close( p_sys->i_frontend_handle ); free( p_frontend ); 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", psz_expected, psz_real ); - close( p_sys->i_frontend_handle ); + vlc_close( p_sys->i_frontend_handle ); free( p_frontend ); return VLC_EGENERIC; } @@ -202,7 +202,7 @@ void FrontendClose( access_t *p_access ) if( p_sys->p_frontend ) { - close( p_sys->i_frontend_handle ); + vlc_close( p_sys->i_frontend_handle ); free( p_sys->p_frontend ); 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 ); - close( i_fd ); + vlc_close( i_fd ); return VLC_SUCCESS; } @@ -1268,5 +1268,5 @@ void DVRClose( access_t * p_access ) { access_sys_t *p_sys = p_access->p_sys; - close( p_sys->i_handle ); + vlc_close( p_sys->i_handle ); } diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c index 884c04ffd7..e1b6adea13 100644 --- a/modules/access/dvdnav.c +++ b/modules/access/dvdnav.c @@ -1608,6 +1608,6 @@ static int ProbeDVD( const char *psz_name ) && GetWLE( &anchor ) == 2 ) ret = VLC_SUCCESS; /* Found a potential anchor */ bailout: - close( fd ); + vlc_close( fd ); return ret; } diff --git a/modules/access/eyetv.m b/modules/access/eyetv.m index 502338a27b..5655d7ecce 100644 --- a/modules/access/eyetv.m +++ b/modules/access/eyetv.m @@ -180,7 +180,7 @@ static int Open(vlc_object_t *p_this) if (bind(publicSock, (struct sockaddr *)&publicAddr, sizeof(struct sockaddr_un)) == -1) { msg_Err(p_access, "bind local socket failed (errno=%d)", errno); - close(publicSock); + vlc_close(publicSock); free(p_sys); return VLC_EGENERIC; } @@ -188,7 +188,7 @@ static int Open(vlc_object_t *p_this) /* we are not expecting more than one connection */ if (listen(publicSock, 1) == -1) { msg_Err(p_access, "cannot accept connection (errno=%d)", errno); - close(publicSock); + vlc_close(publicSock); free(p_sys); return VLC_EGENERIC; } else { @@ -207,7 +207,7 @@ static int Open(vlc_object_t *p_this) peerSock = accept(publicSock, (struct sockaddr *)&peerAddr, &peerSockLen); if (peerSock == -1) { msg_Err(p_access, "cannot wait for connection (errno=%d)", errno); - close(publicSock); + vlc_close(publicSock); free(p_sys); return VLC_EGENERIC; } @@ -217,7 +217,7 @@ static int Open(vlc_object_t *p_this) p_sys->eyetvSock = peerSock; /* remove public access */ - close(publicSock); + vlc_close(publicSock); unlink(publicAddr.sun_path); } return VLC_SUCCESS; @@ -241,7 +241,7 @@ static void Close(vlc_object_t *p_this) TRUE); msg_Dbg(p_access, "plugin notified"); - close(p_sys->eyetvSock); + vlc_close(p_sys->eyetvSock); msg_Dbg(p_access, "msg port closed and freed"); free(p_sys); diff --git a/modules/access/file.c b/modules/access/file.c index 7dafeb21e5..349b9b9057 100644 --- a/modules/access/file.c +++ b/modules/access/file.c @@ -249,7 +249,7 @@ int FileOpen( vlc_object_t *p_this ) return VLC_SUCCESS; error: - close (fd); + vlc_close (fd); return VLC_EGENERIC; } @@ -268,7 +268,7 @@ void FileClose (vlc_object_t * p_this) access_sys_t *p_sys = p_access->p_sys; - close (p_sys->fd); + vlc_close (p_sys->fd); free (p_sys); } diff --git a/modules/access/http/h1conn_test.c b/modules/access/http/h1conn_test.c index 62b64a38e8..4e3b512b7a 100644 --- a/modules/access/http/h1conn_test.c +++ b/modules/access/http/h1conn_test.c @@ -76,7 +76,7 @@ static void conn_destroy(void) { conn_shutdown(SHUT_WR); vlc_http_conn_release(conn); - close(external_fd); + vlc_close(external_fd); } static struct vlc_http_stream *stream_open(void) diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c index e1108beb6a..bff6ac87f0 100644 --- a/modules/access/http/h2conn_test.c +++ b/modules/access/http/h2conn_test.c @@ -113,7 +113,7 @@ static void conn_destroy(void) { shutdown(external_fd, SHUT_WR); vlc_http_conn_release(conn); - close(external_fd); + vlc_close(external_fd); } static struct vlc_http_stream *stream_open(void) diff --git a/modules/access/http/tunnel_test.c b/modules/access/http/tunnel_test.c index fe7ad8fefb..0687056728 100644 --- a/modules/access/http/tunnel_test.c +++ b/modules/access/http/tunnel_test.c @@ -98,7 +98,7 @@ static void *proxy_thread(void *data) int canc = vlc_savecancel(); proxy_client_process(cfd); - close(cfd); + vlc_close(cfd); connection_count++; vlc_restorecancel(canc); } @@ -123,7 +123,7 @@ static int server_socket(unsigned *port) if (bind(fd, (struct sockaddr *)&addr, addrlen) || getsockname(fd, (struct sockaddr *)&addr, &addrlen)) { - close(fd); + vlc_close(fd); return -1; } @@ -157,7 +157,7 @@ int main(void) if (listen(lfd, 255)) { - close(lfd); + vlc_close(lfd); return 77; } @@ -173,5 +173,5 @@ int main(void) vlc_join(th, NULL); assert(connection_count > 0); free(url); - close(lfd); + vlc_close(lfd); } diff --git a/modules/access/linsys/linsys_hdsdi.c b/modules/access/linsys/linsys_hdsdi.c index e6985fc44c..f97fa89b4d 100644 --- a/modules/access/linsys/linsys_hdsdi.c +++ b/modules/access/linsys/linsys_hdsdi.c @@ -253,7 +253,7 @@ static int Open( vlc_object_t *p_this ) if( pthread_create( &p_sys->thread, NULL, Demux, p_demux ) ) { - close( p_sys->evfd ); + vlc_close( p_sys->evfd ); goto error; } @@ -275,7 +275,7 @@ static void Close( vlc_object_t *p_this ) write( p_sys->evfd, &(uint64_t){ 1 }, sizeof (uint64_t)); pthread_join( p_sys->thread, NULL ); - close( p_sys->evfd ); + vlc_close( p_sys->evfd ); free( p_sys ); } @@ -667,7 +667,7 @@ static ssize_t WriteULSysfs( const char *psz_fmt, unsigned int i_link, return i_fd; i_ret = write( i_fd, psz_data, strlen(psz_data) + 1 ); - close( i_fd ); + vlc_close( i_fd ); return i_ret; } @@ -727,7 +727,7 @@ static int InitCapture( demux_t *p_demux ) if( pfd[1].revents ) { - close( p_sys->i_vfd ); + vlc_close( p_sys->i_vfd ); return VLC_EGENERIC; } } @@ -737,10 +737,10 @@ static int InitCapture( demux_t *p_demux ) { msg_Warn( p_demux, "couldn't SDIVIDEO_IOC_RXGETVIDSTATUS: %s", vlc_strerror_c(errno) ); - close( p_sys->i_vfd ); + vlc_close( p_sys->i_vfd ); return VLC_EGENERIC; } - close( p_sys->i_vfd ); + vlc_close( p_sys->i_vfd ); if ( InitVideo( p_demux ) != VLC_SUCCESS ) return VLC_EGENERIC; @@ -789,7 +789,7 @@ static int InitCapture( demux_t *p_demux ) msg_Err( p_demux, "unknown sample rate %u", i_rate ); return VLC_EGENERIC; } - close( p_sys->i_afd ); + vlc_close( p_sys->i_afd ); if ( InitAudio( p_demux ) != VLC_SUCCESS ) 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 ); free( p_sys->pp_vbuffers ); #endif - close( p_sys->i_vfd ); + vlc_close( p_sys->i_vfd ); if ( p_sys->i_max_channel != -1 ) { #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 ); free( p_sys->pp_abuffers ); #endif - close( p_sys->i_afd ); + vlc_close( p_sys->i_afd ); } } diff --git a/modules/access/linsys/linsys_sdi.c b/modules/access/linsys/linsys_sdi.c index c479ad94ff..6ec72c4f87 100644 --- a/modules/access/linsys/linsys_sdi.c +++ b/modules/access/linsys/linsys_sdi.c @@ -1765,7 +1765,7 @@ static void CloseCapture( demux_t *p_demux ) StopDecode( p_demux ); for ( unsigned int i = 0; i < p_sys->i_buffers; i++ ) 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 ); } diff --git a/modules/access/mtp.c b/modules/access/mtp.c index 7134cb6a4a..ac26752ac7 100644 --- a/modules/access/mtp.c +++ b/modules/access/mtp.c @@ -164,7 +164,7 @@ static void Close( vlc_object_t * p_this ) access_t *p_access = ( access_t* )p_this; 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 ) msg_Err( p_access, "Error deleting file %s, %s", p_access->psz_filepath, vlc_strerror_c(errno) ); diff --git a/modules/access/oss.c b/modules/access/oss.c index 40e78c1a09..04a0bd32ef 100644 --- a/modules/access/oss.c +++ b/modules/access/oss.c @@ -192,7 +192,8 @@ static void DemuxClose( vlc_object_t *p_this ) demux_t *p_demux = (demux_t *)p_this; 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 ); free( p_sys ); @@ -376,7 +377,8 @@ static int OpenAudioDevOss( demux_t *p_demux ) adev_fail: - if( i_fd >= 0 ) close( i_fd ); + if( i_fd >= 0 ) + vlc_close( i_fd ); return -1; } @@ -432,11 +434,13 @@ static bool ProbeAudioDevOss( demux_t *p_demux, const char *psz_device ) goto open_failed; } - if( i_fd >= 0 ) close( i_fd ); + if( i_fd >= 0 ) + vlc_close( i_fd ); return true; open_failed: - if( i_fd >= 0 ) close( i_fd ); + if( i_fd >= 0 ) + vöc_close( i_fd ); return false; } diff --git a/modules/access/screen/wayland.c b/modules/access/screen/wayland.c index 3a3b015c8c..02f023a261 100644 --- a/modules/access/screen/wayland.c +++ b/modules/access/screen/wayland.c @@ -219,7 +219,7 @@ static block_t *Shoot(demux_t *demux) } out: - close(fd); + vlc_close(fd); return block; } diff --git a/modules/access/shm.c b/modules/access/shm.c index 7e3a536bfc..cbfd60a093 100644 --- a/modules/access/shm.c +++ b/modules/access/shm.c @@ -341,7 +341,7 @@ static void DemuxFile (void *data) static void CloseFile (demux_sys_t *sys) { - close (sys->fd); + vlc_close (sys->fd); } #ifdef HAVE_SYS_SHM_H diff --git a/modules/access/v4l2/vbi.c b/modules/access/v4l2/vbi.c index 9f25d4ed2f..64780b6eab 100644 --- a/modules/access/v4l2/vbi.c +++ b/modules/access/v4l2/vbi.c @@ -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); free (errstr); - close (rawfd); + vlc_close (rawfd); goto err; } @@ -155,7 +155,7 @@ void GrabVBI (demux_t *p_demux, 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); free (vbi); } diff --git a/modules/access/vcd/cdrom.c b/modules/access/vcd/cdrom.c index bf9d7e8a0c..67fff4b37f 100644 --- a/modules/access/vcd/cdrom.c +++ b/modules/access/vcd/cdrom.c @@ -248,7 +248,7 @@ void ioctl_Close( vlc_object_t * p_this, vcddev_t *p_vcddev ) DosClose( p_vcddev->hcd ); #else if( p_vcddev->i_device_handle != -1 ) - close( p_vcddev->i_device_handle ); + vlc_close( p_vcddev->i_device_handle ); #endif free( p_vcddev ); } @@ -919,7 +919,7 @@ static void CloseVCDImage( vlc_object_t * p_this, vcddev_t *p_vcddev ) { VLC_UNUSED( p_this ); if( p_vcddev->i_vcdimage_handle != -1 ) - close( p_vcddev->i_vcdimage_handle ); + vlc_close( p_vcddev->i_vcdimage_handle ); else return; diff --git a/modules/access/vdr.c b/modules/access/vdr.c index 1845da77cd..9011e0285b 100644 --- a/modules/access/vdr.c +++ b/modules/access/vdr.c @@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this ) access_sys_t *p_sys = p_access->p_sys; if( p_sys->fd != -1 ) - close( p_sys->fd ); + vlc_close( p_sys->fd ); ARRAY_RESET( p_sys->file_sizes ); if( p_sys->p_meta ) @@ -504,7 +504,7 @@ static bool SwitchFile( access_t *p_access, unsigned i_file ) /* close old file */ if( p_sys->fd != -1 ) { - close( p_sys->fd ); + vlc_close( p_sys->fd ); p_sys->fd = -1; } @@ -545,7 +545,7 @@ error: " open the file \"%s\" (%s)."), psz_path, vlc_strerror(errno) ); if( p_sys->fd != -1 ) { - close( p_sys->fd ); + vlc_close( p_sys->fd ); p_sys->fd = -1; } free( psz_path ); diff --git a/modules/access_output/file.c b/modules/access_output/file.c index 34a0329c1f..1b6ea522d8 100644 --- a/modules/access_output/file.c +++ b/modules/access_output/file.c @@ -334,7 +334,7 @@ static int Open( vlc_object_t *p_this ) if (fstat (fd, &st)) { msg_Err (p_access, "write error: %s", vlc_strerror_c(errno)); - close (fd); + vlc_close (fd); 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; - close( (intptr_t)p_access->p_sys ); + vlc_close( (intptr_t)p_access->p_sys ); msg_Dbg( p_access, "file access output closed" ); } diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c index 4563289944..d0f2ea78e5 100644 --- a/modules/access_output/livehttp.c +++ b/modules/access_output/livehttp.c @@ -355,7 +355,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file ) ssize_t keylen = read( keyfd, key, 16 ); - close( keyfd ); + vlc_close( keyfd ); if( keylen < 16 ) { 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; if( ! ( us_asprintf( &segment->psz_duration, "%.2f", p_sys->f_seglen ) ) ) diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c index 9453d5c19f..ba1a0f6276 100644 --- a/modules/audio_output/oss.c +++ b/modules/audio_output/oss.c @@ -237,7 +237,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) sys->format = *fmt; return VLC_SUCCESS; error: - close (fd); + vlc_close (fd); return VLC_EGENERIC; } @@ -313,7 +313,7 @@ static void Stop (audio_output_t *aout) int fd = sys->fd; ioctl (fd, SNDCTL_DSP_HALT, NULL); - close (fd); + vlc_close (fd); sys->fd = -1; } @@ -356,7 +356,7 @@ static int DevicesEnum (audio_output_t *aout) n++; } out: - close (fd); + vlc_close (fd); return n; } diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c index c4dc52a99f..d66047dd86 100644 --- a/modules/codec/avcodec/vaapi.c +++ b/modules/codec/avcodec/vaapi.c @@ -204,7 +204,7 @@ static void Delete( vlc_va_t *va, AVCodecContext *avctx ) XCloseDisplay( sys->p_display_x11 ); #endif #ifdef VLC_VA_BACKEND_DRM - close( sys->drm_fd ); + vlc_close( sys->drm_fd ); #endif free( sys ); } @@ -478,7 +478,7 @@ error: #endif #ifdef VLC_VA_BACKEND_DRM if( sys->drm_fd != -1 ) - close( sys->drm_fd ); + vlc_close( sys->drm_fd ); #endif free( sys ); return VLC_EGENERIC; diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c index 2ac40a2e3e..9424126023 100644 --- a/modules/control/dbus/dbus.c +++ b/modules/control/dbus/dbus.c @@ -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", error.message ); dbus_error_free( &error ); - close( p_sys->p_pipe_fds[1] ); - close( p_sys->p_pipe_fds[0] ); + vlc_close( p_sys->p_pipe_fds[1] ); + vlc_close( p_sys->p_pipe_fds[0] ); free( p_sys ); return VLC_EGENERIC; } @@ -280,8 +280,8 @@ error: vlc_mutex_destroy( &p_sys->lock ); - close( p_sys->p_pipe_fds[1] ); - close( p_sys->p_pipe_fds[0] ); + vlc_close( p_sys->p_pipe_fds[1] ); + vlc_close( p_sys->p_pipe_fds[0] ); free( p_sys ); 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_timeouts ); vlc_array_destroy( p_sys->p_watches ); - close( p_sys->p_pipe_fds[1] ); - close( p_sys->p_pipe_fds[0] ); + vlc_close( p_sys->p_pipe_fds[1] ); + vlc_close( p_sys->p_pipe_fds[0] ); free( p_sys ); } diff --git a/modules/gui/eject.c b/modules/gui/eject.c index e4109aade0..c60952ac2d 100644 --- a/modules/gui/eject.c +++ b/modules/gui/eject.c @@ -167,10 +167,10 @@ static int intf_Eject( vlc_object_t *p_this, const char *psz_device ) # endif { msg_Err( p_this, "could not eject %s", psz_device ); - close( fd ); + vlc_close( fd ); return VLC_EGENERIC; } - close( fd ); + vlc_close( fd ); return VLC_SUCCESS; #else diff --git a/modules/gui/skins2/src/theme_loader.cpp b/modules/gui/skins2/src/theme_loader.cpp index 95b8428191..1ec1dfc1a3 100644 --- a/modules/gui/skins2/src/theme_loader.cpp +++ b/modules/gui/skins2/src/theme_loader.cpp @@ -529,7 +529,7 @@ int tar_open( TAR **t, char *pathname, int oflags ) if( f == NULL ) { fprintf( stderr, "Couldn't gzopen %s\n", pathname ); - close( fd ); + vlc_close( fd ); return -1; } @@ -775,7 +775,7 @@ int gzopen_frontend( const char *pathname, int oflags, int mode ) if( !gzf ) { errno = ENOMEM; - close( fd ); + vlc_close( fd ); return -1; } diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c index ab954d380d..1df75fd4c6 100644 --- a/modules/services_discovery/udev.c +++ b/modules/services_discovery/udev.c @@ -38,6 +38,7 @@ #ifdef HAVE_ALSA # include #endif +#include #include 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"); if (val == NULL) { /* 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) - close (fd); + vlc_close (fd); return NULL; } if (!strcmp (val, "blank")) diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c index fe6c9976a5..fe43d67137 100644 --- a/modules/stream_filter/decomp.c +++ b/modules/stream_filter/decomp.c @@ -178,7 +178,7 @@ static void *Thread (void *data) msg_Dbg (stream, "compressed stream at EOF"); /* Let child process know about EOF */ p_sys->write_fd = -1; - close (fd); + vlc_close (fd); return NULL; } @@ -327,13 +327,13 @@ static int Open (stream_t *stream, const char *path) ret = VLC_SUCCESS; } #endif /* _POSIX_SPAWN < 0 */ - close (uncomp[1]); + vlc_close (uncomp[1]); if (ret != VLC_SUCCESS) - close (uncomp[0]); + vlc_close (uncomp[0]); } - close (comp[0]); + vlc_close (comp[0]); if (ret != VLC_SUCCESS) - close (comp[1]); + vlc_close (comp[1]); } if (ret != VLC_SUCCESS) @@ -363,11 +363,11 @@ static void Close (vlc_object_t *obj) int status; vlc_cancel (p_sys->thread); - close (p_sys->read_fd); + vlc_close (p_sys->read_fd); vlc_join (p_sys->thread, NULL); if (p_sys->write_fd != -1) /* 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); while (waitpid (p_sys->pid, &status, 0) == -1); diff --git a/modules/stream_filter/prefetch.c b/modules/stream_filter/prefetch.c index b3bc8593fe..09b9db9a9e 100644 --- a/modules/stream_filter/prefetch.c +++ b/modules/stream_filter/prefetch.c @@ -499,10 +499,10 @@ static int Open(vlc_object_t *obj) || mmap(sys->buffer + sys->buffer_size, sys->buffer_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0) == MAP_FAILED) { - close(fd); + vlc_close(fd); goto error; } - close(fd); + vlc_close(fd); #elif defined(__OS2__) /* On OS/2 Warp, page size is 4K, but the smallest chunk size is 64K */ int page_size = 64 * 1024; diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay.c b/modules/video_filter/dynamicoverlay/dynamicoverlay.c index 56e80c4617..817ff80d5f 100644 --- a/modules/video_filter/dynamicoverlay/dynamicoverlay.c +++ b/modules/video_filter/dynamicoverlay/dynamicoverlay.c @@ -217,7 +217,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) { msg_Warn( p_filter, "Error on input file: %s", vlc_strerror_c(errno) ); - close( p_sys->i_inputfd ); + vlc_close( p_sys->i_inputfd ); 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", vlc_strerror_c(errno) ); - close( p_sys->i_outputfd ); + vlc_close( p_sys->i_outputfd ); p_sys->i_outputfd = -1; } } diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c index 428eeb6adf..cf6c2a7c87 100644 --- a/modules/video_output/fb.c +++ b/modules/video_output/fb.c @@ -516,7 +516,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution) /* Get framebuffer device information */ if (ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) { msg_Err(vd, "cannot get fb info (%s)", vlc_strerror_c(errno)); - close(sys->fd); + vlc_close(sys->fd); return VLC_EGENERIC; } 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)) { msg_Err(vd, "cannot set fb info (%s)", vlc_strerror_c(errno)); - close(sys->fd); + vlc_close(sys->fd); return VLC_EGENERIC; } @@ -549,7 +549,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution) /* Restore fb config */ ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); - close(sys->fd); + vlc_close(sys->fd); return VLC_EGENERIC; } @@ -584,7 +584,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution) /* Restore fb config */ ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); - close(sys->fd); + vlc_close(sys->fd); return VLC_ENOMEM; } sys->fb_cmap.start = 0; @@ -620,7 +620,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution) /* Restore fb config */ ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); - close(sys->fd); + vlc_close(sys->fd); return VLC_EGENERIC; } @@ -641,7 +641,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution) /* Restore fb config */ ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); - close(sys->fd); + vlc_close(sys->fd); return VLC_EGENERIC; } @@ -678,7 +678,7 @@ static void CloseDisplay(vout_display_t *vd) ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info); /* Close fb */ - close(sys->fd); + vlc_close(sys->fd); } } diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c index 66efa54cbd..8cda503e31 100644 --- a/modules/video_output/wayland/shm.c +++ b/modules/video_output/wayland/shm.c @@ -124,7 +124,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req) if (ftruncate(fd, length)) { msg_Err(vd, "cannot allocate buffers: %s", vlc_strerror_c(errno)); - close(fd); + vlc_close(fd); return NULL; } @@ -132,7 +132,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req) if (base == MAP_FAILED) { msg_Err(vd, "cannot map buffers: %s", vlc_strerror_c(errno)); - close(fd); + vlc_close(fd); return NULL; } #ifndef NDEBUG @@ -140,7 +140,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned req) #endif struct wl_shm_pool *shm_pool = wl_shm_create_pool(sys->shm, fd, length); - close(fd); + vlc_close(fd); if (shm_pool == NULL) { munmap(base, length); diff --git a/src/config/file.c b/src/config/file.c index 3c1712a9e6..8a23680101 100644 --- a/src/config/file.c +++ b/src/config/file.c @@ -397,7 +397,7 @@ int config_SaveConfigFile (vlc_object_t *p_this) msg_Err (p_this, "cannot create configuration file: %s", vlc_strerror_c(errno)); vlc_rwlock_unlock (&config_lock); - close (fd); + vlc_close (fd); vlc_mutex_unlock (&lock); goto error; } diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c index a93e25259e..d1a1fc56dd 100644 --- a/src/input/es_out_timeshift.c +++ b/src/input/es_out_timeshift.c @@ -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" ); if( p_storage->p_filew == NULL ) { - close( fd ); + vlc_close( fd ); vlc_unlink( psz_file ); goto error; } diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c index 804a28d24c..afc74991b2 100644 --- a/src/input/vlmshell.c +++ b/src/input/vlmshell.c @@ -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 ) { free( psz_buffer ); - close( fd ); + vlc_close( fd ); *pp_status = vlm_MessageNew( "load", "Read file error" ); return VLC_EGENERIC; } - close( fd ); + vlc_close( fd ); psz_buffer[st.st_size] = '\0'; diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 5d8813edc7..5cde08ec97 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -442,6 +442,7 @@ us_atof us_strtod us_strtof us_vasprintf +vlc_close vlc_fopen utf8_fprintf vlc_loaddir diff --git a/src/misc/block.c b/src/misc/block.c index 610659d2e3..f7ee8d842b 100644 --- a/src/misc/block.c +++ b/src/misc/block.c @@ -488,6 +488,6 @@ block_t *block_FilePath (const char *path) return NULL; block_t *block = block_File (fd); - close (fd); + vlc_close (fd); return block; } diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c index 54c937793b..43aa90f101 100644 --- a/src/misc/interrupt.c +++ b/src/misc/interrupt.c @@ -365,8 +365,8 @@ static void vlc_poll_i11e_cleanup(void *opaque) vlc_interrupt_finish(ctx); if (fd[1] != fd[0]) - close(fd[1]); - close(fd[0]); + vlc_close(fd[1]); + vlc_close(fd[0]); } 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(); if (fd[1] != fd[0]) - close(fd[1]); - close(fd[0]); + vlc_close(fd[1]); + vlc_close(fd[0]); vlc_restorecancel(canc); return ret; } diff --git a/src/posix/netconf.c b/src/posix/netconf.c index 4dd751b2e4..1ce6526711 100644 --- a/src/posix/netconf.c +++ b/src/posix/netconf.c @@ -77,7 +77,7 @@ char *vlc_getProxyUrl(const char *url) posix_spawnattr_destroy(&attr); posix_spawn_file_actions_destroy(&actions); - close(fd[1]); + vlc_close(fd[1]); if (pid != -1) { @@ -93,7 +93,7 @@ char *vlc_getProxyUrl(const char *url) } while (len < sizeof (buf)); - close(fd[0]); + vlc_close(fd[0]); while (waitpid(pid, &(int){ 0 }, 0) == -1); 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) */ } else - close(fd[0]); + vlc_close(fd[0]); /* Fallback to environment variable */ char *var = getenv("http_proxy"); diff --git a/src/posix/rand.c b/src/posix/rand.c index af448fb82d..338f4675da 100644 --- a/src/posix/rand.c +++ b/src/posix/rand.c @@ -70,7 +70,7 @@ static void vlc_rand_init (void) ikey[i] = key[i] ^ 0x36; } - close (fd); + vlc_close (fd); } diff --git a/src/text/filesystem.c b/src/text/filesystem.c index 38138965ec..9917e30f91 100644 --- a/src/text/filesystem.c +++ b/src/text/filesystem.c @@ -93,7 +93,7 @@ FILE *vlc_fopen (const char *filename, const char *mode) FILE *stream = fdopen (fd, mode); if (stream == NULL) - close (fd); + vlc_close (fd); return stream; } diff --git a/test/libvlc/media.c b/test/libvlc/media.c index 33fe1d9c8d..51adb6a413 100644 --- a/test/libvlc/media.c +++ b/test/libvlc/media.c @@ -29,6 +29,7 @@ #include #include +#include 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); test_media_subitems_media (media, true, true); libvlc_media_release (media); - close (fd); + vlc_close (fd); #else #warning not testing subitems list via a fd location #endif diff --git a/test/modules/keystore/test.c b/test/modules/keystore/test.c index b52f8efa27..ad8105dcf7 100644 --- a/test/modules/keystore/test.c +++ b/test/modules/keystore/test.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #undef NDEBUG @@ -335,7 +336,7 @@ main(int i_argc, char *ppsz_argv[]) if (i_tmp_fd != -1) { - close(i_tmp_fd); + vlc_close(i_tmp_fd); unlink(psz_tmp_path); } free(ppsz_vlc_argv[0]); diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c index 20b3f62e92..60898c654e 100644 --- a/test/modules/misc/tls.c +++ b/test/modules/misc/tls.c @@ -132,7 +132,7 @@ static int securepair(vlc_thread_t *th, vlc_tls_t **restrict client, alpnv[1], alp); if (*client == NULL) { - val = close(insecurev[1]); + val = vlc_close(insecurev[1]); assert(val == 0); vlc_join(*th, NULL); return -1; diff --git a/test/src/misc/keystore.c b/test/src/misc/keystore.c index 7cbe2081d9..313adfd88c 100644 --- a/test/src/misc/keystore.c +++ b/test/src/misc/keystore.c @@ -31,6 +31,7 @@ #include #include #include +#include #undef NDEBUG #include @@ -330,7 +331,7 @@ main(void) } libvlc_release(p_libvlc); - close(i_tmp_fd); + vlc_close(i_tmp_fd); return 0; }