Commit 2f095050 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Don't use void * for utf8_(l)?stat() as it hinders bug detection

parent 65b7318b
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#else
struct stat { };
#endif
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
...@@ -44,8 +49,13 @@ VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) ); ...@@ -44,8 +49,13 @@ VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) );
VLC_EXPORT( void *, utf8_opendir, ( const char *dirname ) ); VLC_EXPORT( void *, utf8_opendir, ( const char *dirname ) );
VLC_EXPORT( char *, utf8_readdir, ( void *dir ) ); VLC_EXPORT( char *, utf8_readdir, ( void *dir ) );
VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) ); VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_stat, ( const char *filename, void *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, void *buf ) ); #ifdef WIN32
# define stat _stati64
#endif
VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_mkdir, ( const char *filename ) ); VLC_EXPORT( int, utf8_mkdir, ( const char *filename ) );
VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) ); VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) );
......
...@@ -469,8 +469,8 @@ struct module_symbols_t ...@@ -469,8 +469,8 @@ struct module_symbols_t
void * (*utf8_opendir_inner) (const char *dirname); void * (*utf8_opendir_inner) (const char *dirname);
FILE * (*utf8_fopen_inner) (const char *filename, const char *mode); FILE * (*utf8_fopen_inner) (const char *filename, const char *mode);
char * (*utf8_readdir_inner) (void *dir); char * (*utf8_readdir_inner) (void *dir);
int (*utf8_stat_inner) (const char *filename, void *buf); int (*utf8_stat_inner) (const char *filename, struct stat *buf);
int (*utf8_lstat_inner) (const char *filename, void *buf); int (*utf8_lstat_inner) (const char *filename, struct stat *buf);
char * (*FromLocaleDup_inner) (const char *); char * (*FromLocaleDup_inner) (const char *);
int (*utf8_mkdir_inner) (const char *filename); int (*utf8_mkdir_inner) (const char *filename);
vlm_media_t* (*vlm_MediaSearch_inner) (vlm_t *, const char *); vlm_media_t* (*vlm_MediaSearch_inner) (vlm_t *, const char *);
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#if defined( WIN32 ) && !defined( UNDER_CE ) #if defined( WIN32 ) && !defined( UNDER_CE )
/* fstat() support for large files on win32 */ /* fstat() support for large files on win32 */
# define fstat(a,b) _fstati64(a,b) # define fstat(a,b) _fstati64(a,b)
# define FILESTAT _stati64
# ifdef lseek # ifdef lseek
# undef lseek # undef lseek
# endif # endif
...@@ -68,8 +67,6 @@ ...@@ -68,8 +67,6 @@
# undef lseek # undef lseek
# endif # endif
# define lseek fseek # define lseek fseek
#else
# define FILESTAT stat
#endif #endif
#include "charset.h" #include "charset.h"
...@@ -169,7 +166,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -169,7 +166,7 @@ static int Open( vlc_object_t *p_this )
fd = open_file (p_access, p_access->psz_path); fd = open_file (p_access, p_access->psz_path);
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
struct FILESTAT st; struct stat st;
while (fd != -1) while (fd != -1)
{ {
...@@ -302,7 +299,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -302,7 +299,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
if( p_access->info.i_size != 0 && if( p_access->info.i_size != 0 &&
(p_sys->i_nb_reads % INPUT_FSTAT_NB_READS) == 0 ) (p_sys->i_nb_reads % INPUT_FSTAT_NB_READS) == 0 )
{ {
struct FILESTAT st; struct stat st;
if ((fstat (fd, &st) == 0) if ((fstat (fd, &st) == 0)
&& (p_access->info.i_size != st.st_size)) && (p_access->info.i_size != st.st_size))
......
...@@ -518,7 +518,7 @@ int utf8_scandir( const char *dirname, char ***namelist, ...@@ -518,7 +518,7 @@ int utf8_scandir( const char *dirname, char ***namelist,
} }
static int utf8_statEx( const char *filename, void *buf, static int utf8_statEx( const char *filename, struct stat *buf,
vlc_bool_t deref ) vlc_bool_t deref )
{ {
#if defined (WIN32) || defined (UNDER_CE) #if defined (WIN32) || defined (UNDER_CE)
...@@ -535,7 +535,7 @@ static int utf8_statEx( const char *filename, void *buf, ...@@ -535,7 +535,7 @@ static int utf8_statEx( const char *filename, void *buf,
} }
wpath[MAX_PATH] = L'\0'; wpath[MAX_PATH] = L'\0';
return _wstati64( wpath, (struct _stati64 *)buf ); return _wstati64( wpath, buf );
} }
#endif #endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
...@@ -543,8 +543,8 @@ static int utf8_statEx( const char *filename, void *buf, ...@@ -543,8 +543,8 @@ static int utf8_statEx( const char *filename, void *buf,
if( local_name != NULL ) if( local_name != NULL )
{ {
int res = deref ? stat( local_name, (struct stat *)buf ) int res = deref ? stat( local_name, buf )
: lstat( local_name, (struct stat *)buf ); : lstat( local_name, buf );
LocaleFree( local_name ); LocaleFree( local_name );
return res; return res;
} }
...@@ -554,12 +554,12 @@ static int utf8_statEx( const char *filename, void *buf, ...@@ -554,12 +554,12 @@ static int utf8_statEx( const char *filename, void *buf,
} }
int utf8_stat( const char *filename, void *buf) int utf8_stat( const char *filename, struct stat *buf)
{ {
return utf8_statEx( filename, buf, VLC_TRUE ); return utf8_statEx( filename, buf, VLC_TRUE );
} }
int utf8_lstat( const char *filename, void *buf) int utf8_lstat( const char *filename, struct stat *buf)
{ {
return utf8_statEx( filename, buf, VLC_FALSE ); return utf8_statEx( filename, buf, VLC_FALSE );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment