[libdvdnav-devel] src/dvd_udf.c: Reduce the scope of some variables

Andrew Clayton git at videolan.org
Fri Oct 24 16:29:24 CEST 2014


libdvdread | branch: master | Andrew Clayton <andrew at digital-domain.net> | Fri Oct 24 15:21:32 2014 +0100| [f5986d6b4c2f97ab3986e341c58a61e20593dc41] | committer: Jean-Baptiste Kempf

src/dvd_udf.c: Reduce the scope of some variables

Signed-off-by: Andrew Clayton <andrew at digital-domain.net>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/dvd_udf.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/dvd_udf.c b/src/dvd_udf.c
index 7302b55..58ad29e 100644
--- a/src/dvd_udf.c
+++ b/src/dvd_udf.c
@@ -48,10 +48,10 @@ static int DVDReadLBUDF( dvd_reader_t *device, uint32_t lb_number,
                          size_t block_count, unsigned char *data,
                          int encrypted )
 {
-  int ret;
   size_t count = block_count;
 
   while(count > 0) {
+    int ret;
 
     ret = InternalUDFReadBlocksRaw(device, lb_number, count, data, encrypted);
 
@@ -564,13 +564,14 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
   uint8_t *cached_dir_base = NULL, *cached_dir;
   uint32_t dir_lba;
   struct AD tmpICB;
-  int found = 0;
-  int in_cache = 0;
 
   /* Scan dir for ICB of file */
   lbnum = partition->Start + Dir.Location;
 
   if(DVDUDFCacheLevel(device, -1) > 0) {
+    int found = 0;
+    int in_cache = 0;
+
     /* caching */
 
     if(!GetUDFCache(device, LBUDFCache, lbnum, &cached_dir)) {
@@ -605,6 +606,7 @@ static int UDFScanDir( dvd_reader_t *device, struct AD Dir, char *FileName,
     p = 0;
 
     while( p < Dir.Length ) {
+
       UDFDescriptor( &cached_dir[ p ], &TagID );
       if( TagID == FileIdentifierDescriptor ) {
         p += UDFFileIdentifier( &cached_dir[ p ], &filechar,
@@ -802,7 +804,6 @@ uint32_t UDFFindFile( dvd_reader_t *device, char *filename,
   struct Partition partition;
   struct AD RootICB, File, ICB;
   char tokenline[ MAX_UDF_FILE_NAME_LEN ];
-  char *token;
   uint8_t filetype;
 
   *filesize = 0;
@@ -846,7 +847,7 @@ uint32_t UDFFindFile( dvd_reader_t *device, char *filename,
   {
     int cache_file_info = 0;
     /* Tokenize filepath */
-    token = strtok(tokenline, "/");
+    char *token = strtok(tokenline, "/");
 
     while( token != NULL ) {
       if( !UDFScanDir( device, File, token, &partition, &ICB,



More information about the libdvdnav-devel mailing list