Skip to content

Commit

Permalink
Remove redundant diplayError function
Browse files Browse the repository at this point in the history
  • Loading branch information
drfiemost committed Aug 13, 2024
1 parent 6a592d5 commit b4bea56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
25 changes: 4 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ using std::endl;

#include "keyboard.h"

const char* ERR_SIGHANDLER = "ERROR: Could not install signal handler.";


// Function prototypes
static void sighandler (int signum);
Expand Down Expand Up @@ -58,7 +60,7 @@ int main(int argc, char *argv[])
|| (signal (SIGABRT, &sighandler) == SIG_ERR)
|| (signal (SIGTERM, &sighandler) == SIG_ERR))
{
displayError(argv[0], errnum_t::SIGHANDLER);
player.displayError(ERR_SIGHANDLER);
goto main_error;
}

Expand All @@ -83,7 +85,7 @@ int main(int argc, char *argv[])
|| (signal (SIGABRT, SIG_DFL) == SIG_ERR)
|| (signal (SIGTERM, SIG_DFL) == SIG_ERR))
{
displayError(argv[0], errnum_t::SIGHANDLER);
player.displayError(ERR_SIGHANDLER);
goto main_error;
}

Expand Down Expand Up @@ -112,22 +114,3 @@ void sighandler (int signum)
default: break;
}
}


void displayError (const char *arg0, errnum_t num)
{
cerr << arg0 << ": ";

switch (num)
{
case errnum_t::NOT_ENOUGH_MEMORY:
cerr << "ERROR: Not enough memory." << endl;
break;

case errnum_t::SIGHANDLER:
cerr << "ERROR: Could not install signal handler." << endl;
break;

default: break;
}
}
8 changes: 6 additions & 2 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ using std::endl;
// Previous song select timeout (4 secs)
#define SID2_PREV_SONG_TIMEOUT 4000


const char* ERR_NOT_ENOUGH_MEMORY = "ERROR: Not enough memory.";


#ifdef HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H
# include <sidplayfp/builders/residfp.h>
const char ConsolePlayer::RESIDFP_ID[] = "ReSIDfp";
Expand Down Expand Up @@ -530,7 +534,7 @@ bool ConsolePlayer::createOutput (output_t driver, const SidTuneInfo *tuneInfo)
if (!m_driver.device)
{
m_driver.device = &m_driver.null;
displayError (errnum_t::NOT_ENOUGH_MEMORY);
displayError (ERR_NOT_ENOUGH_MEMORY);
return false;
}

Expand Down Expand Up @@ -743,7 +747,7 @@ bool ConsolePlayer::createSidEmu (SIDEMUS emu, const SidTuneInfo *tuneInfo)
{
if (emu > EMU_DEFAULT)
{ // No sid emulation?
displayError (errnum_t::NOT_ENOUGH_MEMORY);
displayError (ERR_NOT_ENOUGH_MEMORY);
return false;
}
}
Expand Down
14 changes: 2 additions & 12 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ enum class output_t
END
};

// Error and status message numbers.
enum class errnum_t
{
NOT_ENOUGH_MEMORY,
SIGHANDLER
};

// Songlength DB.
enum class sldb_t
{
Expand All @@ -128,9 +121,6 @@ enum class sldb_t
MD5
};

void displayError (const char *arg0, errnum_t num);


// Grouped global variables
class ConsolePlayer
{
Expand Down Expand Up @@ -248,8 +238,6 @@ class ConsolePlayer

bool createOutput (output_t driver, const SidTuneInfo *tuneInfo);
bool createSidEmu (SIDEMUS emu, const SidTuneInfo *tuneInfo);
void displayError (const char *error);
void displayError (errnum_t num) { ::displayError (m_name, num); }
void decodeKeys (void);
void updateDisplay();
void emuflush (void);
Expand All @@ -269,6 +257,8 @@ class ConsolePlayer
ConsolePlayer (const char * const name);
virtual ~ConsolePlayer() = default;

void displayError(const char *error);

int args (int argc, const char *argv[]);
bool open (void);
void close (void);
Expand Down

0 comments on commit b4bea56

Please sign in to comment.