[vlc-commits] [Git][videolan/vlc][master] 8 commits: archive: fix the type used for libarchive_skip_cb

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sun Jan 8 08:55:40 UTC 2023



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
5da9f85b by Steve Lhomme at 2023-01-07T22:21:26+00:00
archive: fix the type used for libarchive_skip_cb

It is not using off_t.

- - - - -
74131267 by Steve Lhomme at 2023-01-07T22:21:26+00:00
taglib: don't cast the file st_size to a possibly smaller type

We can just use auto and always get the proper type.

- - - - -
36d83f71 by Steve Lhomme at 2023-01-07T22:21:26+00:00
vlc_common: don't redefine off_t to a larger type on Windows

That makes our usage of mingw-w64 structures like stat, _stat32, _stat64i32
invalid. Plus calls to functions expecting a smaller type.

If we need a bigger type, we need to use our own.

We already set _FILE_OFFSET_BITS so that off_t can be larger than usual.

- - - - -
3462d4be by Steve Lhomme at 2023-01-07T22:21:26+00:00
configure: remove skins2 hack to undefine the toolchain off_t

- - - - -
d4b73a54 by Steve Lhomme at 2023-01-07T22:21:26+00:00
sout: use uint64_t for seeking offsets

We don't need to depend on the flimsy off_t. This is in line with the way file
and stream offsets are used in access modules.

- - - - -
3b3a8b39 by Steve Lhomme at 2023-01-07T22:21:26+00:00
vlc_fs: always map lseek to _lseeki64 on Windows

We can safely pass int64_t offsets this way.

- - - - -
47db8028 by Steve Lhomme at 2023-01-07T22:21:26+00:00
mux/avi: use uint32_t for buffer offset

The values are read from size_t anyway, nothing to do with a file offset.
They are read from 32-bit variables are written as 32-bit variables.

- - - - -
a5e1a194 by Steve Lhomme at 2023-01-07T22:21:26+00:00
hxxx_nal: use size_t for the move values

They seem to represent a size for data in memory (size in block allocation) and
offset for a buffer memmove().

- - - - -


13 changed files:

- configure.ac
- include/vlc_common.h
- include/vlc_fs.h
- include/vlc_sout.h
- modules/access/avio.c
- modules/access/ftp.c
- modules/access_output/file.c
- modules/meta_engine/taglib.cpp
- modules/mux/avi.c
- modules/packetizer/hxxx_nal.c
- modules/stream_extractor/archive.c
- src/missing.c
- src/stream_output/stream_output.c


Changes:

=====================================
configure.ac
=====================================
@@ -4100,7 +4100,7 @@ AS_IF([test "${enable_skins2}" != "no"], [
 
   dnl Win32
   AS_IF([test "${SYS}" = "mingw32"], [
-    VLC_ADD_CPPFLAGS([skins2],[-U_OFF_T_ -U_off_t -DWIN32_SKINS])
+    VLC_ADD_CPPFLAGS([skins2],[-DWIN32_SKINS])
     VLC_ADD_LIBS([skins2],[-lgdi32 -lole32 -luuid -lmsimg32])
   dnl OS/2
   ], [test "${SYS}" = "os2"], [


=====================================
include/vlc_common.h
=====================================
@@ -1153,19 +1153,6 @@ static inline void SetQWLE (void *p, uint64_t qw)
 
 #if defined(_WIN32)
 /* several type definitions */
-#   if defined( __MINGW32__ )
-#       if !defined( _OFF_T_ )
-            typedef long long _off_t;
-            typedef _off_t off_t;
-#           define _OFF_T_
-#       else
-#           ifdef off_t
-#               undef off_t
-#           endif
-#           define off_t long long
-#       endif
-#   endif
-
 #   ifndef O_NONBLOCK
 #       define O_NONBLOCK 0
 #   endif


=====================================
include/vlc_fs.h
=====================================
@@ -35,10 +35,8 @@ struct iovec;
 # ifndef fstat
 #  define fstat _fstati64
 # endif
-# ifndef _MSC_VER
-#  undef lseek
-#  define lseek _lseeki64
-# endif
+# undef lseek
+# define lseek _lseeki64
 #else // !_WIN32
 #include <dirent.h>
 #endif


=====================================
include/vlc_sout.h
=====================================
@@ -58,7 +58,7 @@ struct sout_access_out_t
 
     char                    *psz_path;
     void                    *p_sys;
-    int                     (*pf_seek)( sout_access_out_t *, off_t );
+    int                     (*pf_seek)( sout_access_out_t *, uint64_t );
     ssize_t                 (*pf_read)( sout_access_out_t *, block_t * );
     ssize_t                 (*pf_write)( sout_access_out_t *, block_t * );
     int                     (*pf_control)( sout_access_out_t *, int, va_list );
@@ -76,7 +76,7 @@ VLC_API sout_access_out_t * sout_AccessOutNew( vlc_object_t *, const char *psz_a
 #define sout_AccessOutNew( obj, access, name ) \
         sout_AccessOutNew( VLC_OBJECT(obj), access, name )
 VLC_API void sout_AccessOutDelete( sout_access_out_t * );
-VLC_API int sout_AccessOutSeek( sout_access_out_t *, off_t );
+VLC_API int sout_AccessOutSeek( sout_access_out_t *, uint64_t );
 VLC_API ssize_t sout_AccessOutRead( sout_access_out_t *, block_t * );
 VLC_API ssize_t sout_AccessOutWrite( sout_access_out_t *, block_t * );
 VLC_API int sout_AccessOutControl( sout_access_out_t *, int, ... );


=====================================
modules/access/avio.c
=====================================
@@ -52,7 +52,7 @@ static int     Seek   (stream_t *, uint64_t);
 static int     Control(stream_t *, int, va_list);
 static ssize_t Write(sout_access_out_t *, block_t *);
 static int     OutControl(sout_access_out_t *, int, va_list);
-static int     OutSeek (sout_access_out_t *, off_t);
+static int     OutSeek (sout_access_out_t *, uint64_t);
 
 static int UrlInterruptCallback(void *access)
 {
@@ -279,7 +279,7 @@ static int Seek(stream_t *access, uint64_t position)
     return VLC_SUCCESS;
 }
 
-static int OutSeek(sout_access_out_t *p_access, off_t i_pos)
+static int OutSeek(sout_access_out_t *p_access, uint64_t i_pos)
 {
     sout_access_out_sys_t *sys = p_access->p_sys;
 


=====================================
modules/access/ftp.c
=====================================
@@ -114,7 +114,7 @@ static int Seek( stream_t *, uint64_t );
 static int Control( stream_t *, int, va_list );
 static int DirRead( stream_t *, input_item_node_t * );
 #ifdef ENABLE_SOUT
-static int OutSeek( sout_access_out_t *, off_t );
+static int OutSeek( sout_access_out_t *, uint64_t );
 static ssize_t Write( sout_access_out_t *, block_t * );
 #endif
 
@@ -886,7 +886,7 @@ static int Seek( stream_t *p_access, uint64_t i_pos )
 }
 
 #ifdef ENABLE_SOUT
-static int OutSeek( sout_access_out_t *p_access, off_t i_pos )
+static int OutSeek( sout_access_out_t *p_access, uint64_t i_pos )
 {
     return SeekCommon(VLC_OBJECT(p_access), GET_OUT_SYS(p_access), i_pos);
 }


=====================================
modules/access_output/file.c
=====================================
@@ -185,7 +185,7 @@ static ssize_t Send(sout_access_out_t *access, block_t *block)
 /*****************************************************************************
  * Seek: seek to a specific location in a file
  *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
+static int Seek( sout_access_out_t *p_access, uint64_t i_pos )
 {
     int *fdp = p_access->p_sys, fd = *fdp;
 


=====================================
modules/meta_engine/taglib.cpp
=====================================
@@ -1169,7 +1169,7 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
         fclose( p_file );
         return;
     }
-    off_t file_size = st.st_size;
+    auto file_size = st.st_size;
 
     free( psz_path );
 


=====================================
modules/mux/avi.c
=====================================
@@ -130,11 +130,11 @@ typedef struct
     int i_streams;
     int i_stream_video;
 
-    off_t i_movi_size;
+    uint32_t i_movi_size;
     avi_stream_t stream[100];
 
     avi_idx1_t idx1;
-    off_t i_idx1_size;
+    uint32_t i_idx1_size;
 
 } sout_mux_sys_t;
 


=====================================
modules/packetizer/hxxx_nal.c
=====================================
@@ -49,7 +49,7 @@ block_t *hxxx_AnnexB_to_xVC( block_t *p_block, uint8_t i_nal_length_size )
     {
         const uint8_t *p; /* start of prefixed nal */
         uint8_t  prefix; /* startcode length */
-        off_t    move; /* move offset */
+        size_t   move; /* move offset */
     } *p_list = NULL;
 
     if(!p_block->i_buffer || p_block->p_buffer[0])
@@ -62,7 +62,7 @@ block_t *hxxx_AnnexB_to_xVC( block_t *p_block, uint8_t i_nal_length_size )
     const uint8_t *p_buf = p_block->p_buffer;
     const uint8_t *p_end = &p_block->p_buffer[p_block->i_buffer];
     unsigned i_bitflow = 0;
-    off_t i_move = 0;
+    size_t i_move = 0;
     while( p_buf != p_end )
     {
         i_bitflow <<= 1;
@@ -82,7 +82,7 @@ block_t *hxxx_AnnexB_to_xVC( block_t *p_block, uint8_t i_nal_length_size )
                 p_list[i_nalcount].p = &p_buf[-2];
                 p_list[i_nalcount].prefix = 3;
             }
-            i_move += (off_t) i_nal_length_size - p_list[i_nalcount].prefix;
+            i_move += (size_t) i_nal_length_size - p_list[i_nalcount].prefix;
             p_list[i_nalcount++].move = i_move;
 
             /* Check and realloc our list */
@@ -147,7 +147,7 @@ block_t *hxxx_AnnexB_to_xVC( block_t *p_block, uint8_t i_nal_length_size )
     {
         const uint8_t *p_readstart = p_list[i - 1].p;
         uint32_t i_payload = p_sourceend - p_readstart - p_list[i - 1].prefix;
-        off_t offset = p_list[i - 1].p - p_source + p_list[i - 1].prefix + p_list[i - 1].move;
+        size_t offset = p_list[i - 1].p - p_source + p_list[i - 1].prefix + p_list[i - 1].move;
 //        printf(" move offset %ld, length = %ld  prefix %ld move %ld\n", p_readstart - p_source, i_payload, p_list[i - 1].prefix, p_list[i-1].move);
 
         /* move in same / copy between buffers */


=====================================
modules/stream_extractor/archive.c
=====================================
@@ -129,7 +129,7 @@ static int libarchive_jump_cb( libarchive_t* p_arc, void* p_obj_current,
 
 
 static la_int64_t libarchive_skip_cb( libarchive_t* p_arc, void* p_obj,
-  off_t i_request )
+                                      la_int64_t i_request )
 {
     VLC_UNUSED( p_arc );
 


=====================================
src/missing.c
=====================================
@@ -69,7 +69,7 @@ noreturn ssize_t sout_AccessOutRead(sout_access_out_t *out, block_t *block)
     vlc_assert_unreachable ();
 }
 
-noreturn int sout_AccessOutSeek(sout_access_out_t *out, off_t offset)
+noreturn int sout_AccessOutSeek(sout_access_out_t *out, uint64_t offset)
 {
     VLC_UNUSED (out); VLC_UNUSED (offset);
     vlc_assert_unreachable ();


=====================================
src/stream_output/stream_output.c
=====================================
@@ -266,7 +266,7 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
 /*****************************************************************************
  * sout_AccessSeek:
  *****************************************************************************/
-int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
+int sout_AccessOutSeek( sout_access_out_t *p_access, uint64_t i_pos )
 {
     if (p_access->pf_seek == NULL)
         return VLC_EGENERIC;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/15d669cc809d6cefc2f93ea18f2fe0047389020f...a5e1a194b59e8c650989515ede4cee8197435f08

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/15d669cc809d6cefc2f93ea18f2fe0047389020f...a5e1a194b59e8c650989515ede4cee8197435f08
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list