Skip to content

Commit

Permalink
More cleanup of sprintf usage in favor of snprintf. This is to resolv…
Browse files Browse the repository at this point in the history
…e deprecation warnings on Mac OSX
  • Loading branch information
thor2016 committed Feb 24, 2024
1 parent 7b79d9d commit 37574f9
Show file tree
Hide file tree
Showing 35 changed files with 468 additions and 513 deletions.
42 changes: 21 additions & 21 deletions src/drivers/Qt/AviRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ struct OutputStream
if ( writeError )
{
char msg[512];
sprintf( msg, "%s Stream Write Errors Detected.\nOutput may be incomplete or corrupt.\nSee log file '%s' for details\n",
snprintf( msg, sizeof(msg), "%s Stream Write Errors Detected.\nOutput may be incomplete or corrupt.\nSee log file '%s' for details\n",
isAudio ? "Audio" : "Video", AV_LOG_FILE_NAME);
FCEUD_PrintError(msg);
}
Expand Down Expand Up @@ -2123,7 +2123,7 @@ int aviRecordLogOpen(void)
if ( avLogFp == NULL )
{
char msg[512];
sprintf( msg, "Error: Failed to open AV Recording log file for writing: %s\n", AV_LOG_FILE_NAME);
snprintf( msg, sizeof(msg), "Error: Failed to open AV Recording log file for writing: %s\n", AV_LOG_FILE_NAME);
FCEUD_PrintError(msg);
avLogFp = stdout;
}
Expand Down Expand Up @@ -2224,7 +2224,7 @@ int aviRecordOpenFile( const char *filepath )

avi_info.add_pair( "IMED", QSysInfo::prettyProductName().toLocal8Bit().constData() );

sprintf( txt, "FCEUX %s", FCEU_VERSION_STRING );
snprintf( txt, sizeof(txt), "FCEUX %s", FCEU_VERSION_STRING );
avi_info.add_pair( "ITCH", txt );

romFile = getRomFile();
Expand Down Expand Up @@ -2305,7 +2305,7 @@ int aviRecordOpenFile( const char *filepath )
char msg[512];
fprintf( avLogFp, "Error: Failed to open AVI file.\n");
recordEnable = false;
sprintf( msg, "Error: AV Recording Initialization Failed.\nSee %s for details...\n", AV_LOG_FILE_NAME);
snprintf( msg, sizeof(msg), "Error: AV Recording Initialization Failed.\nSee %s for details...\n", AV_LOG_FILE_NAME);
FCEUD_PrintError(msg);
return -1;
}
Expand All @@ -2320,7 +2320,7 @@ int aviRecordOpenFile( const char *filepath )
char msg[512];
fprintf( avLogFp, "Error: Failed to open AVI file.\n");
recordEnable = false;
sprintf( msg, "Error: AV Recording Initialization Failed.\nSee %s for details...\n", AV_LOG_FILE_NAME);
snprintf( msg, sizeof(msg), "Error: AV Recording Initialization Failed.\nSee %s for details...\n", AV_LOG_FILE_NAME);
FCEUD_PrintError(msg);
return -1;
}
Expand Down Expand Up @@ -3136,7 +3136,7 @@ void LibavOptionsPage::initSampleRateSelect( const char *codec_name )

while ( c->supported_samplerates[i] != 0 )
{
sprintf( rateName, "%i", c->supported_samplerates[i] );
snprintf( rateName, sizeof(rateName), "%i", c->supported_samplerates[i] );

audioSampleRate->addItem( tr(rateName), c->supported_samplerates[i] );

Expand Down Expand Up @@ -3410,7 +3410,7 @@ void LibavEncOptItem::setValueText(void)
if ( units[x]->default_val.i64 & i )
{
char stmp2[128];
sprintf( stmp2, "%s", units[x]->name );
snprintf( stmp2, sizeof(stmp2), "%s", units[x]->name );
if (j>0)
{
strcat( stmp, ",");
Expand Down Expand Up @@ -3445,7 +3445,7 @@ void LibavEncOptItem::setValueText(void)
if ( units[x]->default_val.i64 == i )
{
char stmp2[128];
sprintf( stmp2, " (%s)", units[x]->name );
snprintf( stmp2, sizeof(stmp2), " (%s)", units[x]->name );
strcat( stmp, stmp2 );
break;
}
Expand Down Expand Up @@ -3481,12 +3481,12 @@ LibavEncOptWin::LibavEncOptWin(int type, QWidget *parent)
if ( type )
{
codec_name = LIBAV::audio_st.selEnc.c_str();
sprintf( title, "%s Audio Encoder Configuration", codec_name );
snprintf( title, sizeof(title), "%s Audio Encoder Configuration", codec_name );
}
else
{
codec_name = LIBAV::video_st.selEnc.c_str();
sprintf( title, "%s Video Encoder Configuration", codec_name );
snprintf( title, sizeof(title), "%s Video Encoder Configuration", codec_name );
}
setWindowTitle( title );
resize(512, 512);
Expand Down Expand Up @@ -3816,13 +3816,13 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

grid->addWidget( new QLabel( tr("Range:") ), 2, 0 );

sprintf( stmp, "[ %.0f, %.0f ]", opt->min, opt->max );
snprintf( stmp, sizeof(stmp), "[ %.0f, %.0f ]", opt->min, opt->max );

grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

grid->addWidget( new QLabel( tr("Default:") ), 3, 0 );

sprintf( stmp, "%lli", (long long)opt->default_val.i64 );
snprintf( stmp, sizeof(stmp), "%lli", (long long)opt->default_val.i64 );

grid->addWidget( new QLabel( tr(stmp) ), 3, 1 );

Expand All @@ -3838,12 +3838,12 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare
{
if ( item->units[i]->help )
{
sprintf( stmp, "%3lli: %s - %s", (long long)item->units[i]->default_val.i64,
snprintf( stmp, sizeof(stmp), "%3lli: %s - %s", (long long)item->units[i]->default_val.i64,
item->units[i]->name, item->units[i]->help );
}
else
{
sprintf( stmp, "%3lli: %s", (long long)item->units[i]->default_val.i64,
snprintf( stmp, sizeof(stmp), "%3lli: %s", (long long)item->units[i]->default_val.i64,
item->units[i]->name );
}

Expand Down Expand Up @@ -3874,13 +3874,13 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

grid->addWidget( new QLabel( tr("Range:") ), 2, 0 );

sprintf( stmp, "[ %e, %e ]", opt->min, opt->max );
snprintf( stmp, sizeof(stmp), "[ %e, %e ]", opt->min, opt->max );

grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

grid->addWidget( new QLabel( tr("Default:") ), 3, 0 );

sprintf( stmp, "%f", opt->default_val.dbl );
snprintf( stmp, sizeof(stmp), "%f", opt->default_val.dbl );

grid->addWidget( new QLabel( tr(stmp) ), 3, 1 );

Expand All @@ -3905,7 +3905,7 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

if ( opt->default_val.str )
{
sprintf( stmp, "%s", opt->default_val.str );
snprintf( stmp, sizeof(stmp), "%s", opt->default_val.str );
}
grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

Expand All @@ -3929,7 +3929,7 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

grid->addWidget( new QLabel( tr("Default:") ), 2, 0 );

sprintf( stmp, "%i/%i", opt->default_val.q.num, opt->default_val.q.den );
snprintf( stmp, sizeof(stmp), "%i/%i", opt->default_val.q.num, opt->default_val.q.den );

grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

Expand Down Expand Up @@ -3959,7 +3959,7 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

grid->addWidget( new QLabel( tr("Default:") ), 2, 0 );

sprintf( stmp, "%s", opt->default_val.i64 ? "true" : "false" );
snprintf( stmp, sizeof(stmp), "%s", opt->default_val.i64 ? "true" : "false" );

grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

Expand All @@ -3983,7 +3983,7 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

grid->addWidget( new QLabel( tr("Default:") ), 2, 0 );

sprintf( stmp, "0x%08llX", (unsigned long long)opt->default_val.i64 );
snprintf( stmp, sizeof(stmp), "0x%08llX", (unsigned long long)opt->default_val.i64 );

grid->addWidget( new QLabel( tr(stmp) ), 2, 1 );

Expand All @@ -3993,7 +3993,7 @@ LibavEncOptInputWin::LibavEncOptInputWin( LibavEncOptItem *itemIn, QWidget *pare

for (size_t i=0; i<item->units.size(); i++)
{
sprintf( stmp, "%s", item->units[i]->name );
snprintf( stmp, sizeof(stmp), "%s", item->units[i]->name );

c = new QCheckBox( tr(stmp) );

Expand Down
Loading

0 comments on commit 37574f9

Please sign in to comment.