summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.c2
-rw-r--r--libhb/common.h2
-rw-r--r--test/test.c47
3 files changed, 8 insertions, 43 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 2b2917e5d..4acc293e2 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -1344,7 +1344,7 @@ int hb_srt_add( const hb_job_t * job,
return retval;
}
-char * hb_strdup_printf( char * fmt, ... )
+char * hb_strdup_printf( const char * fmt, ... )
{
int len;
va_list ap;
diff --git a/libhb/common.h b/libhb/common.h
index d350a6bf1..712960248 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -840,7 +840,7 @@ typedef void hb_error_handler_t( const char *errmsg );
extern void hb_register_error_handler( hb_error_handler_t * handler );
-char * hb_strdup_printf( char * fmt, ... );
+char * hb_strdup_printf(const char *fmt, ...) HB_WPRINTF(1, 2);
int hb_yuv2rgb(int yuv);
int hb_rgb2yuv(int rgb);
diff --git a/test/test.c b/test/test.c
index 4bb5f80d6..57e8d0642 100644
--- a/test/test.c
+++ b/test/test.c
@@ -2510,7 +2510,7 @@ static void ShowHelp()
" -r, --rate Set video framerate (" );
for( i = 0; i < hb_video_rates_count; i++ )
{
- fprintf( out, hb_video_rates[i].string );
+ fprintf( out, "%s", hb_video_rates[i].string );
if( i != hb_video_rates_count - 1 )
fprintf( out, "/" );
}
@@ -2565,7 +2565,7 @@ static void ShowHelp()
" -R, --arate Set audio samplerate(s) (" );
for( i = 0; i < hb_audio_rates_count; i++ )
{
- fprintf( out, hb_audio_rates[i].string );
+ fprintf( out, "%s", hb_audio_rates[i].string );
if( i != hb_audio_rates_count - 1 )
fprintf( out, "/" );
}
@@ -3383,41 +3383,6 @@ static int ParseOptions( int argc, char ** argv )
return 0;
}
-static char * str_printf(const char *fmt, ...)
-{
- /* Guess we need no more than 100 bytes. */
- int len;
- va_list ap;
- int size = 100;
- char *tmp, *str = NULL;
-
- str = (char*)malloc(size);
- while (1)
- {
- /* Try to print in the allocated space. */
- va_start(ap, fmt);
- len = vsnprintf(str, size, fmt, ap);
- va_end(ap);
-
- /* If that worked, return the string. */
- if (len > -1 && len < size) {
- return str;
- }
-
- /* Else try again with more space. */
- if (len > -1) /* glibc 2.1 */
- size = len+1; /* precisely what is needed */
- else /* glibc 2.0 */
- size *= 2; /* twice the old size */
-
- tmp = (char*)realloc(str, size);
- if (tmp == NULL) {
- return str;
- }
- str = tmp;
- }
-}
-
static int CheckOptions( int argc, char ** argv )
{
#if defined( __APPLE_CC__ )
@@ -3442,14 +3407,14 @@ static int CheckOptions( int argc, char ** argv )
// And add our extra path
if ( home != NULL )
{
- path = str_printf("%s/lib:%s:%s:%s%s", home,
+ path = hb_strdup_printf("%s/lib:%s:%s:%s%s", home,
DEFAULT_DYLD_PATH,
EXTRA_VLC_DYLD_PATH,
home, EXTRA_VLC_DYLD_PATH);
}
else
{
- path = str_printf("%s:%s", DEFAULT_DYLD_PATH, EXTRA_VLC_DYLD_PATH);
+ path = hb_strdup_printf("%s:%s", DEFAULT_DYLD_PATH, EXTRA_VLC_DYLD_PATH);
}
if ( path != NULL )
result = setenv("DYLD_FALLBACK_LIBRARY_PATH", path, 1);
@@ -3459,12 +3424,12 @@ static int CheckOptions( int argc, char ** argv )
// add our extra path
if ( home != NULL )
{
- path = str_printf("%s:%s:%s%s", dylib_path, EXTRA_VLC_DYLD_PATH,
+ path = hb_strdup_printf("%s:%s:%s%s", dylib_path, EXTRA_VLC_DYLD_PATH,
home, EXTRA_VLC_DYLD_PATH);
}
else
{
- path = str_printf("%s:%s", dylib_path, EXTRA_VLC_DYLD_PATH);
+ path = hb_strdup_printf("%s:%s", dylib_path, EXTRA_VLC_DYLD_PATH);
}
if ( path != NULL )
result = setenv("DYLD_FALLBACK_LIBRARY_PATH", path, 1);