Prefer EXIT_SUCCESS and EXIT_FAILURE defines.

This commit is contained in:
Peter Simons 2010-02-24 17:24:33 +01:00
parent 1d2616d1e9
commit e4f1835752
9 changed files with 47 additions and 49 deletions

View File

@ -44,13 +44,13 @@ void approve_main(char* mail)
if (chdir(MasterConfig->ack_queue_dir) == -1)
{
syslog(LOG_ERR, "Can't change directory to \"%s\": %s", MasterConfig->ack_queue_dir, strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
if (regcomp(&preg, cookie_regex, REG_EXTENDED | REG_ICASE) != 0)
{
syslog(LOG_CRIT, "Can't compile my internal regular expressions. This is serious!");
exit(1);
exit(EXIT_FAILURE);
}
offset = 0;
@ -87,7 +87,7 @@ void approve_main(char* mail)
if (((signed char)system(cmd)) == -1)
{
syslog(LOG_ERR, "system() failed for \"%s\": %s", buffer, strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
}
else

View File

@ -14,14 +14,12 @@ gnulib_modules=( git-version-gen gitlog-to-changelog gnupload progname
$gnulibtool --m4-base build-aux --source-base libgnu --import "${gnulib_modules[@]}"
sed -i -e 's/^sc_prohibit_atoi_atof/disabled_sc_prohibit_atoi_atof/' \
-e 's/^sc_prohibit_magic_number_exit/disabled_sc_prohibit_magic_number_exit/' \
-e 's/^sc_prohibit_strcmp/disabled_sc_prohibit_strcmp/' \
-e 's/^sc_require_config_h/disabled_sc_require_config_h/' \
-e 's/^sc_useless_cpp_parens/disabled_sc_useless_cpp_parens/' \
maint.mk
# -e 's/^sc_prohibit_magic_number_exit/disabled_sc_prohibit_magic_number_exit/' \
# -e 's/^sc_prohibit_strcmp/disabled_sc_prohibit_strcmp/' \
# -e 's/^sc_require_config_h/disabled_sc_require_config_h/' \
# -e 's/^sc_useless_cpp_parens/disabled_sc_useless_cpp_parens/' \
build-aux/gitlog-to-changelog >ChangeLog
autoreconf --install -Wall

View File

@ -229,7 +229,7 @@ const struct List_Config* getListConfig(const char * listname)
if (stat(buffer, &sb) != 0)
{
syslog(LOG_ERR, "Can't find a config file for list \"%s\".", listname);
exit(1);
exit(EXIT_FAILURE);
}
}
}
@ -238,7 +238,7 @@ const struct List_Config* getListConfig(const char * listname)
if (rc != 0)
{
syslog(LOG_ERR, "Failed to parse the list \"%s\"'s config file.", listname);
exit(1);
exit(EXIT_FAILURE);
}
/* Do consistency checks. */
@ -246,7 +246,7 @@ const struct List_Config* getListConfig(const char * listname)
if (listtype == NULL)
{
syslog(LOG_ERR, "List \"%s\" doesn't have a valid type in config file.", listname);
exit(1);
exit(EXIT_FAILURE);
}
/* Set up the list config structure. */
@ -255,7 +255,7 @@ const struct List_Config* getListConfig(const char * listname)
if (ListConfig == NULL)
{
syslog(LOG_ERR, "Failed to allocate %d byte of memory.", sizeof(struct List_Config));
exit(1);
exit(EXIT_FAILURE);
}
if (!strcasecmp(listtype, "open"))
ListConfig->listtype = LIST_OPEN;
@ -270,7 +270,7 @@ const struct List_Config* getListConfig(const char * listname)
else
{
syslog(LOG_ERR, "List \"%s\" doesn't have a valid type in config file.", listname);
exit(1);
exit(EXIT_FAILURE);
}
if (!strcasecmp(subtype, "public"))
@ -282,7 +282,7 @@ const struct List_Config* getListConfig(const char * listname)
else
{
syslog(LOG_ERR, "List \"%s\" doesn't have a valid subscription type in config file.", listname);
exit(1);
exit(EXIT_FAILURE);
}
ListConfig->allowmembers = allowmembers;

View File

@ -80,7 +80,7 @@ void hermes_main(char * incoming_mail, const char * listname)
if (isValidListName(listname) == FALSE)
{
syslog(LOG_ERR, "Mailing list \"%s\" does not exist.", listname);
exit(1);
exit(EXIT_FAILURE);
}
PostingHeaders = xmalloc(strlen(MailStruct->Header)+1024);
sprintf(envelope, "%s-owner@%s", listname, ListConfig->fqdn);
@ -89,7 +89,7 @@ void hermes_main(char * incoming_mail, const char * listname)
/* Check for authorization. */
if (FindBodyPassword(MailStruct) != 0)
exit(1);
exit(EXIT_FAILURE);
if (isValidPostingPassword(MailStruct->Approve, listname) == FALSE)
{
@ -104,14 +104,14 @@ void hermes_main(char * incoming_mail, const char * listname)
if (checkACL(MailStruct, listname, &operation, &parameter, ACL_PRE) != 0)
{
syslog(LOG_ERR, "checkACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
}
rc = handleACL(MailStruct, listname, operation, parameter);
switch(rc)
{
case -1:
syslog(LOG_ERR, "handleACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
case 0:
break;
case 1:
@ -299,14 +299,14 @@ void hermes_main(char * incoming_mail, const char * listname)
if (checkACL(MailStruct, listname, &operation, &parameter, ACL_POST) != 0)
{
syslog(LOG_ERR, "checkACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
}
rc = handleACL(MailStruct, listname, operation, parameter);
switch(rc)
{
case -1:
syslog(LOG_ERR, "handleACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
case 0:
break;
case 1:
@ -406,7 +406,7 @@ void hermes_main(char * incoming_mail, const char * listname)
if (p == NULL)
{
syslog(LOG_ERR, "Failed reading the header file for list \"%s\".", listname);
exit(1);
exit(EXIT_FAILURE);
}
strcpy(dst, p);
dst += strlen(p);
@ -421,7 +421,7 @@ void hermes_main(char * incoming_mail, const char * listname)
if (buffer == NULL)
{
syslog(LOG_ERR, "Failed reading the signature file for list \"%s\".", listname);
exit(1);
exit(EXIT_FAILURE);
}
MailStruct->ListSignature = buffer;
}
@ -440,7 +440,7 @@ void hermes_main(char * incoming_mail, const char * listname)
{
syslog(LOG_ERR, "Postingfilter \"%s\" returned error %d while processing posting " \
"for list \"%s\".", ListConfig->postingfilter, rc, listname);
exit(1);
exit(EXIT_FAILURE);
}
}
@ -450,7 +450,7 @@ void hermes_main(char * incoming_mail, const char * listname)
if (rc != 0)
{
syslog(LOG_ERR, "The attempt to deliver the article to the subscribers failed.");
exit(1);
exit(EXIT_FAILURE);
}
syslog(LOG_INFO, "Posted article from \"%s\" to list \"%s\" successfully.",

View File

@ -2483,7 +2483,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
|| strncmp(HELP_ARG, *arg_p + LONG_PREFIX_LENGTH, len) == 0) {
if (argv_interactive) {
do_usage(grid, global_usage);
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2492,7 +2492,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
if (strncmp(USAGE_SHORT_ARG, *arg_p + LONG_PREFIX_LENGTH, len) == 0) {
if (argv_interactive) {
do_usage(grid, GLOBAL_USAGE_SHORT);
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2501,7 +2501,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
if (strncmp(USAGE_LONG_ARG, *arg_p + LONG_PREFIX_LENGTH, len) == 0) {
if (argv_interactive) {
do_usage(grid, GLOBAL_USAGE_LONG);
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2510,7 +2510,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
if (strncmp(USAGE_ALL_ARG, *arg_p + LONG_PREFIX_LENGTH, len) == 0) {
if (argv_interactive) {
do_usage(grid, GLOBAL_USAGE_ALL);
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2529,7 +2529,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
argv_program, argv_help_string);
}
}
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2547,7 +2547,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
(void)fprintf(argv_error_stream, "%s\n", argv_version_string);
}
}
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2558,7 +2558,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
if (argv_error_stream != NULL) {
display_variables(grid);
}
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}
@ -2623,7 +2623,7 @@ static void do_list(argv_t *grid, const int arg_c, char **argv,
if ((*arg_p)[SHORT_PREFIX_LENGTH + char_c] == USAGE_CHAR_ARG) {
if (argv_interactive) {
do_usage(grid, global_usage);
(void)exit(0);
(void)exit(EXIT_SUCCESS);
}
continue;
}

View File

@ -66,13 +66,13 @@ void listserv_main(char * incoming_mail, char * default_list)
if (checkACL(MailStruct, NULL, &operator, &parameter, ACL_PRE) != 0) {
syslog(LOG_ERR, "checkACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
}
rc = handleACL(MailStruct, NULL, operator, parameter);
switch(rc) {
case -1:
syslog(LOG_ERR, "handleACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
case 0:
break;
case 1:
@ -80,13 +80,13 @@ void listserv_main(char * incoming_mail, char * default_list)
}
if (checkACL(MailStruct, NULL, &operator, &parameter, ACL_POST) != 0) {
syslog(LOG_ERR, "checkACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
}
rc = handleACL(MailStruct, NULL, operator, parameter);
switch(rc) {
case -1:
syslog(LOG_ERR, "handleACL() failed with an error.");
exit(1);
exit(EXIT_FAILURE);
case 0:
break;
case 1:
@ -136,7 +136,7 @@ void listserv_main(char * incoming_mail, char * default_list)
default_list);
if (rc != 0) {
syslog(LOG_ERR, "Error occured while handling command.");
exit(1);
exit(EXIT_FAILURE);
}
found++;
break;

18
main.c
View File

@ -73,7 +73,7 @@ main(int argc, char * argv[])
if (getcwd(buf, sizeof(buf)) == NULL)
{
syslog(LOG_CRIT, "Failed to get the path to my current working directory.");
exit(1);
exit(EXIT_FAILURE);
}
who_am_i = text_easy_sprintf("%s/%s", buf, argv[0]);
}
@ -94,7 +94,7 @@ main(int argc, char * argv[])
if ((!strcasecmp(mode, "deliver") || !strcasecmp(mode, "dump")) && listname == NULL)
{
fprintf(stderr, "petidomo: %s mode requires a list name argument\n", mode);
exit(1);
exit(EXIT_FAILURE);
}
/* Member Dump Mode */
@ -106,18 +106,18 @@ main(int argc, char * argv[])
if (InitPetidomo(masterconfig_path) != 0)
{
fprintf(stderr, "petidomo: failed load master configuration.\n");
exit(1);
exit(EXIT_FAILURE);
}
MasterConfig = getMasterConfig();
ListConfig = getListConfig(listname);
if ((cp = loadfile(ListConfig->address_file)) == NULL)
{
fprintf(stderr, "petidomo: failed to open file \"%s\"\n", ListConfig->address_file);
exit(1);
exit(EXIT_FAILURE);
}
fwrite(cp, strlen(cp), 1, stdout);
free(cp);
exit(0);
exit(EXIT_SUCCESS);
}
/* Log a few helpful facts about this Petidomo instance. */
@ -130,7 +130,7 @@ main(int argc, char * argv[])
if (InitPetidomo(masterconfig_path) != 0) {
syslog(LOG_CRIT, "Failed to initialize my internals.");
exit(1);
exit(EXIT_FAILURE);
}
MasterConfig = getMasterConfig();
@ -140,7 +140,7 @@ main(int argc, char * argv[])
incoming_mail = LoadFromDescriptor(STDIN_FILENO);
if (incoming_mail == NULL) {
syslog(LOG_ERR, "Failed to read incoming mail from standard input.");
exit(1);
exit(EXIT_FAILURE);
}
/* Now decide what we actually do with the mail. */
@ -154,7 +154,7 @@ main(int argc, char * argv[])
else
{
syslog(LOG_ERR, "Wrong command line syntax; deliver mode requires a parameter.");
exit(1);
exit(EXIT_FAILURE);
}
}
else if (strcasecmp("approve", mode) == 0)
@ -164,7 +164,7 @@ main(int argc, char * argv[])
else
{
syslog(LOG_ERR, "I don't know anything about mode \"%s\".", mode);
exit(1);
exit(EXIT_FAILURE);
}
/* Exit gracefully. */

View File

@ -37,7 +37,7 @@ char* queue_command(const struct Mail* mail, const char* command)
if (fh == NULL)
{
syslog(LOG_ERR, "Opening ack spool file \"%s\" failed: %s", buffer, strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
fprintf(fh, "#!/bin/sh\n");
fprintf(fh, "%s \\\n--masterconf=%s \\\n--mode=listserv --approved \\\n<<[end-of-%s-marker]\n", who_am_i, masterconfig_path, cookie);

View File

@ -37,7 +37,7 @@ char* queue_posting(const struct Mail* mail, const char* listname)
if (fh == NULL)
{
syslog(LOG_ERR, "Opening ack spool file \"%s\" failed: %s", buffer, strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
fprintf(fh, "#! /bin/sh\n");
fprintf(fh, "\n");