]> granicus.if.org Git - handbrake/commitdiff
Format cleanup.
authorkonablend <kona8lend@gmail.com>
Thu, 25 Jun 2009 03:36:26 +0000 (03:36 +0000)
committerkonablend <kona8lend@gmail.com>
Thu, 25 Jun 2009 03:36:26 +0000 (03:36 +0000)
- fixed ports.c to use a more portable method of getting integral pthread_t representation; resolves mingw crash.
- added GCC attribute to generate compiler warnings for invalid usage of hb_log, hb_deep_log and hb_errror;
  see new macro HB_WPRINTF(s,v) in common.h.
- fixed various invalid usage of above functions on osx i386/x86_64, and mingw.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2618 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/common.h
libhb/decsrtsub.c
libhb/dvd.c
libhb/dvdnav.c
libhb/internal.h
libhb/muxcommon.c
libhb/platform/macosx/encca_aac.c
libhb/ports.c

index 82499635225fb2830c8bf7a81ab95d63c81fd36a..1da836ece465ef0a0b56b532f5a681688d4179c5 100644 (file)
@@ -124,8 +124,8 @@ void hb_fix_aspect( hb_job_t * job, int keep )
     if ( title->height == 0 || title->width == 0 || title->aspect == 0 )
     {
         hb_log( "hb_fix_aspect: incomplete info for title %d: "
-                "height = %d, width = %d, aspect = %d",
-                title->height, title->width, title->aspect );
+                "height = %d, width = %d, aspect = %.3f",
+                title->index, title->height, title->width, title->aspect );
         return;
     }
 
index 808714ee7b5a7e968eba5c26d996fe7108f922a8..fb1f21198a5ef774119771006443182584931cc7 100644 (file)
 #include <sys/stat.h>
 #include <dirent.h>
 
+#if defined( __GNUC__ ) && !(defined( _WIN32 ) || defined( __MINGW32__ ))
+#   define HB_WPRINTF(s,v) __attribute__((format(printf,s,v)))
+#else
+#   define HB_WPRINTF(s,v)
+#endif
+
 #if defined( SYS_MINGW )
 #   define fseek fseeko64
 #   define ftell ftello64
index 190c2df80c7e17f53b7672fe8ff821d3df3993a4..51aaeeb906707fae49b4e28779627aee04ded96d 100644 (file)
@@ -123,8 +123,7 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
                 hb_error( "Invalid shift sequence" );
             } else if ( ( retval == -1 ) && ( errno == EILSEQ ) )
             {
-                hb_error( "Invalid byte for codeset in input, %d bytes discarded",
-                          in_size);
+                hb_error( "Invalid byte for codeset in input, %"PRId64" bytes discarded", (int64_t)in_size);
             } else if ( ( retval == -1 ) && ( errno == E2BIG ) )
             {
                 hb_error( "Not enough space in output buffer");
index 2d5fb8c9d803b4c24a04338c4fa877362b630eb7..b26725da94cff0fa18e359ee7c89d60b80822c8a 100644 (file)
@@ -232,7 +232,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t )
     pgn    = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgn;
     d->pgc = vts->vts_pgcit->pgci_srp[pgc_id-1].pgc;
 
-    hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgc_id, pgn, d->pgc);
+    hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgc_id, pgn, d->pgc);
 
     if( !d->pgc )
     {
index dfe847d8a58d0a6820287ff847fa374321883bfb..805e8f2bf194f492427a42a298e1eb97b725d7ac 100644 (file)
@@ -425,7 +425,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
 
     pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
 
-    hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgcn, pgn, pgc);
+    hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgcn, pgn, pgc);
     if (pgn > pgc->nr_of_programs)
     {
         hb_error( "invalid PGN %d for title %d, skipping", pgn, t );
index c68d9fa82767cd3fbcfafc35087e2c38259d559f..9a03074bf21510c55205d4adbe92e1e1f095a45c 100644 (file)
@@ -7,7 +7,7 @@
 /***********************************************************************
  * common.c
  **********************************************************************/
-void hb_log( char * log, ... );
+void hb_log( char * log, ... ) HB_WPRINTF(1,2);
 extern int global_verbosity_level; // Global variable for hb_deep_log
 typedef enum hb_debug_level_s
 {
@@ -15,8 +15,8 @@ typedef enum hb_debug_level_s
     HB_HOUSEKEEPING_LOG = 2, // stuff we hate scrolling through  
     HB_GRANULAR_LOG     = 3  // sample-by-sample
 } hb_debug_level_t;
-void hb_deep_log( hb_debug_level_t level, char * log, ... );
-void hb_error( char * fmt, ...);
+void hb_deep_log( hb_debug_level_t level, char * log, ... ) HB_WPRINTF(2,3);
+void hb_error( char * fmt, ...) HB_WPRINTF(1,2);
 
 int  hb_list_bytes( hb_list_t * );
 void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size );
index da390c500482c3647ab6437a8124fdf954bb640f..4c2c680090abfc43619e7f92e486891334d2ecc2 100644 (file)
@@ -355,8 +355,7 @@ finished:
                 {
                     /* Video */
                     hb_deep_log( 2, "mux: video bitrate error, %+lld bytes",
-                            track->bytes - mux->pts * job->vbitrate *
-                            125 / 90000 );
+                            (int64_t)(track->bytes - mux->pts * job->vbitrate * 125 / 90000) );
                 }
                 bytes_total  += track->bytes;
                 frames_total += track->frames;
index 26aff207a4aabd4bcb8b14bcdb55977811dabfb3..aee157d1877ff99d024ee1bca90bea07d6a245d2 100644 (file)
@@ -130,7 +130,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
     err = AudioConverterNew( &input, &output, &pv->converter );
     if( err != noErr)
     {
-        hb_log( "Error creating an AudioConverter %x %d", err, output.mBytesPerFrame );
+        hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame );
         *job->die = 1;
         return 0;
     }
index 2e6b65329a9de6dde936a98c01b81bcc5a1c7114..40183015f39fabbca5374db7b3c5a390d8e3314b 100644 (file)
@@ -54,6 +54,8 @@
 #include <netinet/in.h>
 #endif
 
+#include <stddef.h>
+
 #include "hb.h"
 
 /************************************************************************
@@ -261,6 +263,25 @@ struct hb_thread_s
 #endif
 };
 
+/* Get a unique identifier to thread and represent as 64-bit unsigned.
+ * If unsupported, the value 0 is be returned.
+ * Caller should use result only for display/log purposes.
+ */
+static uint64_t hb_thread_to_integer( const hb_thread_t* t )
+{
+#if defined( USE_PTHREAD )
+    #if defined( _WIN32 ) || defined( __MINGW32__ )
+        return (uint64_t)(ptrdiff_t)t->thread.p;
+    #elif defined( SYS_DARWIN )
+        return (uint64_t)(ptrdiff_t)t->thread;
+    #else
+        return (uint64_t)t->thread;
+    #endif
+#else
+    return 0;
+#endif
+}
+
 /************************************************************************
  * hb_thread_func()
  ************************************************************************
@@ -291,7 +312,7 @@ static void hb_thread_func( void * _t )
     t->function( t->arg );
 
     /* Inform that the thread can be joined now */
-    hb_deep_log( 2, "thread %x exited (\"%s\")", t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" exited (\"%s\")", hb_thread_to_integer( t ), t->name );
     hb_lock( t->lock );
     t->exited = 1;
     hb_unlock( t->lock );
@@ -336,7 +357,7 @@ hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
 //        SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL );
 #endif
 
-    hb_deep_log( 2, "thread %x started (\"%s\")", t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" started (\"%s\")", hb_thread_to_integer( t ), t->name );
     return t;
 }
 
@@ -361,8 +382,7 @@ void hb_thread_close( hb_thread_t ** _t )
 //    WaitForSingleObject( t->thread, INFINITE );
 #endif
 
-    hb_deep_log( 2, "thread %x joined (\"%s\")",
-            t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" joined (\"%s\")", hb_thread_to_integer( t ), t->name );
 
     hb_lock_close( &t->lock );
     free( t->name );