Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a single

call to FATAL().

git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
J. Alexander Treuman 2007-05-26 18:15:54 +00:00
parent dba45a5992
commit bba444524e
21 changed files with 135 additions and 273 deletions

View File

@ -127,23 +127,21 @@ void initAudioDriver(void)
if (!initAudioOutput(output, param)) { if (!initAudioOutput(output, param)) {
if (param) if (param)
{ {
ERROR("problems configuring output device " FATAL("problems configuring output device "
"defined at line %i\n", param->line); "defined at line %i\n", param->line);
} }
else else
{ {
ERROR("No audio_output specified and unable to " FATAL("No audio_output specified and unable to "
"detect a default audio output device\n"); "detect a default audio output device\n");
} }
exit(EXIT_FAILURE);
} }
/* require output names to be unique: */ /* require output names to be unique: */
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (!strcmp(output->name, audioOutputArray[j].name)) { if (!strcmp(output->name, audioOutputArray[j].name)) {
ERROR("output devices with identical " FATAL("output devices with identical "
"names: %s\n", output->name); "names: %s\n", output->name);
exit(EXIT_FAILURE);
} }
} }
audioDeviceStates[i] = DEVICE_ENABLE; audioDeviceStates[i] = DEVICE_ENABLE;
@ -169,9 +167,8 @@ void initAudioConfig(void)
audio_configFormat = xmalloc(sizeof(AudioFormat)); audio_configFormat = xmalloc(sizeof(AudioFormat));
if (0 != parseAudioConfig(audio_configFormat, param->value)) { if (0 != parseAudioConfig(audio_configFormat, param->value)) {
ERROR("error parsing \"%s\" at line %i\n", FATAL("error parsing \"%s\" at line %i\n",
CONF_AUDIO_OUTPUT_FORMAT, param->line); CONF_AUDIO_OUTPUT_FORMAT, param->line);
exit(EXIT_FAILURE);
} }
} }

View File

@ -58,10 +58,9 @@ void finishAudioOutputPlugins(void)
#define getBlockParam(name, str, force) { \ #define getBlockParam(name, str, force) { \
bp = getBlockParam(param, name); \ bp = getBlockParam(param, name); \
if(force && bp == NULL) { \ if(force && bp == NULL) { \
ERROR("couldn't find parameter \"%s\" in audio output " \ FATAL("couldn't find parameter \"%s\" in audio output " \
"definition beginning at %i\n", \ "definition beginning at %i\n", \
name, param->line); \ name, param->line); \
exit(EXIT_FAILURE); \
} \ } \
if(bp) str = bp->value; \ if(bp) str = bp->value; \
} }
@ -81,9 +80,8 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0); getBlockParam(AUDIO_OUTPUT_FORMAT, format, 0);
if (!findInList(audioOutputPluginList, type, &data)) { if (!findInList(audioOutputPluginList, type, &data)) {
ERROR("couldn't find audio output plugin for type " FATAL("couldn't find audio output plugin for type "
"\"%s\" at line %i\n", type, param->line); "\"%s\" at line %i\n", type, param->line);
exit(EXIT_FAILURE);
} }
plugin = (AudioOutputPlugin *) data; plugin = (AudioOutputPlugin *) data;
@ -141,8 +139,7 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param)
ao->convertAudioFormat = 1; ao->convertAudioFormat = 1;
if (0 != parseAudioConfig(&ao->reqAudioFormat, format)) { if (0 != parseAudioConfig(&ao->reqAudioFormat, format)) {
ERROR("error parsing format at line %i\n", bp->line); FATAL("error parsing format at line %i\n", bp->line);
exit(EXIT_FAILURE);
} }
copyAudioFormat(&ao->outAudioFormat, &ao->reqAudioFormat); copyAudioFormat(&ao->outAudioFormat, &ao->reqAudioFormat);

View File

@ -75,9 +75,8 @@ static int audioOutputAo_initDriver(AudioOutput * audioOutput,
if ((blockParam = getBlockParam(param, "write_size"))) { if ((blockParam = getBlockParam(param, "write_size"))) {
ad->writeSize = strtol(blockParam->value, &test, 10); ad->writeSize = strtol(blockParam->value, &test, 10);
if (*test != '\0') { if (*test != '\0') {
ERROR("\"%s\" is not a valid write size at line %i\n", FATAL("\"%s\" is not a valid write size at line %i\n",
blockParam->value, blockParam->line); blockParam->value, blockParam->line);
exit(EXIT_FAILURE);
} }
} else } else
ad->writeSize = 1024; ad->writeSize = 1024;
@ -92,16 +91,13 @@ static int audioOutputAo_initDriver(AudioOutput * audioOutput,
if (!blockParam || 0 == strcmp(blockParam->value, "default")) { if (!blockParam || 0 == strcmp(blockParam->value, "default")) {
ad->driverId = ao_default_driver_id(); ad->driverId = ao_default_driver_id();
} else if ((ad->driverId = ao_driver_id(blockParam->value)) < 0) { } else if ((ad->driverId = ao_driver_id(blockParam->value)) < 0) {
ERROR("\"%s\" is not a valid ao driver at line %i\n", FATAL("\"%s\" is not a valid ao driver at line %i\n",
blockParam->value, blockParam->line); blockParam->value, blockParam->line);
exit(EXIT_FAILURE);
} }
if ((ai = ao_driver_info(ad->driverId)) == NULL) { if ((ai = ao_driver_info(ad->driverId)) == NULL) {
ERROR("problems getting driver info for device defined at " FATAL("problems getting driver info for device defined at line %i\n"
"line %i\n", param->line); "you may not have permission to the audio device\n" param->line);
ERROR("you may not have permission to the audio device\n");
exit(EXIT_FAILURE);
} }
DEBUG("using ao driver \"%s\" for \"%s\"\n", ai->short_name, DEBUG("using ao driver \"%s\" for \"%s\"\n", ai->short_name,
@ -120,11 +116,8 @@ static int audioOutputAo_initDriver(AudioOutput * audioOutput,
while (n1) { while (n1) {
stk2 = NULL; stk2 = NULL;
key = strtok_r(n1, "=", &stk2); key = strtok_r(n1, "=", &stk2);
if (!key) { if (!key)
ERROR("problems parsing " FATAL("problems parsing options \"%s\"\n", n1);
"options \"%s\"\n", n1);
exit(EXIT_FAILURE);
}
/*found = 0; /*found = 0;
for(i=0;i<ai->option_count;i++) { for(i=0;i<ai->option_count;i++) {
if(strcmp(ai->options[i],key)==0) { if(strcmp(ai->options[i],key)==0) {
@ -133,17 +126,13 @@ static int audioOutputAo_initDriver(AudioOutput * audioOutput,
} }
} }
if(!found) { if(!found) {
ERROR("\"%s\" is not an option for " FATAL("\"%s\" is not an option for "
"\"%s\" ao driver\n",key, "\"%s\" ao driver\n",key,
ai->short_name); ai->short_name);
exit(EXIT_FAILURE);
} */ } */
value = strtok_r(NULL, "", &stk2); value = strtok_r(NULL, "", &stk2);
if (!value) { if (!value)
ERROR("problems parsing " FATAL("problems parsing options \"%s\"\n", n1);
"options \"%s\"\n", n1);
exit(EXIT_FAILURE);
}
ao_append_option(&ad->options, key, value); ao_append_option(&ad->options, key, value);
n1 = strtok_r(NULL, ";", &stk1); n1 = strtok_r(NULL, ";", &stk1);
} }

View File

@ -359,7 +359,7 @@ static int oss_open_default(AudioOutput *ao, ConfigParam *param, OssData *od)
} }
if (param) if (param)
ERROR("Error trying to open specified OSS device" ERROR("error trying to open specified OSS device"
" at line %i\n", param->line); " at line %i\n", param->line);
else else
ERROR("error trying to open default OSS device\n"); ERROR("error trying to open default OSS device\n");

View File

@ -100,10 +100,9 @@ static void freeShoutData(ShoutData * sd)
#define checkBlockParam(name) { \ #define checkBlockParam(name) { \
blockParam = getBlockParam(param, name); \ blockParam = getBlockParam(param, name); \
if(!blockParam) { \ if (!blockParam) { \
ERROR("no \"%s\" defined for shout device defined at line " \ FATAL("no \"%s\" defined for shout device defined at line " \
"%i\n", name, param->line); \ "%i\n", name, param->line); \
exit(EXIT_FAILURE); \
} \ } \
} }
@ -138,9 +137,8 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
port = strtol(blockParam->value, &test, 10); port = strtol(blockParam->value, &test, 10);
if (*test != '\0' || port <= 0) { if (*test != '\0' || port <= 0) {
ERROR("shout port \"%s\" is not a positive integer, line %i\n", FATAL("shout port \"%s\" is not a positive integer, line %i\n",
blockParam->value, blockParam->line); blockParam->value, blockParam->line);
exit(EXIT_FAILURE);
} }
checkBlockParam("password"); checkBlockParam("password");
@ -151,14 +149,13 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
blockParam = getBlockParam(param, "public"); blockParam = getBlockParam(param, "public");
if (blockParam) { if (blockParam) {
if (0 == strcmp(blockParam->value, "yes")) if (0 == strcmp(blockParam->value, "yes")) {
public = 1; public = 1;
else if (0 == strcmp(blockParam->value, "no")) } else if (0 == strcmp(blockParam->value, "no")) {
public = 0; public = 0;
else { } else {
ERROR("public \"%s\" is not \"yes\" or \"no\" at line " FATAL("public \"%s\" is not \"yes\" or \"no\" at line "
"%i\n", param->value, param->line); "%i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
} else } else
public = 0; public = 0;
@ -177,35 +174,31 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
sd->quality = strtod(blockParam->value, &test); sd->quality = strtod(blockParam->value, &test);
if (*test != '\0' || sd->quality < -1.0 || sd->quality > 10.0) { if (*test != '\0' || sd->quality < -1.0 || sd->quality > 10.0) {
ERROR("shout quality \"%s\" is not a number in the " FATAL("shout quality \"%s\" is not a number in the "
"range -1 to 10, line %i\n", blockParam->value, "range -1 to 10, line %i\n", blockParam->value,
blockParam->line); blockParam->line);
exit(EXIT_FAILURE);
} }
blockParam = getBlockParam(param, "bitrate"); blockParam = getBlockParam(param, "bitrate");
if (blockParam) { if (blockParam) {
ERROR("quality (line %i) and bitrate (line %i) are " FATAL("quality (line %i) and bitrate (line %i) are "
"both defined for shout output\n", line, "both defined for shout output\n", line,
blockParam->line); blockParam->line);
exit(EXIT_FAILURE);
} }
} else { } else {
blockParam = getBlockParam(param, "bitrate"); blockParam = getBlockParam(param, "bitrate");
if (!blockParam) { if (!blockParam) {
ERROR("neither bitrate nor quality defined for shout " FATAL("neither bitrate nor quality defined for shout "
"output at line %i\n", param->line); "output at line %i\n", param->line);
exit(EXIT_FAILURE);
} }
sd->bitrate = strtol(blockParam->value, &test, 10); sd->bitrate = strtol(blockParam->value, &test, 10);
if (*test != '\0' || sd->bitrate <= 0) { if (*test != '\0' || sd->bitrate <= 0) {
ERROR("bitrate at line %i should be a positive integer " FATAL("bitrate at line %i should be a positive integer "
"\n", blockParam->line); "\n", blockParam->line);
exit(EXIT_FAILURE);
} }
} }
@ -225,25 +218,22 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP) shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP)
!= SHOUTERR_SUCCESS || != SHOUTERR_SUCCESS ||
shout_set_agent(sd->shoutConn, "MPD") != SHOUTERR_SUCCESS) { shout_set_agent(sd->shoutConn, "MPD") != SHOUTERR_SUCCESS) {
ERROR("error configuring shout defined at line %i: %s\n", FATAL("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shoutConn)); param->line, shout_get_error(sd->shoutConn));
exit(EXIT_FAILURE);
} }
/* optional paramters */ /* optional paramters */
blockParam = getBlockParam(param, "genre"); blockParam = getBlockParam(param, "genre");
if (blockParam && shout_set_genre(sd->shoutConn, blockParam->value)) { if (blockParam && shout_set_genre(sd->shoutConn, blockParam->value)) {
ERROR("error configuring shout defined at line %i: %s\n", FATAL("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shoutConn)); param->line, shout_get_error(sd->shoutConn));
exit(EXIT_FAILURE);
} }
blockParam = getBlockParam(param, "description"); blockParam = getBlockParam(param, "description");
if (blockParam && shout_set_description(sd->shoutConn, if (blockParam && shout_set_description(sd->shoutConn,
blockParam->value)) { blockParam->value)) {
ERROR("error configuring shout defined at line %i: %s\n", FATAL("error configuring shout defined at line %i: %s\n",
param->line, shout_get_error(sd->shoutConn)); param->line, shout_get_error(sd->shoutConn));
exit(EXIT_FAILURE);
} }
{ {

View File

@ -115,10 +115,8 @@ static void registerConfigParam(char *name, int repeatable, int block)
{ {
ConfigEntry *entry; ConfigEntry *entry;
if (findInList(configEntriesList, name, NULL)) { if (findInList(configEntriesList, name, NULL))
ERROR("config parameter \"%s\" already registered\n", name); FATAL("config parameter \"%s\" already registered\n", name);
exit(EXIT_FAILURE);
}
entry = newConfigEntry(repeatable, block); entry = newConfigEntry(repeatable, block);
@ -225,19 +223,17 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
} }
if (2 != argsMinusComment) { if (2 != argsMinusComment) {
ERROR("improperly formatted config file at line %i:" FATAL("improperly formatted config file at line %i:"
" %s\n", *count, string); " %s\n", *count, string);
exit(EXIT_FAILURE);
} }
if (0 == strcmp(array[0], CONF_BLOCK_BEGIN) || if (0 == strcmp(array[0], CONF_BLOCK_BEGIN) ||
0 == strcmp(array[1], CONF_BLOCK_BEGIN) || 0 == strcmp(array[1], CONF_BLOCK_BEGIN) ||
0 == strcmp(array[0], CONF_BLOCK_END) || 0 == strcmp(array[0], CONF_BLOCK_END) ||
0 == strcmp(array[1], CONF_BLOCK_END)) { 0 == strcmp(array[1], CONF_BLOCK_END)) {
ERROR("improperly formatted config file at line %i:" FATAL("improperly formatted config file at line %i: %s\n"
" %s\n", *count, string); "in block beginning at line %i\n",
ERROR("in block beginning at line %i\n", ret->line); *count, string, ret->line);;
exit(EXIT_FAILURE);
} }
addBlockParam(ret, array[0], array[1], *count); addBlockParam(ret, array[0], array[1], *count);
@ -259,9 +255,8 @@ void readConf(char *file)
ConfigParam *param; ConfigParam *param;
if (!(fp = fopen(file, "r"))) { if (!(fp = fopen(file, "r"))) {
ERROR("problems opening file %s for reading: %s\n", file, FATAL("problems opening file %s for reading: %s\n", file,
strerror(errno)); strerror(errno));
exit(EXIT_FAILURE);
} }
while (myFgets(string, MAX_STRING_SIZE, fp)) { while (myFgets(string, MAX_STRING_SIZE, fp)) {
@ -282,15 +277,13 @@ void readConf(char *file)
} }
if (2 != argsMinusComment) { if (2 != argsMinusComment) {
ERROR("improperly formatted config file at line %i:" FATAL("improperly formatted config file at line %i:"
" %s\n", count, string); " %s\n", count, string);
exit(EXIT_FAILURE);
} }
if (!findInList(configEntriesList, array[0], &voidPtr)) { if (!findInList(configEntriesList, array[0], &voidPtr)) {
ERROR("unrecognized parameter in config file at line " FATAL("unrecognized parameter in config file at line "
"%i: %s\n", count, string); "%i: %s\n", count, string);
exit(EXIT_FAILURE);
} }
entry = (ConfigEntry *) voidPtr; entry = (ConfigEntry *) voidPtr;
@ -298,18 +291,15 @@ void readConf(char *file)
if (!(entry->mask & CONF_REPEATABLE_MASK) && if (!(entry->mask & CONF_REPEATABLE_MASK) &&
entry->configParamList->numberOfNodes) { entry->configParamList->numberOfNodes) {
param = entry->configParamList->firstNode->data; param = entry->configParamList->firstNode->data;
ERROR FATAL("config parameter \"%s\" is first defined on line "
("config parameter \"%s\" is first defined on line "
"%i and redefined on line %i\n", array[0], "%i and redefined on line %i\n", array[0],
param->line, count); param->line, count);
exit(EXIT_FAILURE);
} }
if (entry->mask & CONF_BLOCK_MASK) { if (entry->mask & CONF_BLOCK_MASK) {
if (0 != strcmp(array[1], CONF_BLOCK_BEGIN)) { if (0 != strcmp(array[1], CONF_BLOCK_BEGIN)) {
ERROR("improperly formatted config file at " FATAL("improperly formatted config file at "
"line %i: %s\n", count, string); "line %i: %s\n", count, string);
exit(EXIT_FAILURE);
} }
param = readConfigBlock(fp, &count, string); param = readConfigBlock(fp, &count, string);
} else } else
@ -400,10 +390,8 @@ ConfigParam *parseConfigFilePath(char *name, int force)
ConfigParam *param = getConfigParam(name); ConfigParam *param = getConfigParam(name);
char *path; char *path;
if (!param && force) { if (!param && force)
ERROR("config parameter \"%s\" not found\n", name); FATAL("config parameter \"%s\" not found\n", name);
exit(EXIT_FAILURE);
}
if (!param) if (!param)
return NULL; return NULL;
@ -411,9 +399,8 @@ ConfigParam *parseConfigFilePath(char *name, int force)
path = param->value; path = param->value;
if (path[0] != '/' && path[0] != '~') { if (path[0] != '/' && path[0] != '~') {
ERROR("\"%s\" is not an absolute path at line %i\n", FATAL("\"%s\" is not an absolute path at line %i\n",
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
/* Parse ~ in path */ /* Parse ~ in path */
else if (path[0] == '~') { else if (path[0] == '~') {
@ -426,17 +413,15 @@ ConfigParam *parseConfigFilePath(char *name, int force)
if (userParam) { if (userParam) {
pwd = getpwnam(userParam->value); pwd = getpwnam(userParam->value);
if (!pwd) { if (!pwd) {
ERROR("no such user %s at line %i\n", FATAL("no such user %s at line %i\n",
userParam->value, userParam->value,
userParam->line); userParam->line);
exit(EXIT_FAILURE);
} }
} else { } else {
uid_t uid = geteuid(); uid_t uid = geteuid();
if ((pwd = getpwuid(uid)) == NULL) { if ((pwd = getpwuid(uid)) == NULL) {
ERROR("problems getting passwd entry " FATAL("problems getting passwd entry "
"for current user\n"); "for current user\n");
exit(EXIT_FAILURE);
} }
} }
} else { } else {
@ -448,9 +433,8 @@ ConfigParam *parseConfigFilePath(char *name, int force)
*ch = '\0'; *ch = '\0';
pos += ch - path - 1; pos += ch - path - 1;
if ((pwd = getpwnam(path + 1)) == NULL) { if ((pwd = getpwnam(path + 1)) == NULL) {
ERROR("user \"%s\" not found at line %i\n", FATAL("user \"%s\" not found at line %i\n",
path + 1, param->line); path + 1, param->line);
exit(EXIT_FAILURE);
} }
if (foundSlash) if (foundSlash)
*ch = '/'; *ch = '/';

View File

@ -951,23 +951,18 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
&& 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) { && 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) {
if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) { if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) {
key = xstrdup(&(buffer[strlen(DIRECTORY_DIR)])); key = xstrdup(&(buffer[strlen(DIRECTORY_DIR)]));
if (!myFgets(buffer, bufferSize, fp)) { if (!myFgets(buffer, bufferSize, fp))
ERROR("Error reading db, fgets\n"); FATAL("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
/* for compatibility with db's prior to 0.11 */ /* for compatibility with db's prior to 0.11 */
if (0 == strncmp(DIRECTORY_MTIME, buffer, if (0 == strncmp(DIRECTORY_MTIME, buffer,
strlen(DIRECTORY_MTIME))) { strlen(DIRECTORY_MTIME))) {
if (!myFgets(buffer, bufferSize, fp)) { if (!myFgets(buffer, bufferSize, fp))
ERROR("Error reading db, fgets\n"); FATAL("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
} }
if (strncmp if (strncmp
(DIRECTORY_BEGIN, buffer, (DIRECTORY_BEGIN, buffer,
strlen(DIRECTORY_BEGIN))) { strlen(DIRECTORY_BEGIN))) {
ERROR("Error reading db at line: %s\n", buffer); FATAL("Error reading db at line: %s\n", buffer);
exit(EXIT_FAILURE);
} }
name = xstrdup(&(buffer[strlen(DIRECTORY_BEGIN)])); name = xstrdup(&(buffer[strlen(DIRECTORY_BEGIN)]));
@ -1001,8 +996,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
} else if (0 == strncmp(SONG_BEGIN, buffer, strlen(SONG_BEGIN))) { } else if (0 == strncmp(SONG_BEGIN, buffer, strlen(SONG_BEGIN))) {
readSongInfoIntoList(fp, directory->songs, directory); readSongInfoIntoList(fp, directory->songs, directory);
} else { } else {
ERROR("Unknown line in db: %s\n", buffer); FATAL("Unknown line in db: %s\n", buffer);
exit(EXIT_FAILURE);
} }
} }
@ -1155,21 +1149,16 @@ int readDirectoryDB(void)
int foundFsCharset = 0; int foundFsCharset = 0;
int foundVersion = 0; int foundVersion = 0;
if (!myFgets(buffer, bufferSize, fp)) { if (!myFgets(buffer, bufferSize, fp))
ERROR("Error reading db, fgets\n"); FATAL("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
if (0 == strcmp(DIRECTORY_INFO_BEGIN, buffer)) { if (0 == strcmp(DIRECTORY_INFO_BEGIN, buffer)) {
while (myFgets(buffer, bufferSize, fp) && while (myFgets(buffer, bufferSize, fp) &&
0 != strcmp(DIRECTORY_INFO_END, buffer)) { 0 != strcmp(DIRECTORY_INFO_END, buffer)) {
if (0 == strncmp(DIRECTORY_MPD_VERSION, buffer, if (0 == strncmp(DIRECTORY_MPD_VERSION, buffer,
strlen(DIRECTORY_MPD_VERSION))) strlen(DIRECTORY_MPD_VERSION)))
{ {
if (foundVersion) { if (foundVersion)
ERROR("already found " FATAL("already found version in db\n");
"version in db\n");
exit(EXIT_FAILURE);
}
foundVersion = 1; foundVersion = 1;
} else if (0 == } else if (0 ==
strncmp(DIRECTORY_FS_CHARSET, buffer, strncmp(DIRECTORY_FS_CHARSET, buffer,
@ -1178,11 +1167,8 @@ int readDirectoryDB(void)
char *fsCharset; char *fsCharset;
char *tempCharset; char *tempCharset;
if (foundFsCharset) { if (foundFsCharset)
WARNING("already found " FATAL("already found fs charset in db\n");
"fs charset in db\n");
exit(EXIT_FAILURE);
}
foundFsCharset = 1; foundFsCharset = 1;
@ -1198,10 +1184,8 @@ int readDirectoryDB(void)
setFsCharset(fsCharset); setFsCharset(fsCharset);
} }
} else { } else {
ERROR FATAL("directory: unknown line in db info: %s\n",
("directory: unknown line in db info: %s\n",
buffer); buffer);
exit(EXIT_FAILURE);
} }
} }
} else { } else {
@ -1233,14 +1217,12 @@ void updateMp3Directory(void)
/* nothing updated */ /* nothing updated */
return; return;
case 1: case 1:
if (writeDirectoryDB() < 0) { if (writeDirectoryDB() < 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
}
break; break;
default: default:
/* something was updated and db should be written */ /* something was updated and db should be written */
ERROR("problems updating music db\n"); FATAL("problems updating music db\n");
exit(EXIT_FAILURE);
} }
return; return;

View File

@ -81,9 +81,8 @@ void inputStream_initHttp(void)
param = getConfigParam(CONF_HTTP_PROXY_PORT); param = getConfigParam(CONF_HTTP_PROXY_PORT);
if (!param) { if (!param) {
ERROR("%s specified but not %s", CONF_HTTP_PROXY_HOST, FATAL("%s specified but not %s", CONF_HTTP_PROXY_HOST,
CONF_HTTP_PROXY_PORT); CONF_HTTP_PROXY_PORT);
exit(EXIT_FAILURE);
} }
proxyPort = param->value; proxyPort = param->value;
@ -95,10 +94,9 @@ void inputStream_initHttp(void)
param = getConfigParam(CONF_HTTP_PROXY_PASSWORD); param = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
if (!param) { if (!param) {
ERROR("%s specified but not %s\n", FATAL("%s specified but not %s\n",
CONF_HTTP_PROXY_USER, CONF_HTTP_PROXY_USER,
CONF_HTTP_PROXY_PASSWORD); CONF_HTTP_PROXY_PASSWORD);
exit(EXIT_FAILURE);
} }
proxyPassword = param->value; proxyPassword = param->value;
@ -106,24 +104,20 @@ void inputStream_initHttp(void)
param = getConfigParam(CONF_HTTP_PROXY_PASSWORD); param = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
if (param) { if (param) {
ERROR("%s specified but not %s\n", FATAL("%s specified but not %s\n",
CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_USER); CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_USER);
exit(EXIT_FAILURE);
} }
} }
} else if ((param = getConfigParam(CONF_HTTP_PROXY_PORT))) { } else if ((param = getConfigParam(CONF_HTTP_PROXY_PORT))) {
ERROR("%s specified but not %s, line %i\n", FATAL("%s specified but not %s, line %i\n",
CONF_HTTP_PROXY_PORT, CONF_HTTP_PROXY_HOST, param->line); CONF_HTTP_PROXY_PORT, CONF_HTTP_PROXY_HOST, param->line);
exit(EXIT_FAILURE);
} else if ((param = getConfigParam(CONF_HTTP_PROXY_USER))) { } else if ((param = getConfigParam(CONF_HTTP_PROXY_USER))) {
ERROR("%s specified but not %s, line %i\n", FATAL("%s specified but not %s, line %i\n",
CONF_HTTP_PROXY_USER, CONF_HTTP_PROXY_HOST, param->line); CONF_HTTP_PROXY_USER, CONF_HTTP_PROXY_HOST, param->line);
exit(EXIT_FAILURE);
} else if ((param = getConfigParam(CONF_HTTP_PROXY_PASSWORD))) { } else if ((param = getConfigParam(CONF_HTTP_PROXY_PASSWORD))) {
ERROR("%s specified but not %s, line %i\n", FATAL("%s specified but not %s, line %i\n",
CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_HOST, CONF_HTTP_PROXY_PASSWORD, CONF_HTTP_PROXY_HOST,
param->line); param->line);
exit(EXIT_FAILURE);
} }
param = getConfigParam(CONF_HTTP_BUFFER_SIZE); param = getConfigParam(CONF_HTTP_BUFFER_SIZE);
@ -132,10 +126,9 @@ void inputStream_initHttp(void)
bufferSize = strtol(param->value, &test, 10); bufferSize = strtol(param->value, &test, 10);
if (bufferSize <= 0 || *test != '\0') { if (bufferSize <= 0 || *test != '\0') {
ERROR("\"%s\" specified for %s at line %i is not a " FATAL("\"%s\" specified for %s at line %i is not a "
"positive integer\n", "positive integer\n",
param->value, CONF_HTTP_BUFFER_SIZE, param->line); param->value, CONF_HTTP_BUFFER_SIZE, param->line);
exit(EXIT_FAILURE);
} }
bufferSize *= 1024; bufferSize *= 1024;
@ -150,11 +143,10 @@ void inputStream_initHttp(void)
prebufferSize = strtol(param->value, &test, 10); prebufferSize = strtol(param->value, &test, 10);
if (prebufferSize <= 0 || *test != '\0') { if (prebufferSize <= 0 || *test != '\0') {
ERROR("\"%s\" specified for %s at line %i is not a " FATAL("\"%s\" specified for %s at line %i is not a "
"positive integer\n", "positive integer\n",
param->value, CONF_HTTP_PREBUFFER_SIZE, param->value, CONF_HTTP_PREBUFFER_SIZE,
param->line); param->line);
exit(EXIT_FAILURE);
} }
prebufferSize *= 1024; prebufferSize *= 1024;

View File

@ -585,10 +585,9 @@ void initInterfaces(void)
if (param) { if (param) {
interface_timeout = strtol(param->value, &test, 10); interface_timeout = strtol(param->value, &test, 10);
if (*test != '\0' || interface_timeout <= 0) { if (*test != '\0' || interface_timeout <= 0) {
ERROR("connection timeout \"%s\" is not a positive " FATAL("connection timeout \"%s\" is not a positive "
"integer, line %i\n", CONF_CONN_TIMEOUT, "integer, line %i\n", CONF_CONN_TIMEOUT,
param->line); param->line);
exit(EXIT_FAILURE);
} }
} }
@ -597,9 +596,8 @@ void initInterfaces(void)
if (param) { if (param) {
interface_max_connections = strtol(param->value, &test, 10); interface_max_connections = strtol(param->value, &test, 10);
if (*test != '\0' || interface_max_connections <= 0) { if (*test != '\0' || interface_max_connections <= 0) {
ERROR("max connections \"%s\" is not a positive integer" FATAL("max connections \"%s\" is not a positive integer"
", line %i\n", param->value, param->line); ", line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
} else } else
interface_max_connections = INTERFACE_MAX_CONNECTIONS_DEFAULT; interface_max_connections = INTERFACE_MAX_CONNECTIONS_DEFAULT;
@ -610,9 +608,8 @@ void initInterfaces(void)
interface_max_command_list_size = strtol(param->value, interface_max_command_list_size = strtol(param->value,
&test, 10); &test, 10);
if (*test != '\0' || interface_max_command_list_size <= 0) { if (*test != '\0' || interface_max_command_list_size <= 0) {
ERROR("max command list size \"%s\" is not a positive " FATAL("max command list size \"%s\" is not a positive "
"integer, line %i\n", param->value, param->line); "integer, line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
interface_max_command_list_size *= 1024; interface_max_command_list_size *= 1024;
} }
@ -623,9 +620,8 @@ void initInterfaces(void)
interface_max_output_buffer_size = strtol(param->value, interface_max_output_buffer_size = strtol(param->value,
&test, 10); &test, 10);
if (*test != '\0' || interface_max_output_buffer_size <= 0) { if (*test != '\0' || interface_max_output_buffer_size <= 0) {
ERROR("max output buffer size \"%s\" is not a positive " FATAL("max output buffer size \"%s\" is not a positive "
"integer, line %i\n", param->value, param->line); "integer, line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
interface_max_output_buffer_size *= 1024; interface_max_output_buffer_size *= 1024;
} }

View File

@ -41,8 +41,9 @@
#define DEFAULT_PORT 6600 #define DEFAULT_PORT 6600
#define BINDERROR() do { \ #define BINDERROR() do { \
ERROR("unable to bind port %u: %s\n", port, strerror(errno)); \ FATAL("unable to bind port %u: %s\n" \
ERROR("maybe MPD is still running?\n"); \ "maybe MPD is still running?\n", \
port, strerror(errno)); \
} while (0); } while (0);
static int *listenSockets; static int *listenSockets;
@ -69,25 +70,20 @@ static int establishListen(unsigned int port,
pf = PF_UNIX; pf = PF_UNIX;
break; break;
default: default:
ERROR("unknown address family: %i\n", addrp->sa_family); FATAL("unknown address family: %i\n", addrp->sa_family);
exit(EXIT_FAILURE);
} }
if ((sock = socket(pf, SOCK_STREAM, 0)) < 0) { if ((sock = socket(pf, SOCK_STREAM, 0)) < 0)
ERROR("socket < 0\n"); FATAL("socket < 0\n");
exit(EXIT_FAILURE);
}
if (fcntl(sock, F_SETFL, fcntl(sock, F_GETFL) | O_NONBLOCK) < 0) { if (fcntl(sock, F_SETFL, fcntl(sock, F_GETFL) | O_NONBLOCK) < 0) {
ERROR("problems setting nonblocking on listen socket: %s\n", FATAL("problems setting nonblocking on listen socket: %s\n",
strerror(errno)); strerror(errno));
exit(EXIT_FAILURE);
} }
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&allowReuse, if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&allowReuse,
sizeof(allowReuse)) < 0) { sizeof(allowReuse)) < 0) {
ERROR("problems setsockopt'ing: %s\n", strerror(errno)); FATAL("problems setsockopt'ing: %s\n", strerror(errno));
exit(EXIT_FAILURE);
} }
if (bind(sock, addrp, addrlen) < 0) { if (bind(sock, addrp, addrlen) < 0) {
@ -95,10 +91,8 @@ static int establishListen(unsigned int port,
return -1; return -1;
} }
if (listen(sock, 5) < 0) { if (listen(sock, 5) < 0)
ERROR("problems listen'ing: %s\n", strerror(errno)); FATAL("problems listen'ing: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
numberOfListenSockets++; numberOfListenSockets++;
listenSockets = listenSockets =
@ -133,10 +127,8 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
sin6.sin6_addr = in6addr_any; sin6.sin6_addr = in6addr_any;
addrp = (struct sockaddr *)&sin6; addrp = (struct sockaddr *)&sin6;
addrlen = sizeof(struct sockaddr_in6); addrlen = sizeof(struct sockaddr_in6);
if (establishListen(port, addrp, addrlen) < 0) { if (establishListen(port, addrp, addrlen) < 0)
BINDERROR(); BINDERROR();
exit(EXIT_FAILURE);
}
} }
#endif #endif
sin.sin_addr.s_addr = INADDR_ANY; sin.sin_addr.s_addr = INADDR_ANY;
@ -148,24 +140,21 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
if (establishListen(port, addrp, addrlen) < 0) { if (establishListen(port, addrp, addrlen) < 0) {
#endif #endif
BINDERROR(); BINDERROR();
exit(EXIT_FAILURE);
} }
} else { } else {
struct hostent *he; struct hostent *he;
DEBUG("binding to address for %s\n", param->value); DEBUG("binding to address for %s\n", param->value);
if (!(he = gethostbyname(param->value))) { if (!(he = gethostbyname(param->value))) {
ERROR("can't lookup host \"%s\" at line %i\n", FATAL("can't lookup host \"%s\" at line %i\n",
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
switch (he->h_addrtype) { switch (he->h_addrtype) {
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
case AF_INET6: case AF_INET6:
if (!useIpv6) { if (!useIpv6) {
ERROR("no IPv6 support, but a IPv6 address " FATAL("no IPv6 support, but a IPv6 address "
"found for \"%s\" at line %i\n", "found for \"%s\" at line %i\n",
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
memcpy((char *)&sin6.sin6_addr.s6_addr, memcpy((char *)&sin6.sin6_addr.s6_addr,
(char *)he->h_addr, he->h_length); (char *)he->h_addr, he->h_length);
@ -180,15 +169,12 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
addrlen = sizeof(struct sockaddr_in); addrlen = sizeof(struct sockaddr_in);
break; break;
default: default:
ERROR("address type for \"%s\" is not IPv4 or IPv6 " FATAL("address type for \"%s\" is not IPv4 or IPv6 "
"at line %i\n", param->value, param->line); "at line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
if (establishListen(port, addrp, addrlen) < 0) { if (establishListen(port, addrp, addrlen) < 0)
BINDERROR(); BINDERROR();
exit(EXIT_FAILURE);
}
} }
} }
@ -202,10 +188,9 @@ void listenOnPort(void)
char *test; char *test;
port = strtol(portParam->value, &test, 10); port = strtol(portParam->value, &test, 10);
if (port <= 0 || *test != '\0') { if (port <= 0 || *test != '\0') {
ERROR("%s \"%s\" specified at line %i is not a " FATAL("%s \"%s\" specified at line %i is not a "
"positive integer", CONF_PORT, "positive integer", CONF_PORT,
portParam->value, portParam->line); portParam->value, portParam->line);
exit(EXIT_FAILURE);
} }
} }

View File

@ -246,15 +246,13 @@ static void changeToUser(void)
/* get uid */ /* get uid */
struct passwd *userpwd; struct passwd *userpwd;
if ((userpwd = getpwnam(param->value)) == NULL) { if ((userpwd = getpwnam(param->value)) == NULL) {
ERROR("no such user \"%s\" at line %i\n", param->value, FATAL("no such user \"%s\" at line %i\n", param->value,
param->line); param->line);
exit(EXIT_FAILURE);
} }
if (setgid(userpwd->pw_gid) == -1) { if (setgid(userpwd->pw_gid) == -1) {
ERROR("cannot setgid for user \"%s\" at line %i: %s\n", FATAL("cannot setgid for user \"%s\" at line %i: %s\n",
param->value, param->line, strerror(errno)); param->value, param->line, strerror(errno));
exit(EXIT_FAILURE);
} }
#ifdef _BSD_SOURCE #ifdef _BSD_SOURCE
/* init suplementary groups /* init suplementary groups
@ -269,10 +267,9 @@ static void changeToUser(void)
/* set uid */ /* set uid */
if (setuid(userpwd->pw_uid) == -1) { if (setuid(userpwd->pw_uid) == -1) {
ERROR("cannot change to uid of user " FATAL("cannot change to uid of user "
"\"%s\" at line %i: %s\n", "\"%s\" at line %i: %s\n",
param->value, param->line, strerror(errno)); param->value, param->line, strerror(errno));
exit(EXIT_FAILURE);
} }
/* this is needed by libs such as arts */ /* this is needed by libs such as arts */
@ -286,10 +283,9 @@ static void openDB(Options * options, char *argv0)
{ {
if (options->createDB > 0 || readDirectoryDB() < 0) { if (options->createDB > 0 || readDirectoryDB() < 0) {
if (options->createDB < 0) { if (options->createDB < 0) {
ERROR("can't open db file and using \"--no-create-db\"" FATAL("can't open db file and using "
" command line option\n"); "\"--no-create-db\" command line option\n"
ERROR("try running \"%s --create-db\"\n", argv0); "try running \"%s --create-db\"\n", argv0);
exit(EXIT_FAILURE);
} }
flushWarningLog(); flushWarningLog();
if (checkDirectoryDB() < 0) if (checkDirectoryDB() < 0)
@ -313,11 +309,9 @@ static void daemonize(Options * options)
DEBUG("opening pid file\n"); DEBUG("opening pid file\n");
fp = fopen(pidFileParam->value, "w+"); fp = fopen(pidFileParam->value, "w+");
if (!fp) { if (!fp) {
ERROR FATAL("could not open %s \"%s\" (at line %i) for writing: %s\n",
("could not open %s \"%s\" (at line %i) for writing: %s\n",
CONF_PID_FILE, pidFileParam->value, CONF_PID_FILE, pidFileParam->value,
pidFileParam->line, strerror(errno)); pidFileParam->line, strerror(errno));
exit(EXIT_FAILURE);
} }
} }
@ -329,18 +323,15 @@ static void daemonize(Options * options)
if (pid > 0) if (pid > 0)
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
else if (pid < 0) { else if (pid < 0) {
ERROR("problems fork'ing for daemon!\n"); FATAL("problems fork'ing for daemon!\n");
exit(EXIT_FAILURE);
} }
if (chdir("/") < 0) { if (chdir("/") < 0) {
ERROR("problems changing to root directory\n"); FATAL("problems changing to root directory\n");
exit(EXIT_FAILURE);
} }
if (setsid() < 0) { if (setsid() < 0) {
ERROR("problems setsid'ing\n"); FATAL("problems setsid'ing\n");
exit(EXIT_FAILURE);
} }
fflush(NULL); fflush(NULL);
@ -348,8 +339,7 @@ static void daemonize(Options * options)
if (pid > 0) if (pid > 0)
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
else if (pid < 0) { else if (pid < 0) {
ERROR("problems fork'ing for daemon!\n"); FATAL("problems fork'ing for daemon!\n");
exit(EXIT_FAILURE);
} }
DEBUG("daemonized!\n"); DEBUG("daemonized!\n");
@ -381,26 +371,22 @@ static void killFromPidFile(char *cmd, int killOption)
int pid; int pid;
if (!pidFileParam) { if (!pidFileParam) {
ERROR("no pid_file specified in the config file\n"); FATAL("no pid_file specified in the config file\n");
exit(EXIT_FAILURE);
} }
fp = fopen(pidFileParam->value, "r"); fp = fopen(pidFileParam->value, "r");
if (!fp) { if (!fp) {
ERROR("unable to open %s \"%s\": %s\n", FATAL("unable to open %s \"%s\": %s\n",
CONF_PID_FILE, pidFileParam->value, strerror(errno)); CONF_PID_FILE, pidFileParam->value, strerror(errno));
exit(EXIT_FAILURE);
} }
if (fscanf(fp, "%i", &pid) != 1) { if (fscanf(fp, "%i", &pid) != 1) {
ERROR("unable to read the pid from file \"%s\"\n", FATAL("unable to read the pid from file \"%s\"\n",
pidFileParam->value); pidFileParam->value);
exit(EXIT_FAILURE);
} }
fclose(fp); fclose(fp);
if (kill(pid, SIGTERM)) { if (kill(pid, SIGTERM)) {
ERROR("unable to kill proccess %i: %s\n", pid, strerror(errno)); FATAL("unable to kill proccess %i: %s\n", pid, strerror(errno));
exit(EXIT_FAILURE);
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -142,18 +142,16 @@ void initPaths(void)
playlistDir = appendSlash(&(playlistParam->value)); playlistDir = appendSlash(&(playlistParam->value));
if ((dir = opendir(playlistDir)) == NULL) { if ((dir = opendir(playlistDir)) == NULL) {
ERROR("cannot open %s \"%s\" (config line %i): %s\n", FATAL("cannot open %s \"%s\" (config line %i): %s\n",
CONF_PLAYLIST_DIR, playlistParam->value, CONF_PLAYLIST_DIR, playlistParam->value,
playlistParam->line, strerror(errno)); playlistParam->line, strerror(errno));
exit(EXIT_FAILURE);
} }
closedir(dir); closedir(dir);
if ((dir = opendir(musicDir)) == NULL) { if ((dir = opendir(musicDir)) == NULL) {
ERROR("cannot open %s \"%s\" (config line %i): %s\n", FATAL("cannot open %s \"%s\" (config line %i): %s\n",
CONF_MUSIC_DIR, musicParam->value, CONF_MUSIC_DIR, musicParam->value,
musicParam->line, strerror(errno)); musicParam->line, strerror(errno));
exit(EXIT_FAILURE);
} }
closedir(dir); closedir(dir);

View File

@ -72,9 +72,8 @@ void pcm_volumeChange(char *buffer, int bufferSize, AudioFormat * format,
} }
break; break;
default: default:
ERROR("%i bits not supported by pcm_volumeChange!\n", FATAL("%i bits not supported by pcm_volumeChange!\n",
format->bits); format->bits);
exit(EXIT_FAILURE);
} }
} }
@ -129,8 +128,7 @@ static void pcm_add(char *buffer1, char *buffer2, size_t bufferSize1,
memcpy(buffer8_1, buffer8_2, bufferSize2); memcpy(buffer8_1, buffer8_2, bufferSize2);
break; break;
default: default:
ERROR("%i bits not supported by pcm_add!\n", format->bits); FATAL("%i bits not supported by pcm_add!\n", format->bits);
exit(EXIT_FAILURE);
} }
} }
@ -447,8 +445,7 @@ size_t pcm_sizeOfConvBuffer(AudioFormat * inFormat, size_t inSize,
case 16: case 16:
break; break;
default: default:
ERROR("only 8 or 16 bits are supported for conversion!\n"); FATAL("only 8 or 16 bits are supported for conversion!\n");
exit(EXIT_FAILURE);
} }
if (inFormat->channels != outFormat->channels) { if (inFormat->channels != outFormat->channels) {
@ -460,9 +457,8 @@ size_t pcm_sizeOfConvBuffer(AudioFormat * inFormat, size_t inSize,
outSize >>= 1; outSize >>= 1;
break; break;
default: default:
ERROR("only 1 or 2 channels are supported " FATAL("only 1 or 2 channels are supported "
"for conversion!\n"); "for conversion!\n");
exit(EXIT_FAILURE);
} }
} }

View File

@ -57,8 +57,7 @@ static int parsePermissions(char *string)
} else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) { } else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
permission |= PERMISSION_ADMIN; permission |= PERMISSION_ADMIN;
} else { } else {
ERROR("unknown permission \"%s\"\n", temp); FATAL("unknown permission \"%s\"\n", temp);
exit(EXIT_FAILURE);
} }
temp = strtok_r(NULL, PERMISSION_SEPERATOR, &tok); temp = strtok_r(NULL, PERMISSION_SEPERATOR, &tok);
@ -87,19 +86,16 @@ void initPermissions(void)
do { do {
if (!strstr(param->value, PERMISSION_PASSWORD_CHAR)) { if (!strstr(param->value, PERMISSION_PASSWORD_CHAR)) {
ERROR("\"%s\" not found in password string " FATAL("\"%s\" not found in password string "
"\"%s\", line %i\n", "\"%s\", line %i\n",
PERMISSION_PASSWORD_CHAR, PERMISSION_PASSWORD_CHAR,
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
if (!(temp = strtok_r(param->value, if (!(temp = strtok_r(param->value,
PERMISSION_PASSWORD_CHAR, PERMISSION_PASSWORD_CHAR,
&cp2))) { &cp2))) {
ERROR FATAL("something weird just happened in permission.c\n");
("something weird just happened in permission.c\n");
exit(EXIT_FAILURE);
} }
password = temp; password = temp;

View File

@ -53,9 +53,8 @@ void initPlayerData(void)
if (param) { if (param) {
bufferSize = strtol(param->value, &test, 10); bufferSize = strtol(param->value, &test, 10);
if (*test != '\0' || bufferSize <= 0) { if (*test != '\0' || bufferSize <= 0) {
ERROR("buffer size \"%s\" is not a positive integer, " FATAL("buffer size \"%s\" is not a positive integer, "
"line %i\n", param->value, param->line); "line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
} }
@ -64,8 +63,7 @@ void initPlayerData(void)
buffered_chunks = bufferSize / CHUNK_SIZE; buffered_chunks = bufferSize / CHUNK_SIZE;
if (buffered_chunks >= 1 << 15) { if (buffered_chunks >= 1 << 15) {
ERROR("buffer size \"%li\" is too big\n", (long)bufferSize); FATAL("buffer size \"%li\" is too big\n", (long)bufferSize);
exit(EXIT_FAILURE);
} }
param = getConfigParam(CONF_BUFFER_BEFORE_PLAY); param = getConfigParam(CONF_BUFFER_BEFORE_PLAY);
@ -73,10 +71,9 @@ void initPlayerData(void)
if (param) { if (param) {
perc = strtod(param->value, &test); perc = strtod(param->value, &test);
if (*test != '%' || perc < 0 || perc > 100) { if (*test != '%' || perc < 0 || perc > 100) {
ERROR("buffered before play \"%s\" is not a positive " FATAL("buffered before play \"%s\" is not a positive "
"percentage and less than 100 percent, line %i" "percentage and less than 100 percent, line %i"
"\n", param->value, param->line); "\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
} }
@ -97,20 +94,11 @@ void initPlayerData(void)
allocationSize += device_array_size; allocationSize += device_array_size;
if ((shmid = shmget(IPC_PRIVATE, allocationSize, IPC_CREAT | 0600)) < 0) if ((shmid = shmget(IPC_PRIVATE, allocationSize, IPC_CREAT | 0600)) < 0)
{ FATAL("problems shmget'ing\n");
ERROR("problems shmget'ing\n");
exit(EXIT_FAILURE);
}
if (!(playerData_pd = shmat(shmid, NULL, 0))) if (!(playerData_pd = shmat(shmid, NULL, 0)))
{ FATAL("problems shmat'ing\n");
ERROR("problems shmat'ing\n");
exit(EXIT_FAILURE);
}
if (shmctl(shmid, IPC_RMID, NULL) < 0) if (shmctl(shmid, IPC_RMID, NULL) < 0)
{ FATAL("problems shmctl'ing\n");
ERROR("problems shmctl'ing\n");
exit(EXIT_FAILURE);
}
playerData_pd->audioDeviceStates = (mpd_uint8 *)playerData_pd + playerData_pd->audioDeviceStates = (mpd_uint8 *)playerData_pd +
allocationSize - device_array_size; allocationSize - device_array_size;

View File

@ -135,9 +135,8 @@ void initPlaylist(void)
if (param) { if (param) {
playlist_max_length = strtol(param->value, &test, 10); playlist_max_length = strtol(param->value, &test, 10);
if (*test != '\0') { if (*test != '\0') {
ERROR("max playlist length \"%s\" is not an integer, " FATAL("max playlist length \"%s\" is not an integer, "
"line %i\n", param->value, param->line); "line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
} }

View File

@ -44,9 +44,8 @@ void initReplayGainState(void)
} else if (strcmp(param->value, "album") == 0) { } else if (strcmp(param->value, "album") == 0) {
replayGainState = REPLAYGAIN_ALBUM; replayGainState = REPLAYGAIN_ALBUM;
} else { } else {
ERROR("replaygain value \"%s\" at line %i is invalid\n", FATAL("replaygain value \"%s\" at line %i is invalid\n",
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
param = getConfigParam(CONF_REPLAYGAIN_PREAMP); param = getConfigParam(CONF_REPLAYGAIN_PREAMP);
@ -56,15 +55,13 @@ void initReplayGainState(void)
float f = strtod(param->value, &test); float f = strtod(param->value, &test);
if (*test != '\0') { if (*test != '\0') {
ERROR("Replaygain preamp \"%s\" is not a number at " FATAL("Replaygain preamp \"%s\" is not a number at "
"line %i\n", param->value, param->line); "line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
if (f < -15 || f > 15) { if (f < -15 || f > 15) {
ERROR("Replaygain preamp \"%s\" is not between -15 and" FATAL("Replaygain preamp \"%s\" is not between -15 and"
"15 at line %i\n", param->value, param->line); "15 at line %i\n", param->value, param->line);
exit(EXIT_FAILURE);
} }
replayGainPreamp = pow(10, f / 20.0); replayGainPreamp = pow(10, f / 20.0);

View File

@ -251,10 +251,8 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
song->type = SONG_TYPE_FILE; song->type = SONG_TYPE_FILE;
song->parentDir = parentDir; song->parentDir = parentDir;
} else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) { } else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) {
if (!song) { if (!song)
ERROR("Problems reading song info\n"); FATAL("Problems reading song info\n");
exit(EXIT_FAILURE);
}
/* we don't need this info anymore /* we don't need this info anymore
song->url = xstrdup(&(buffer[strlen(SONG_FILE)])); song->url = xstrdup(&(buffer[strlen(SONG_FILE)]));
*/ */
@ -273,10 +271,8 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
song->mtime = atoi(&(buffer[strlen(SONG_MTIME)])); song->mtime = atoi(&(buffer[strlen(SONG_MTIME)]));
} }
/* ignore empty lines (starting with '\0') */ /* ignore empty lines (starting with '\0') */
else if (*buffer) { else if (*buffer)
ERROR("songinfo: unknown line in db: %s\n", buffer); FATAL("songinfo: unknown line in db: %s\n", buffer);
exit(EXIT_FAILURE);
}
} }
if (song) { if (song) {

View File

@ -87,16 +87,13 @@ void read_state_file(void)
DEBUG("failed to stat state file: %s\n", sfpath); DEBUG("failed to stat state file: %s\n", sfpath);
return; return;
} }
if (!S_ISREG(st.st_mode)) { if (!S_ISREG(st.st_mode))
ERROR("state file \"%s\" is not a regular file\n", sfpath); FATAL("state file \"%s\" is not a regular file\n", sfpath);
exit(EXIT_FAILURE);
}
while (!(fp = fopen(sfpath, "r")) && errno == EINTR); while (!(fp = fopen(sfpath, "r")) && errno == EINTR);
if (mpd_unlikely(!fp)) { if (mpd_unlikely(!fp)) {
ERROR("problems opening state file \"%s\" for reading: %s\n", FATAL("problems opening state file \"%s\" for reading: %s\n",
sfpath, strerror(errno)); sfpath, strerror(errno));
exit(EXIT_FAILURE);
} }
for (i = 0; i < ARRAY_SIZE(sf_callbacks); i++) { for (i = 0; i < ARRAY_SIZE(sf_callbacks); i++) {
sf_callbacks[i].reader(fp); sf_callbacks[i].reader(fp);
@ -108,7 +105,6 @@ void read_state_file(void)
void mpd_noreturn state_file_fatal(void) void mpd_noreturn state_file_fatal(void)
{ {
ERROR("error parsing state file \"%s\"\n", sfpath); FATAL("error parsing state file \"%s\"\n", sfpath);
exit(EXIT_FAILURE);
} }

View File

@ -103,9 +103,8 @@ void initTagConfig(void)
} }
} }
if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) { if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) {
ERROR("error parsing metadata item \"%s\" at " FATAL("error parsing metadata item \"%s\" at "
"line %i\n", c, param->line); "line %i\n", c, param->line);
exit(EXIT_FAILURE);
} }
s++; s++;
c = s; c = s;

View File

@ -430,9 +430,8 @@ void initVolume(void)
volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE; volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE;
volume_mixerDevice = VOLUME_MIXER_SOFTWARE_DEFAULT; volume_mixerDevice = VOLUME_MIXER_SOFTWARE_DEFAULT;
} else { } else {
ERROR("unknown mixer type %s at line %i\n", FATAL("unknown mixer type %s at line %i\n",
param->value, param->line); param->value, param->line);
exit(EXIT_FAILURE);
} }
} }