[vlc-commits] VCD: small cosmetics and avoid calling block_New with a negative value

Jean-Baptiste Kempf git at videolan.org
Thu Feb 17 22:28:10 CET 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Feb 17 21:34:51 2011 +0100| [dc8a9e592d408b446d2c17e251802a5b9649667c] | committer: Jean-Baptiste Kempf

VCD: small cosmetics and avoid calling block_New with a negative value

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc8a9e592d408b446d2c17e251802a5b9649667c
---

 modules/access/vcd/vcd.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/modules/access/vcd/vcd.c b/modules/access/vcd/vcd.c
index 925a894..3919df2 100644
--- a/modules/access/vcd/vcd.c
+++ b/modules/access/vcd/vcd.c
@@ -331,7 +331,6 @@ static block_t *Block( access_t *p_access )
     access_sys_t *p_sys = p_access->p_sys;
     int i_blocks = VCD_BLOCKS_ONCE;
     block_t *p_block;
-    int i_read;
 
     /* Check end of file */
     if( p_access->info.b_eof ) return NULL;
@@ -349,8 +348,7 @@ static block_t *Block( access_t *p_access )
             INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT | INPUT_UPDATE_SIZE;
         p_access->info.i_title++;
         p_access->info.i_seekpoint = 0;
-        p_access->info.i_size =
-            p_sys->title[p_access->info.i_title]->i_size;
+        p_access->info.i_size = p_sys->title[p_access->info.i_title]->i_size;
         p_access->info.i_pos = 0;
     }
 
@@ -358,12 +356,11 @@ static block_t *Block( access_t *p_access )
     if( p_sys->i_sector + i_blocks >=
         p_sys->p_sectors[p_access->info.i_title + 2] )
     {
-        i_blocks = p_sys->p_sectors[p_access->info.i_title + 2 ] -
-                   p_sys->i_sector;
+        i_blocks = p_sys->p_sectors[p_access->info.i_title + 2 ] - p_sys->i_sector;
     }
 
     /* Do the actual reading */
-    if( !( p_block = block_New( p_access, i_blocks * VCD_DATA_SIZE ) ) )
+    if( i_blocks < 0 || !( p_block = block_New( p_access, i_blocks * VCD_DATA_SIZE ) ) )
     {
         msg_Err( p_access, "cannot get a new block of size: %i",
                  i_blocks * VCD_DATA_SIZE );
@@ -383,7 +380,7 @@ static block_t *Block( access_t *p_access )
     }
 
     /* Update seekpoints */
-    for( i_read = 0; i_read < i_blocks; i_read++ )
+    for( int i_read = 0; i_read < i_blocks; i_read++ )
     {
         input_title_t *t = p_sys->title[p_access->info.i_title];
 



More information about the vlc-commits mailing list