Commit 8f2e1e57 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use vlc_close()

parent 582355f9
......@@ -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 */
......
......@@ -610,7 +610,7 @@ static int probeFile(const char *psz_name)
ret = VLC_SUCCESS;
bailout:
close(fd);
vlc_close(fd);
return ret;
}
......
......@@ -28,6 +28,7 @@
#include <vlc_common.h>
#include <vlc_charset.h>
#include <vlc_fs.h>
#include <errno.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 );
}
......@@ -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, &param) < 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;
}
......
......@@ -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 );
}
......@@ -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;
}
......@@ -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);
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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);
}
......@@ -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 );
}
}
......
......@@ -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 );
}
......
......@@ -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) );
......
......@@ -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;
}
......@@ -219,7 +219,7 @@ static block_t *Shoot(demux_t *demux)
}
out:
close(fd);
vlc_close(fd);
return block;
}
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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" );
}
......
......@@ -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 ) ) )
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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
......
......@@ -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;
}
......
......@@ -38,6 +38,7 @@
#ifdef HAVE_ALSA
# include <vlc_modules.h>
#endif
#include <vlc_fs.h>
#include <vlc_url.h>
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"))
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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)