From: Amos Jeffries Date: Fri, 16 Jun 2017 18:38:19 +0000 (+1200) Subject: Cleanup: use EXIT_FAILURE and EXIT_SUCCESS instead of magic numbers in exit() X-Git-Tag: M-staged-PR71~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24885773d0a2e2e770bf534ae0c609c70bb04514;p=thirdparty%2Fsquid.git Cleanup: use EXIT_FAILURE and EXIT_SUCCESS instead of magic numbers in exit() ... and return EXIT_SUCCESS from main() functions. --- diff --git a/lib/hash.cc b/lib/hash.cc index 3bd3bf38b3..30c387b056 100644 --- a/lib/hash.cc +++ b/lib/hash.cc @@ -339,7 +339,7 @@ main(void) printf("creating hash table\n"); if ((hid = hash_create((HASHCMP *) strcmp, 229, hash4)) < 0) { printf("hash_create error.\n"); - exit(1); + exit(EXIT_FAILURE); } printf("done creating hash table: %d\n", hid); @@ -375,7 +375,7 @@ main(void) printf("done walking hash table...\n"); printf("driver finished.\n"); - exit(0); + return EXIT_SUCCESS; } #endif diff --git a/src/DiskIO/DiskDaemon/diskd.cc b/src/DiskIO/DiskDaemon/diskd.cc index f2ad7cb123..2b698d02e7 100644 --- a/src/DiskIO/DiskDaemon/diskd.cc +++ b/src/DiskIO/DiskDaemon/diskd.cc @@ -321,7 +321,7 @@ main(int argc, char *argv[]) if (rmsgid < 0) { perror("msgget"); - return 1; + exit(EXIT_FAILURE); } key = atoi(argv[2]); @@ -329,7 +329,7 @@ main(int argc, char *argv[]) if (smsgid < 0) { perror("msgget"); - return 1; + exit(EXIT_FAILURE); } key = atoi(argv[3]); @@ -337,21 +337,21 @@ main(int argc, char *argv[]) if (shmid < 0) { perror("shmget"); - return 1; + exit(EXIT_FAILURE); } shmbuf = (char *)shmat(shmid, NULL, 0); if (shmbuf == (void *) -1) { perror("shmat"); - return 1; + exit(EXIT_FAILURE); } hash = hash_create(fsCmp, 1 << 4, fsHash); assert(hash); if (fcntl(0, F_SETFL, SQUID_NONBLOCK) < 0) { perror(xstrerr(errno)); - return 1; + exit(EXIT_FAILURE); } memset(&sa, '\0', sizeof(sa)); sa.sa_handler = alarm_handler; @@ -413,6 +413,6 @@ main(int argc, char *argv[]) if (shmctl(shmid, IPC_RMID, 0) < 0) perror("shmctl IPC_RMID"); - return 0; + return EXIT_SUCCESS; } diff --git a/src/WinSvc.cc b/src/WinSvc.cc index 2042b1f836..21a515bd9b 100644 --- a/src/WinSvc.cc +++ b/src/WinSvc.cc @@ -734,7 +734,7 @@ WIN32_InstallService() if ((lenpath = GetModuleFileName(NULL, ServicePath, 512)) == 0) { fprintf(stderr, "Can't get executable path\n"); - exit(1); + exit(EXIT_FAILURE); } snprintf(szPath, sizeof(szPath), "%s %s:" SQUIDSBUFPH, ServicePath, _WIN_SQUID_SERVICE_OPTION, SQUIDSBUFPRINT(service_name)); @@ -745,7 +745,7 @@ WIN32_InstallService() if (!schSCManager) { fprintf(stderr, "OpenSCManager failed\n"); - exit(1); + exit(EXIT_FAILURE); } else { schService = CreateService(schSCManager, /* SCManager database */ service, /* name of service */ @@ -788,7 +788,7 @@ WIN32_InstallService() printf("Don't forget to edit squid.conf before starting it.\n\n"); } else { fprintf(stderr, "CreateService failed\n"); - exit(1); + exit(EXIT_FAILURE); } CloseServiceHandle(schSCManager); @@ -813,7 +813,7 @@ WIN32_sendSignal(int WIN32_signal) if (!schSCManager) { fprintf(stderr, "OpenSCManager failed\n"); - exit(1); + exit(EXIT_FAILURE); } /* The required service object access depends on the control. */ @@ -852,7 +852,7 @@ WIN32_sendSignal(int WIN32_signal) break; default: - exit(1); + exit(EXIT_FAILURE); } /* Open a handle to the service. */ @@ -862,7 +862,7 @@ WIN32_sendSignal(int WIN32_signal) if (schService == NULL) { fprintf(stderr, "%s: ERROR: Could not open Service " SQUIDSBUFPH "\n", APP_SHORTNAME, SQUIDSBUFPRINT(service_name)); - exit(1); + exit(EXIT_FAILURE); } else { /* Send a control value to the service. */ @@ -871,7 +871,7 @@ WIN32_sendSignal(int WIN32_signal) &ssStatus)) { /* address of status info */ fprintf(stderr, "%s: ERROR: Could not Control Service " SQUIDSBUFPH "\n", APP_SHORTNAME, SQUIDSBUFPRINT(service_name)); - exit(1); + exit(EXIT_FAILURE); } else { /* Print the service status. */ printf("\nStatus of " SQUIDSBUFPH " Service:\n", SQUIDSBUFPRINT(service_name)); diff --git a/src/acl/external/AD_group/ext_ad_group_acl.cc b/src/acl/external/AD_group/ext_ad_group_acl.cc index 18e7cf4f20..64dae2ae2d 100644 --- a/src/acl/external/AD_group/ext_ad_group_acl.cc +++ b/src/acl/external/AD_group/ext_ad_group_acl.cc @@ -235,7 +235,7 @@ My_NameTranslate(wchar_t * name, int in_format, int out_format) if (FAILED(hr)) { debug("My_NameTranslate: cannot initialize COM interface, ERROR: %s\n", Get_WIN32_ErrorMessage(hr)); /* This is a fatal error */ - exit(1); + exit(EXIT_FAILURE); } WIN32_COM_initialized = 1; } @@ -247,14 +247,14 @@ My_NameTranslate(wchar_t * name, int in_format, int out_format) if (FAILED(hr)) { debug("My_NameTranslate: cannot create COM instance, ERROR: %s\n", Get_WIN32_ErrorMessage(hr)); /* This is a fatal error */ - exit(1); + exit(EXIT_FAILURE); } hr = pNto->lpVtbl->Init(pNto, ADS_NAME_INITTYPE_GC, L""); if (FAILED(hr)) { debug("My_NameTranslate: cannot initialise NameTranslate API, ERROR: %s\n", Get_WIN32_ErrorMessage(hr)); pNto->lpVtbl->Release(pNto); /* This is a fatal error */ - exit(1); + exit(EXIT_FAILURE); } hr = pNto->lpVtbl->Set(pNto, in_format, name); if (FAILED(hr)) { @@ -753,18 +753,17 @@ process_options(int argc, char *argv[]) break; case 'h': usage(argv[0]); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ default: fprintf(stderr, "%s: FATAL: Unknown option: -%c. Exiting\n", program_name, opt); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); break; /* not reached */ } } - return; } int @@ -795,7 +794,7 @@ main(int argc, char *argv[]) if (use_global) { if ((machinedomain = GetDomainName()) == NULL) { fprintf(stderr, "%s: FATAL: Can't read machine domain\n", program_name); - exit(1); + exit(EXIT_FAILURE); } strlwr(machinedomain); if (!DefaultDomain) @@ -854,6 +853,6 @@ main(int argc, char *argv[]) } err = 0; } - return 0; + return EXIT_SUCCESS; } diff --git a/src/acl/external/LDAP_group/ext_ldap_group_acl.cc b/src/acl/external/LDAP_group/ext_ldap_group_acl.cc index 6bf5a5e906..ac6e10ff28 100644 --- a/src/acl/external/LDAP_group/ext_ldap_group_acl.cc +++ b/src/acl/external/LDAP_group/ext_ldap_group_acl.cc @@ -260,7 +260,7 @@ main(int argc, char **argv) case 'H': #if !HAS_URI_SUPPORT fprintf(stderr, "FATAL: Your LDAP library does not have URI support\n"); - exit(1); + exit(EXIT_FAILURE); #endif /* Fall thru to -h */ case 'h': @@ -298,7 +298,7 @@ main(int argc, char **argv) searchscope = LDAP_SCOPE_SUBTREE; else { fprintf(stderr, PROGRAM_NAME ": FATAL: Unknown search scope '%s'\n", value); - exit(1); + exit(EXIT_FAILURE); } break; case 'E': @@ -308,7 +308,7 @@ main(int argc, char **argv) port = LDAPS_PORT; #else fprintf(stderr, PROGRAM_NAME ": FATAL: -E unsupported with this LDAP library\n"); - exit(1); + exit(EXIT_FAILURE); #endif break; case 'c': @@ -328,7 +328,7 @@ main(int argc, char **argv) aliasderef = LDAP_DEREF_FINDING; else { fprintf(stderr, PROGRAM_NAME ": FATAL: Unknown alias dereference method '%s'\n", value); - exit(1); + exit(EXIT_FAILURE); } break; case 'D': @@ -360,14 +360,14 @@ main(int argc, char **argv) break; default: fprintf(stderr, "FATAL: Protocol version should be 2 or 3\n"); - exit(1); + exit(EXIT_FAILURE); } break; case 'Z': if (version == LDAP_VERSION2) { fprintf(stderr, "FATAL: TLS (-Z) is incompatible with version %d\n", version); - exit(1); + exit(EXIT_FAILURE); } version = LDAP_VERSION3; use_tls = 1; @@ -387,7 +387,7 @@ main(int argc, char **argv) break; default: fprintf(stderr, PROGRAM_NAME ": FATAL: Unknown command line option '%c'\n", option); - exit(1); + exit(EXIT_FAILURE); } } @@ -443,7 +443,7 @@ main(int argc, char **argv) fprintf(stderr, "\t-d\t\t\tenable debug mode\n"); fprintf(stderr, "\n"); fprintf(stderr, "\tIf you need to bind as a user to perform searches then use the\n\t-D binddn -w bindpasswd or -D binddn -W secretfile options\n\n"); - exit(1); + exit(EXIT_FAILURE); } /* On Windows ldap_start_tls_s is available starting from Windows XP, * so we need to bind at run-time with the function entry point @@ -456,7 +456,7 @@ main(int argc, char **argv) WLDAP32Handle = GetModuleHandle("wldap32"); if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { fprintf(stderr, PROGRAM_NAME ": FATAL: TLS (-Z) not supported on this platform.\n"); - exit(1); + exit(EXIT_FAILURE); } } #endif @@ -525,14 +525,14 @@ recover: if (sslpath) { if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) { fprintf(stderr, "FATAL: Unable to initialise SSL with cert path %s\n", sslpath); - exit(1); + exit(EXIT_FAILURE); } else { ++sslinit; } if ((ld = ldapssl_init(ldapServer, port, 1)) == NULL) { fprintf(stderr, "FATAL: Unable to connect to SSL LDAP server: %s port:%d\n", ldapServer, port); - exit(1); + exit(EXIT_FAILURE); } } else #endif @@ -559,7 +559,7 @@ recover: #ifdef LDAP_OPT_X_TLS if (version != LDAP_VERSION3) { fprintf(stderr, "FATAL: TLS requires LDAP version 3\n"); - exit(1); + exit(EXIT_FAILURE); } else if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { broken = HLP_MSG("Could not Activate TLS connection"); fprintf(stderr, "ERROR: %s\n", broken); @@ -569,7 +569,7 @@ recover: } #else fprintf(stderr, "FATAL: TLS not supported with your LDAP library\n"); - exit(1); + exit(EXIT_FAILURE); #endif } #endif @@ -621,7 +621,7 @@ recover: } if (ld) ldap_unbind(ld); - return 0; + return EXIT_SUCCESS; } static std::string diff --git a/src/acl/external/LM_group/ext_lm_group_acl.cc b/src/acl/external/LM_group/ext_lm_group_acl.cc index 7d2cc8a084..52713efe2e 100644 --- a/src/acl/external/LM_group/ext_lm_group_acl.cc +++ b/src/acl/external/LM_group/ext_lm_group_acl.cc @@ -492,14 +492,14 @@ process_options(int argc, char *argv[]) break; case 'h': usage(argv[0]); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ default: fprintf(stderr, "%s: FATAL: Unknown option: -%c. Exiting\n", program_name, opt); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); break; /* not reached */ } } @@ -534,7 +534,7 @@ main(int argc, char *argv[]) if (use_global) { if ((machinedomain = GetDomainName()) == NULL) { fprintf(stderr, "%s: FATAL: Can't read machine domain\n", program_name); - exit(1); + exit(EXIT_FAILURE); } strlwr(machinedomain); if (!DefaultDomain) @@ -594,6 +594,6 @@ main(int argc, char *argv[]) SEND_ERR(""); } } - return 0; + return EXIT_SUCCESS; } diff --git a/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc b/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc index 68dcd53142..776dcb3b75 100644 --- a/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc +++ b/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc @@ -1474,7 +1474,7 @@ SigTrap(int s) CloseLDAP(&edui_ldap); debug("Terminating, Signal: %d\n", s); - exit(0); + exit(EXIT_SUCCESS); } /* diff --git a/src/acl/external/file_userip/ext_file_userip_acl.cc b/src/acl/external/file_userip/ext_file_userip_acl.cc index e0c73e5ba7..6d184f7a1f 100644 --- a/src/acl/external/file_userip/ext_file_userip_acl.cc +++ b/src/acl/external/file_userip/ext_file_userip_acl.cc @@ -237,23 +237,23 @@ main (int argc, char *argv[]) break; case 'h': usage(program_name); - exit (0); + exit(EXIT_SUCCESS); default: fprintf(stderr, "%s: FATAL: Unknown parameter option '%c'", program_name, ch); usage(program_name); - exit (1); + exit(EXIT_FAILURE); } } if (filename == NULL) { fprintf(stderr, "%s: FATAL: No Filename configured.", program_name); usage(program_name); - exit(1); + exit(EXIT_FAILURE); } FILE *FH = fopen(filename, "r"); if (!FH) { int xerrno = errno; fprintf(stderr, "%s: FATAL: Unable to open file '%s': %s", program_name, filename, xstrerr(xerrno)); - exit(1); + exit(EXIT_FAILURE); } current_entry = load_dict(FH); @@ -289,6 +289,6 @@ main (int argc, char *argv[]) } fclose (FH); - return 0; + return EXIT_SUCCESS; } diff --git a/src/acl/external/kerberos_ldap_group/kerberos_ldap_group.cc b/src/acl/external/kerberos_ldap_group/kerberos_ldap_group.cc index 5e7277d9f3..b5117a3bb7 100644 --- a/src/acl/external/kerberos_ldap_group/kerberos_ldap_group.cc +++ b/src/acl/external/kerberos_ldap_group/kerberos_ldap_group.cc @@ -296,7 +296,7 @@ main(int argc, char *const argv[]) fprintf(stderr, "server@domain - In this case server can be used for Kerberos domain domain\n"); fprintf(stderr, "server1a@domain1:server1b@domain1:server2@domain2:server3@:server4 - A list is build with a colon as separator\n"); clean_args(&margs); - exit(0); + exit(EXIT_SUCCESS); default: warn((char *) "%s| %s: WARNING: unknown option: -%c.\n", LogTime(), PROGRAM, opt); } @@ -309,7 +309,7 @@ main(int argc, char *const argv[]) debug((char *) "%s| %s: FATAL: Error in group list: %s\n", LogTime(), PROGRAM, margs.glist ? margs.glist : "NULL"); SEND_BH(""); clean_args(&margs); - exit(1); + exit(EXIT_FAILURE); } else { debug((char *) "%s| %s: INFO: no group list given expect it from stdin\n", LogTime(), PROGRAM); gopt = 1; @@ -319,13 +319,13 @@ main(int argc, char *const argv[]) debug((char *) "%s| %s: FATAL: Error in netbios list: %s\n", LogTime(), PROGRAM, margs.nlist ? margs.nlist : "NULL"); SEND_BH(""); clean_args(&margs); - exit(1); + exit(EXIT_FAILURE); } if (create_ls(&margs)) { debug((char *) "%s| %s: Error in ldap server list: %s\n", LogTime(), PROGRAM, margs.llist ? margs.llist : "NULL"); SEND_BH(""); clean_args(&margs); - exit(1); + exit(EXIT_FAILURE); } #if HAVE_KRB5 @@ -343,7 +343,7 @@ main(int argc, char *const argv[]) error((char *) "%s| %s: ERROR: Error while initialising Kerberos library : %s\n", LogTime(), PROGRAM, error_message(code)); SEND_BH(""); clean_args(&margs); - exit(1); + exit(EXIT_FAILURE); } #endif @@ -359,14 +359,14 @@ main(int argc, char *const argv[]) #if HAVE_KRB5 krb5_cleanup(); #endif - exit(1); /* BIIG buffer */ + exit(EXIT_FAILURE); /* BIIG buffer */ } SEND_BH("fgets NULL"); clean_args(&margs); #if HAVE_KRB5 krb5_cleanup(); #endif - exit(0); + exit(EXIT_SUCCESS); } c = (char *) memchr(buf, '\n', sizeof(buf) - 1); if (c) { @@ -438,7 +438,7 @@ main(int argc, char *const argv[]) krb5_cleanup(); #endif - exit(-1); + exit(EXIT_SUCCESS); } if (gopt) { if ((group = strtok(NULL, " \n")) != NULL) { @@ -494,6 +494,7 @@ main(int argc, char *const argv[]) fprintf(stdout, "ERR\n"); fprintf(stderr, "LDAP group authorisation not supported\n"); } + return EXIT_SUCCESS } #endif diff --git a/src/acl/external/session/ext_session_acl.cc b/src/acl/external/session/ext_session_acl.cc index bd023bd13a..009f67c357 100644 --- a/src/acl/external/session/ext_session_acl.cc +++ b/src/acl/external/session/ext_session_acl.cc @@ -76,7 +76,7 @@ static void init_db(void) if (db_env->open(db_env, db_path, DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK , 0666)) { fprintf(stderr, "FATAL: %s: Failed to open database environment in '%s'\n", program_name, db_path); db_env->close(db_env, 0); - exit(1); + exit(EXIT_FAILURE); } db_create(&db, db_env, 0); } @@ -88,13 +88,13 @@ static void init_db(void) fprintf(stderr, "FATAL: %s: Failed to open db file '%s' in dir '%s'\n", program_name, "session", db_path); db_env->close(db_env, 0); - exit(1); + exit(EXIT_FAILURE); } } else { db_create(&db, NULL, 0); if (db->open(db, NULL, db_path, NULL, DB_BTREE, DB_CREATE, 0666)) { fprintf(stderr, "FATAL: %s: Failed to open session db '%s'\n", program_name, db_path); - exit(1); + exit(EXIT_FAILURE); } } } @@ -180,7 +180,7 @@ int main(int argc, char **argv) break; case '?': usage(); - exit(0); + exit(EXIT_SUCCESS); break; } } @@ -197,7 +197,7 @@ int main(int argc, char **argv) // Only 1 paramater supplied. We are expecting at least 2 (including the channel ID) fprintf(stderr, "FATAL: %s is concurrent and requires the concurrency option to be specified.\n", program_name); shutdown_db(); - exit(1); + exit(EXIT_FAILURE); } char *lastdetail = strrchr(detail, ' '); size_t detail_len = strlen(detail); @@ -236,6 +236,6 @@ int main(int argc, char **argv) } } shutdown_db(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/acl/external/time_quota/ext_time_quota_acl.cc b/src/acl/external/time_quota/ext_time_quota_acl.cc index 3c7ec6933d..0027f58aa5 100644 --- a/src/acl/external/time_quota/ext_time_quota_acl.cc +++ b/src/acl/external/time_quota/ext_time_quota_acl.cc @@ -151,7 +151,7 @@ static void init_db(void) db = dbopen(db_path, O_CREAT | O_RDWR, 0666, DB_BTREE, NULL); if (!db) { log_fatal("Failed to open time_quota db '%s'\n", db_path); - exit(1); + exit(EXIT_FAILURE); } } @@ -430,7 +430,7 @@ int main(int argc, char **argv) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); break; } } @@ -442,7 +442,7 @@ int main(int argc, char **argv) if ( optind + 1 != argc ) { usage(); - exit(1); + exit(EXIT_FAILURE); } else { readConfig(argv[optind]); } @@ -459,6 +459,6 @@ int main(int argc, char **argv) } log_info("Ending %s\n", __FILE__); shutdown_db(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/acl/external/unix_group/check_group.cc b/src/acl/external/unix_group/check_group.cc index b7fdf598c7..5b8d23640e 100644 --- a/src/acl/external/unix_group/check_group.cc +++ b/src/acl/external/unix_group/check_group.cc @@ -185,13 +185,13 @@ main(int argc, char *argv[]) default: usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } } if (optind < argc) { fprintf(stderr, "FATAL: Unknown option '%s'\n", argv[optind]); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } while (fgets(buf, HELPER_INPUT_BUFFER, stdin)) { j = 0; @@ -245,6 +245,6 @@ main(int argc, char *argv[]) SEND_ERR(""); } } - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/LDAP/basic_ldap_auth.cc b/src/auth/basic/LDAP/basic_ldap_auth.cc index 3c0a92f974..b5d46fbd75 100644 --- a/src/auth/basic/LDAP/basic_ldap_auth.cc +++ b/src/auth/basic/LDAP/basic_ldap_auth.cc @@ -262,7 +262,7 @@ open_ldap_connection(const char *ldapServer, int port) int rc = ldap_initialize(&ld, ldapServer); if (rc != LDAP_SUCCESS) { fprintf(stderr, "\nUnable to connect to LDAPURI:%s\n", ldapServer); - exit(1); + exit(EXIT_FAILURE); } } else #endif @@ -271,21 +271,21 @@ open_ldap_connection(const char *ldapServer, int port) if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) { fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n", sslpath); - exit(1); + exit(EXIT_FAILURE); } else { ++sslinit; } if ((ld = ldapssl_init(ldapServer, port, 1)) == NULL) { fprintf(stderr, "\nUnable to connect to SSL LDAP server: %s port:%d\n", ldapServer, port); - exit(1); + exit(EXIT_FAILURE); } } else #endif if ((ld = ldap_init(ldapServer, port)) == NULL) { fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n", ldapServer, port); - exit(1); + exit(EXIT_FAILURE); } if (connect_timeout) squid_ldap_set_connect_timeout(ld, connect_timeout); @@ -297,20 +297,20 @@ open_ldap_connection(const char *ldapServer, int port) if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version) != LDAP_SUCCESS) { fprintf(stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n", version); - exit(1); + exit(EXIT_FAILURE); } if (use_tls) { #ifdef LDAP_OPT_X_TLS if (version != LDAP_VERSION3) { fprintf(stderr, "TLS requires LDAP version 3\n"); - exit(1); + exit(EXIT_FAILURE); } else if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { fprintf(stderr, "Could not Activate TLS connection\n"); - exit(1); + exit(EXIT_FAILURE); } #else fprintf(stderr, "TLS not supported with your LDAP library\n"); - exit(1); + exit(EXIT_FAILURE); #endif } #endif @@ -386,7 +386,7 @@ main(int argc, char **argv) case 'H': #if !HAS_URI_SUPPORT fprintf(stderr, "ERROR: Your LDAP library does not have URI support\n"); - exit(1); + exit(EXIT_FAILURE); #endif /* Fall thru to -h */ case 'h': @@ -421,7 +421,7 @@ main(int argc, char **argv) searchscope = LDAP_SCOPE_SUBTREE; else { fprintf(stderr, PROGRAM_NAME ": ERROR: Unknown search scope '%s'\n", value); - exit(1); + exit(EXIT_FAILURE); } break; case 'E': @@ -431,7 +431,7 @@ main(int argc, char **argv) port = LDAPS_PORT; #else fprintf(stderr, PROGRAM_NAME " ERROR: -E unsupported with this LDAP library\n"); - exit(1); + exit(EXIT_FAILURE); #endif break; case 'c': @@ -451,7 +451,7 @@ main(int argc, char **argv) aliasderef = LDAP_DEREF_FINDING; else { fprintf(stderr, PROGRAM_NAME ": ERROR: Unknown alias dereference method '%s'\n", value); - exit(1); + exit(EXIT_FAILURE); } break; case 'D': @@ -486,14 +486,14 @@ main(int argc, char **argv) break; default: fprintf(stderr, "Protocol version should be 2 or 3\n"); - exit(1); + exit(EXIT_FAILURE); } break; case 'Z': if (version == LDAP_VERSION2) { fprintf(stderr, "TLS (-Z) is incompatible with version %d\n", version); - exit(1); + exit(EXIT_FAILURE); } version = LDAP_VERSION3; use_tls = 1; @@ -504,7 +504,7 @@ main(int argc, char **argv) break; default: fprintf(stderr, PROGRAM_NAME ": ERROR: Unknown command line option '%c'\n", option); - exit(1); + exit(EXIT_FAILURE); } } @@ -555,7 +555,7 @@ main(int argc, char **argv) fprintf(stderr, "\n"); fprintf(stderr, "\tIf no search filter is specified, then the dn =user,basedn\n\twill be used (same as specifying a search filter of '=',\n\tbut quicker as as there is no need to search for the user DN)\n\n"); fprintf(stderr, "\tIf you need to bind as a user to perform searches then use the\n\t-D binddn -w bindpasswd or -D binddn -W secretfile options\n\n"); - exit(1); + exit(EXIT_FAILURE); } /* On Windows ldap_start_tls_s is available starting from Windows XP, * so we need to bind at run-time with the function entry point @@ -568,7 +568,7 @@ main(int argc, char **argv) WLDAP32Handle = GetModuleHandle("wldap32"); if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { fprintf(stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n"); - exit(1); + exit(EXIT_FAILURE); } } #endif @@ -613,7 +613,7 @@ recover: } if (ld) ldap_unbind(ld); - return 0; + return EXIT_SUCCESS; } static int @@ -787,7 +787,7 @@ readSecret(const char *filename) passwd = (char *) calloc(sizeof(char), strlen(buf) + 1); if (!passwd) { fprintf(stderr, PROGRAM_NAME " ERROR: can not allocate memory\n"); - exit(1); + exit(EXIT_FAILURE); } strcpy(passwd, buf); bindpasswd = passwd; diff --git a/src/auth/basic/NCSA/basic_ncsa_auth.cc b/src/auth/basic/NCSA/basic_ncsa_auth.cc index 97655554f8..50e7f96f0d 100644 --- a/src/auth/basic/NCSA/basic_ncsa_auth.cc +++ b/src/auth/basic/NCSA/basic_ncsa_auth.cc @@ -55,7 +55,7 @@ read_passwd_file(const char *passwdfile) if (!f) { int xerrno = errno; fprintf(stderr, "FATAL: %s: %s\n", passwdfile, xstrerr(xerrno)); - exit(1); + exit(EXIT_FAILURE); } unsigned int lineCount = 0; buf[HELPER_INPUT_BUFFER-1] = '\0'; @@ -87,11 +87,11 @@ main(int argc, char **argv) setbuf(stdout, NULL); if (argc != 2) { fprintf(stderr, "Usage: ncsa_auth \n"); - exit(1); + exit(EXIT_FAILURE); } if (stat(argv[1], &sb) != 0) { fprintf(stderr, "FATAL: cannot stat %s\n", argv[1]); - exit(1); + exit(EXIT_FAILURE); } while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) { if ((p = strchr(buf, '\n')) != NULL) @@ -152,6 +152,6 @@ main(int argc, char **argv) } SEND_ERR("Wrong password"); } - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/basic/NIS/basic_nis_auth.cc b/src/auth/basic/NIS/basic_nis_auth.cc index f53dfe3079..47c53359fb 100644 --- a/src/auth/basic/NIS/basic_nis_auth.cc +++ b/src/auth/basic/NIS/basic_nis_auth.cc @@ -47,7 +47,7 @@ main(int argc, char **argv) fprintf(stderr, "Usage: basic_nis_auth \n"); fprintf(stderr, "\n"); fprintf(stderr, "Example basic_nis_auth mydomain.com passwd.byname\n"); - exit(1); + exit(EXIT_FAILURE); } nisdomain = argv[1]; nismap = argv[2]; @@ -90,6 +90,6 @@ main(int argc, char **argv) printf("BH message=\"Missing crypto capability\"\n"); #endif } - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/basic/PAM/basic_pam_auth.cc b/src/auth/basic/PAM/basic_pam_auth.cc index d6cff854db..e907345860 100644 --- a/src/auth/basic/PAM/basic_pam_auth.cc +++ b/src/auth/basic/PAM/basic_pam_auth.cc @@ -197,14 +197,14 @@ main(int argc, char *argv[]) default: fprintf(stderr, "FATAL: Unknown getopt value '%c'\n", ch); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } } start: if (optind < argc) { fprintf(stderr, "FATAL: Unknown option '%s'\n", argv[optind]); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } while (fgets(buf, HELPER_INPUT_BUFFER, stdin)) { @@ -308,6 +308,6 @@ error: debug("ERROR: failed to release PAM authenticator\n"); } } - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/RADIUS/basic_radius_auth.cc b/src/auth/basic/RADIUS/basic_radius_auth.cc index c4510980b2..24d65e1d93 100644 --- a/src/auth/basic/RADIUS/basic_radius_auth.cc +++ b/src/auth/basic/RADIUS/basic_radius_auth.cc @@ -510,21 +510,21 @@ main(int argc, char **argv) } /* make standard output line buffered */ if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) - return 1; + exit(EXIT_FAILURE); if (cfname) { if (rad_auth_config(cfname) < 0) { fprintf(stderr, "FATAL: %s: can't open configuration file '%s'.\n", argv[0], cfname); - exit(1); + exit(EXIT_FAILURE); } } if (!*server) { fprintf(stderr, "FATAL: %s: Server not specified\n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } if (!*secretkey) { fprintf(stderr, "FATAL: %s: Shared secret not specified\n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } #if _SQUID_WINDOWS_ { @@ -547,12 +547,12 @@ main(int argc, char **argv) /* Get the IP address of the authentication server */ if ((auth_ipaddr = get_ipaddr(server)) == 0) { fprintf(stderr, "FATAL: %s: Couldn't find host %s\n", argv[0], server); - exit(1); + exit(EXIT_FAILURE); } sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { perror("socket"); - exit(1); + exit(EXIT_FAILURE); } memset(&saremote, 0, sizeof(saremote)); saremote.sin_family = AF_INET; @@ -561,18 +561,18 @@ main(int argc, char **argv) if (connect(sockfd, (struct sockaddr *) &saremote, sizeof(saremote)) < 0) { perror("connect"); - exit(1); + exit(EXIT_FAILURE); } salen = sizeof(salocal); if (getsockname(sockfd, (struct sockaddr *) &salocal, &salen) < 0) { perror("getsockname"); - exit(1); + exit(EXIT_FAILURE); } #ifdef O_NONBLOCK if (fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK) < 0) { int xerrno = errno; fprintf(stderr,"%s| ERROR: fcntl() failure: %s\n", argv[0], xstrerr(xerrno)); - exit(1); + exit(EXIT_FAILURE); } #endif nas_ipaddr = ntohl(salocal.sin_addr.s_addr); @@ -613,6 +613,6 @@ main(int argc, char **argv) authenticate(sockfd, username, passwd); } close(sockfd); - exit(1); + return EXIT_SUCCESS; } diff --git a/src/auth/basic/SASL/basic_sasl_auth.cc b/src/auth/basic/SASL/basic_sasl_auth.cc index 8622e586da..f9f93af3b1 100644 --- a/src/auth/basic/SASL/basic_sasl_auth.cc +++ b/src/auth/basic/SASL/basic_sasl_auth.cc @@ -67,7 +67,7 @@ main(int, char *argv[]) if ( rc != SASL_OK ) { fprintf(stderr, "FATAL: %d %s\n", rc, sasl_errstring(rc, NULL, NULL )); - return 1; + exit(EXIT_FAILURE); } #if SASL_VERSION_MAJOR < 2 @@ -78,7 +78,7 @@ main(int, char *argv[]) if ( rc != SASL_OK ) { fprintf(stderr, "FATAL: %d %s\n", rc, sasl_errstring(rc, NULL, NULL )); - return 1; + exit(EXIT_FAILURE); } while ( fgets( line, HELPER_INPUT_BUFFER, stdin )) { @@ -126,6 +126,6 @@ main(int, char *argv[]) sasl_dispose(&conn); sasl_done(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/SMB/basic_smb_auth.cc b/src/auth/basic/SMB/basic_smb_auth.cc index ce101a5755..dca4574197 100644 --- a/src/auth/basic/SMB/basic_smb_auth.cc +++ b/src/auth/basic/SMB/basic_smb_auth.cc @@ -98,7 +98,7 @@ main(int argc, char *argv[]) /* make standard output line buffered */ if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) - return 1; + exit(EXIT_FAILURE); /* parse command line arguments */ for (i = 1; i < argc; ++i) { @@ -157,7 +157,7 @@ main(int argc, char *argv[]) if (strcmp(argv[i], "-S") == 0) { if (lastdom != NULL) { if ((lastdom->authshare = xstrdup(argv[++i])) == NULL) - return 1; + exit(EXIT_FAILURE); /* convert backslashes to forward slashes */ for (s = lastdom->authshare; *s != '\0'; ++s) @@ -236,6 +236,7 @@ main(int argc, char *argv[]) else SEND_ERR(""); } /* while (1) */ - return 0; + + return EXIT_SUCCESS; } diff --git a/src/auth/basic/SMB_LM/msntauth.cc b/src/auth/basic/SMB_LM/msntauth.cc index fe4aab9549..78c488f6c4 100644 --- a/src/auth/basic/SMB_LM/msntauth.cc +++ b/src/auth/basic/SMB_LM/msntauth.cc @@ -106,14 +106,14 @@ main(int argc, char **argv) if (dc.domain.length() == 0 || dc.server.length() == 0) { std::cerr << "Error: invalid domain specification in '" << arg << "'. Ignoring." << std::endl; - exit(1); + exit(EXIT_FAILURE); } domaincontrollers.push_back(dc); } if (domaincontrollers.empty()) { display_usage_instructions(); std::cerr << "Error: no domain controllers specified" << std::endl; - exit(1); + exit(EXIT_FAILURE); } while (1) { @@ -162,6 +162,6 @@ main(int argc, char **argv) err = 0; } - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/SSPI/basic_sspi_auth.cc b/src/auth/basic/SSPI/basic_sspi_auth.cc index 158baefd94..f55a3dccd5 100644 --- a/src/auth/basic/SSPI/basic_sspi_auth.cc +++ b/src/auth/basic/SSPI/basic_sspi_auth.cc @@ -97,14 +97,14 @@ process_options(int argc, char *argv[]) break; case 'h': usage(argv[0]); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ default: fprintf(stderr, "FATAL: Unknown option: -%c\n", opt); usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } } } @@ -125,7 +125,7 @@ main(int argc, char **argv) if (LoadSecurityDll(SSP_BASIC, NTLM_PACKAGE_NAME) == NULL) { fprintf(stderr, "FATAL: can't initialize SSPI, exiting.\n"); - exit(1); + exit(EXIT_FAILURE); } debug("SSPI initialized OK\n"); @@ -177,6 +177,6 @@ main(int argc, char **argv) err = 0; fflush(stdout); } - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/fake/fake.cc b/src/auth/basic/fake/fake.cc index fd656d0bf7..1dc224d4c5 100644 --- a/src/auth/basic/fake/fake.cc +++ b/src/auth/basic/fake/fake.cc @@ -77,12 +77,12 @@ process_options(int argc, char *argv[]) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); default: std::cerr << program_name << ": FATAL: unknown option: -" << static_cast(optopt) << ". Exiting" << std::endl; usage(); - exit(1); + exit(EXIT_FAILURE); } } } @@ -104,6 +104,6 @@ main(int argc, char *argv[]) } ndebug(program_name << ' ' << VERSION << ' ' << SQUID_BUILD_INFO << " shutting down..."); - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/basic/getpwnam/basic_getpwnam_auth.cc b/src/auth/basic/getpwnam/basic_getpwnam_auth.cc index f3218f9373..bce573432c 100644 --- a/src/auth/basic/getpwnam/basic_getpwnam_auth.cc +++ b/src/auth/basic/getpwnam/basic_getpwnam_auth.cc @@ -125,6 +125,6 @@ main(int, char **) } } } - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/digest/LDAP/digest_pw_auth.cc b/src/auth/digest/LDAP/digest_pw_auth.cc index e6720bc095..bfb28f1833 100644 --- a/src/auth/digest/LDAP/digest_pw_auth.cc +++ b/src/auth/digest/LDAP/digest_pw_auth.cc @@ -104,9 +104,7 @@ DoOneRequest(char *buf) static void ProcessArguments(int argc, char **argv) { - int i; - i = LDAPArguments(argc, argv); - if (i) + if (int i = LDAPArguments(argc, argv)) exit(i); } @@ -118,6 +116,6 @@ main(int argc, char **argv) ProcessArguments(argc, argv); while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) DoOneRequest(buf); - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/digest/LDAP/ldap_backend.cc b/src/auth/digest/LDAP/ldap_backend.cc index 7f167e5567..932014c222 100644 --- a/src/auth/digest/LDAP/ldap_backend.cc +++ b/src/auth/digest/LDAP/ldap_backend.cc @@ -318,7 +318,7 @@ ldapconnect(void) WLDAP32Handle = GetModuleHandle("wldap32"); if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { fprintf(stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n"); - exit(1); + exit(EXIT_FAILURE); } } #endif @@ -337,14 +337,14 @@ ldapconnect(void) if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) { fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n", sslpath); - exit(1); + exit(EXIT_FAILURE); } else { ++sslinit; } if ((ld = ldapssl_init(ldapServer, port, 1)) == NULL) { fprintf(stderr, "\nUnable to connect to SSL LDAP server: %s port:%d\n", ldapServer, port); - exit(1); + exit(EXIT_FAILURE); } } else #endif @@ -369,10 +369,10 @@ ldapconnect(void) #ifdef LDAP_OPT_X_TLS if (version != LDAP_VERSION3) { fprintf(stderr, "TLS requires LDAP version 3\n"); - exit(1); + exit(EXIT_FAILURE); } else if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { fprintf(stderr, "Could not Activate TLS connection\n"); - exit(1); + exit(EXIT_FAILURE); } #else fprintf(stderr, "TLS not supported with your LDAP library\n"); diff --git a/src/auth/digest/eDirectory/digest_pw_auth.cc b/src/auth/digest/eDirectory/digest_pw_auth.cc index 53a2c49684..23f23628df 100644 --- a/src/auth/digest/eDirectory/digest_pw_auth.cc +++ b/src/auth/digest/eDirectory/digest_pw_auth.cc @@ -103,9 +103,7 @@ DoOneRequest(char *buf) static void ProcessArguments(int argc, char **argv) { - int i; - i = LDAPArguments(argc, argv); - if (i) + if (int i = LDAPArguments(argc, argv)) exit(i); } @@ -117,6 +115,6 @@ main(int argc, char **argv) ProcessArguments(argc, argv); while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) DoOneRequest(buf); - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/digest/eDirectory/ldap_backend.cc b/src/auth/digest/eDirectory/ldap_backend.cc index 02848ed5b6..86aa8da2d1 100644 --- a/src/auth/digest/eDirectory/ldap_backend.cc +++ b/src/auth/digest/eDirectory/ldap_backend.cc @@ -344,7 +344,7 @@ ldapconnect(void) WLDAP32Handle = GetModuleHandle("wldap32"); if ((Win32_ldap_start_tls_s = (PFldap_start_tls_s) GetProcAddress(WLDAP32Handle, LDAP_START_TLS_S)) == NULL) { fprintf(stderr, PROGRAM_NAME ": ERROR: TLS (-Z) not supported on this platform.\n"); - exit(1); + exit(EXIT_FAILURE); } } #endif @@ -363,14 +363,14 @@ ldapconnect(void) if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) { fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n", sslpath); - exit(1); + exit(EXIT_FAILURE); } else { ++sslinit; } if ((ld = ldapssl_init(ldapServer, port, 1)) == NULL) { fprintf(stderr, "\nUnable to connect to SSL LDAP server: %s port:%d\n", ldapServer, port); - exit(1); + exit(EXIT_FAILURE); } } else #endif diff --git a/src/auth/digest/file/digest_file_auth.cc b/src/auth/digest/file/digest_file_auth.cc index da4e9d7663..a194408d7d 100644 --- a/src/auth/digest/file/digest_file_auth.cc +++ b/src/auth/digest/file/digest_file_auth.cc @@ -116,6 +116,6 @@ main(int argc, char **argv) ProcessArguments(argc, argv); while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) DoOneRequest(buf); - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/digest/file/text_backend.cc b/src/auth/digest/file/text_backend.cc index 23e8104f02..6c73a7d6f0 100644 --- a/src/auth/digest/file/text_backend.cc +++ b/src/auth/digest/file/text_backend.cc @@ -76,13 +76,13 @@ read_passwd_file(const char *passwordFile, int isHa1Mode) hash = hash_create((HASHCMP *) strcmp, 7921, hash_string); if (NULL == hash) { fprintf(stderr, "digest_file_auth: cannot create hash table\n"); - exit(1); + exit(EXIT_FAILURE); } FILE *f = fopen(passwordFile, "r"); if (!f) { int xerrno = errno; fprintf(stderr, "digest_file_auth: cannot open password file: %s\n", xstrerr(xerrno)); - exit(1); + exit(EXIT_FAILURE); } unsigned int lineCount = 0; while (fgets(buf, sizeof(buf), f) != NULL) { @@ -148,11 +148,11 @@ TextArguments(int argc, char **argv) if (!passwdfile) { fprintf(stderr, "Usage: digest_file_auth [OPTIONS] \n"); fprintf(stderr, " -c accept digest hashed passwords rather than plaintext in passwordfile\n"); - exit(1); + exit(EXIT_FAILURE); } if (stat(passwdfile, &sb) != 0) { fprintf(stderr, "cannot stat %s\n", passwdfile); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/src/auth/negotiate/SSPI/negotiate_sspi_auth.cc b/src/auth/negotiate/SSPI/negotiate_sspi_auth.cc index 52de73cf8a..420ac70b6e 100644 --- a/src/auth/negotiate/SSPI/negotiate_sspi_auth.cc +++ b/src/auth/negotiate/SSPI/negotiate_sspi_auth.cc @@ -112,7 +112,7 @@ process_options(int argc, char *argv[]) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ @@ -123,7 +123,7 @@ process_options(int argc, char *argv[]) } } if (had_error) - exit(1); + exit(EXIT_FAILURE); } static bool @@ -306,7 +306,7 @@ main(int argc, char *argv[]) if (LoadSecurityDll(SSP_NTLM, NEGOTIATE_PACKAGE_NAME) == NULL) { fprintf(stderr, "FATAL: %s: can't initialize SSPI, exiting.\n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } debug("SSPI initialized OK\n"); @@ -319,6 +319,6 @@ main(int argc, char *argv[]) while (manage_request()) { /* everything is done within manage_request */ } - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc b/src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc index 61775d2d81..7195689514 100644 --- a/src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc +++ b/src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc @@ -391,7 +391,7 @@ main(int argc, char *const argv[]) keytab_name = xstrdup(optarg); else { fprintf(stderr, "ERROR: keytab file not given\n"); - exit(1); + exit(EXIT_FAILURE); } /* * Some sanity checks @@ -406,16 +406,16 @@ main(int argc, char *const argv[]) fprintf(stderr, "ERROR: keytab file %s does not exist\n",keytab_name); else fprintf(stderr, "ERROR: Error %s during stat of keytab file %s\n",strerror(errno),keytab_name); - exit(1); + exit(EXIT_FAILURE); } else if (!S_ISREG(fstat.st_mode)) { fprintf(stderr, "ERROR: keytab file %s is not a file\n",keytab_name); - exit(1); + exit(EXIT_FAILURE); } #endif #if HAVE_UNISTD_H if (access(ktp, R_OK)) { fprintf(stderr, "ERROR: keytab file %s is not accessible\n",keytab_name); - exit(1); + exit(EXIT_FAILURE); } #endif break; @@ -427,7 +427,7 @@ main(int argc, char *const argv[]) rcache_dir = xstrdup(optarg); else { fprintf(stderr, "ERROR: replay cache directory not given\n"); - exit(1); + exit(EXIT_FAILURE); } /* * Some sanity checks @@ -438,16 +438,16 @@ main(int argc, char *const argv[]) fprintf(stderr, "ERROR: replay cache directory %s does not exist\n",rcache_dir); else fprintf(stderr, "ERROR: Error %s during stat of replay cache directory %s\n",strerror(errno),rcache_dir); - exit(1); + exit(EXIT_FAILURE); } else if (!S_ISDIR(dstat.st_mode)) { fprintf(stderr, "ERROR: replay cache directory %s is not a directory\n",rcache_dir); - exit(1); + exit(EXIT_FAILURE); } #endif #if HAVE_UNISTD_H if (access(rcache_dir, W_OK)) { fprintf(stderr, "ERROR: replay cache directory %s is not accessible\n",rcache_dir); - exit(1); + exit(EXIT_FAILURE); } #endif break; @@ -456,7 +456,7 @@ main(int argc, char *const argv[]) rcache_type = xstrdup(optarg); else { fprintf(stderr, "ERROR: replay cache type not given\n"); - exit(1); + exit(EXIT_FAILURE); } break; case 's': @@ -464,7 +464,7 @@ main(int argc, char *const argv[]) service_principal = xstrdup(optarg); else { fprintf(stderr, "ERROR: service principal not given\n"); - exit(1); + exit(EXIT_FAILURE); } break; default: @@ -480,7 +480,7 @@ main(int argc, char *const argv[]) fprintf(stderr, "The SPN can be set to GSS_C_NO_NAME to allow any entry from keytab\n"); fprintf(stderr, "default SPN is HTTP/fqdn@DEFAULT_REALM\n"); - exit(0); + exit(EXIT_SUCCESS); } } @@ -499,7 +499,7 @@ main(int argc, char *const argv[]) "%s| %s: FATAL: Local hostname could not be determined. Please specify the service principal\n", LogTime(), PROGRAM); fprintf(stdout, "BH hostname error\n"); - exit(-1); + exit(EXIT_FAILURE); } service.value = xmalloc(strlen(service_name) + strlen(host_name) + 2); snprintf((char *) service.value, strlen(service_name) + strlen(host_name) + 2, @@ -589,10 +589,10 @@ main(int argc, char *const argv[]) strerror(ferror(stdin))); fprintf(stdout, "BH input error\n"); - exit(1); /* BIIG buffer */ + exit(EXIT_FAILURE); /* BIIG buffer */ } fprintf(stdout, "BH input error\n"); - exit(0); + exit(EXIT_SUCCESS); } c = (char *) memchr(buf, '\n', sizeof(buf) - 1); if (c) { @@ -641,7 +641,7 @@ main(int argc, char *const argv[]) } xfree(token); fprintf(stdout, "BH quit command\n"); - exit(0); + exit(EXIT_SUCCESS); } if (strncmp(buf, "YR", 2) && strncmp(buf, "KK", 2)) { debug((char *) "%s| %s: ERROR: Invalid request [%s]\n", LogTime(), PROGRAM, buf); @@ -864,6 +864,7 @@ cleanup: safe_free(user); continue; } + return EXIT_SUCCESS; } #else #include @@ -879,10 +880,11 @@ main(int argc, char *const argv[]) while (1) { if (fgets(buf, sizeof(buf) - 1, stdin) == NULL) { fprintf(stdout, "BH input error\n"); - exit(0); + exit(EXIT_SUCCESS); } fprintf(stdout, "BH Kerberos authentication not supported\n"); } + return EXIT_SUCCESS; } #endif /* HAVE_GSSAPI */ diff --git a/src/auth/negotiate/kerberos/negotiate_kerberos_auth_test.cc b/src/auth/negotiate/kerberos/negotiate_kerberos_auth_test.cc index a597e7ed8a..afe0737896 100644 --- a/src/auth/negotiate/kerberos/negotiate_kerberos_auth_test.cc +++ b/src/auth/negotiate/kerberos/negotiate_kerberos_auth_test.cc @@ -241,7 +241,7 @@ main(int argc, char *argv[]) fprintf(stdout, "Token: %s\n", Token ? Token : "NULL"); } - return 0; + return EXIT_SUCCESS; } #else diff --git a/src/auth/negotiate/wrapper/negotiate_wrapper.cc b/src/auth/negotiate/wrapper/negotiate_wrapper.cc index 57ceed6f54..9943a99b86 100644 --- a/src/auth/negotiate/wrapper/negotiate_wrapper.cc +++ b/src/auth/negotiate/wrapper/negotiate_wrapper.cc @@ -282,7 +282,7 @@ main(int argc, char *const argv[]) if (argc ==1 || !strncasecmp(argv[1],"-h",2)) { usage(); - return 0; + exit(EXIT_SUCCESS); } int j = 1; @@ -306,7 +306,7 @@ main(int argc, char *const argv[]) } if (nstart == 0 || kstart == 0 || kend-kstart <= 0 || nend-nstart <= 0 ) { usage(); - return 0; + exit(EXIT_SUCCESS); } if (debug_enabled) @@ -315,7 +315,7 @@ main(int argc, char *const argv[]) if ((nargs = (char **)xmalloc((nend-nstart+1)*sizeof(char *))) == NULL) { fprintf(stderr, "%s| %s: Error allocating memory for ntlm helper\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } memcpy(nargs,argv+nstart+1,(nend-nstart)*sizeof(char *)); nargs[nend-nstart]=NULL; @@ -327,7 +327,7 @@ main(int argc, char *const argv[]) } if ((kargs = (char **)xmalloc((kend-kstart+1)*sizeof(char *))) == NULL) { fprintf(stderr, "%s| %s: Error allocating memory for kerberos helper\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } memcpy(kargs,argv+kstart+1,(kend-kstart)*sizeof(char *)); kargs[kend-kstart]=NULL; @@ -344,16 +344,16 @@ main(int argc, char *const argv[]) if (pipe(pkin) < 0) { fprintf(stderr, "%s| %s: Could not assign streams for pkin\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if (pipe(pkout) < 0) { fprintf(stderr, "%s| %s: Could not assign streams for pkout\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if (( fpid = vfork()) < 0 ) { fprintf(stderr, "%s| %s: Failed first fork\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if ( fpid == 0 ) { @@ -372,7 +372,7 @@ main(int argc, char *const argv[]) execv(kargs[0], kargs); fprintf(stderr, "%s| %s: Failed execv for %s: %s\n", LogTime(), PROGRAM, kargs[0], strerror(errno)); - return 1; + exit(EXIT_FAILURE); } close(pkin[0]); @@ -380,16 +380,16 @@ main(int argc, char *const argv[]) if (pipe(pnin) < 0) { fprintf(stderr, "%s| %s: Could not assign streams for pnin\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if (pipe(pnout) < 0) { fprintf(stderr, "%s| %s: Could not assign streams for pnout\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if (( fpid = vfork()) < 0 ) { fprintf(stderr, "%s| %s: Failed second fork\n", LogTime(), PROGRAM); - return 1; + exit(EXIT_FAILURE); } if ( fpid == 0 ) { @@ -408,7 +408,7 @@ main(int argc, char *const argv[]) execv(nargs[0], nargs); fprintf(stderr, "%s| %s: Failed execv for %s: %s\n", LogTime(), PROGRAM, nargs[0], strerror(errno)); - return 1; + exit(EXIT_FAILURE); } close(pnin[0]); @@ -423,7 +423,7 @@ main(int argc, char *const argv[]) if (!FDKIN || !FDKOUT || !FDNIN || !FDNOUT) { fprintf(stderr, "%s| %s: Could not assign streams for FDKIN/FDKOUT/FDNIN/FDNOUT\n", LogTime(), PROGRAM); closeFds(FDKIN, FDKOUT, FDNIN, FDNOUT); - return 1; + exit(EXIT_FAILURE); } setbuf(FDKIN, NULL); diff --git a/src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc b/src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc index 1443fc7839..e0b9329244 100644 --- a/src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc +++ b/src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc @@ -399,7 +399,7 @@ process_options(int argc, char *argv[]) } } if (had_error) - exit(1); + exit(EXIT_FAILURE); /* Okay, now begin filling controllers up */ /* we can avoid memcpy-ing, and just reuse argv[] */ for (j = optind; j < argc; ++j) { @@ -446,7 +446,7 @@ process_options(int argc, char *argv[]) if (numcontrollers == 0) { fprintf(stderr, "You must specify at least one domain-controller!\n"); usage(); - exit(1); + exit(EXIT_FAILURE); } last_dc->next = controllers; /* close the queue, now it's circular */ } @@ -503,7 +503,7 @@ manage_request() if (fgets(buf, NTLM_BLOB_BUFFER_SIZE, stdin) == NULL) { fprintf(stderr, "fgets() failed! dying..... errno=%d (%s)\n", errno, strerror(errno)); - exit(1); /* BIIG buffer */ + exit(EXIT_FAILURE); /* BIIG buffer */ } debug("managing request\n"); ch2 = (char*)memchr(buf, '\n', NTLM_BLOB_BUFFER_SIZE); /* safer against overrun than strchr */ @@ -693,6 +693,6 @@ main(int argc, char *argv[]) manage_request(); } /* notreached */ - return 0; + return EXIT_SUCCESS; } diff --git a/src/auth/ntlm/SSPI/ntlm_sspi_auth.cc b/src/auth/ntlm/SSPI/ntlm_sspi_auth.cc index 5c66a8f070..cc70a72aa5 100644 --- a/src/auth/ntlm/SSPI/ntlm_sspi_auth.cc +++ b/src/auth/ntlm/SSPI/ntlm_sspi_auth.cc @@ -399,7 +399,7 @@ process_options(int argc, char *argv[]) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ @@ -410,7 +410,7 @@ process_options(int argc, char *argv[]) } } if (had_error) - exit(1); + exit(EXIT_FAILURE); } static bool @@ -641,7 +641,7 @@ main(int argc, char *argv[]) if (LoadSecurityDll(SSP_NTLM, NTLM_PACKAGE_NAME) == NULL) { fprintf(stderr, "FATAL, can't initialize SSPI, exiting.\n"); - exit(1); + exit(EXIT_FAILURE); } debug("SSPI initialized OK\n"); @@ -654,6 +654,6 @@ main(int argc, char *argv[]) while (manage_request()) { /* everything is done within manage_request */ } - exit(0); + return EXIT_SUCCESS; } diff --git a/src/auth/ntlm/fake/ntlm_fake_auth.cc b/src/auth/ntlm/fake/ntlm_fake_auth.cc index 19f2abdd61..ac9fb281d7 100644 --- a/src/auth/ntlm/fake/ntlm_fake_auth.cc +++ b/src/auth/ntlm/fake/ntlm_fake_auth.cc @@ -108,7 +108,7 @@ process_options(int argc, char *argv[]) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ @@ -119,7 +119,7 @@ process_options(int argc, char *argv[]) } } if (had_error) - exit(1); + exit(EXIT_FAILURE); } int @@ -220,6 +220,6 @@ main(int argc, char *argv[]) } } } - exit(0); + return EXIT_SUCCESS; } diff --git a/src/cache_diff.cc b/src/cache_diff.cc index 1b4d1d8299..ad362c859a 100644 --- a/src/cache_diff.cc +++ b/src/cache_diff.cc @@ -225,7 +225,7 @@ usage(const char *prg_name) { fprintf(stderr, "usage: %s : ... : ...\n", prg_name); - return -1; + return EXIT_FAILURE; } int @@ -275,6 +275,6 @@ main(int argc, char *argv[]) cacheIndexDestroy(CacheIdx[1]); - return 1; + return EXIT_FAILURE; } diff --git a/src/cf_gen.cc b/src/cf_gen.cc index 0f76c0ee18..01e849604f 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -150,20 +150,20 @@ checkDepend(const std::string &directive, const char *name, const TypeList &type } if (entry == entries.end()) { std::cerr << "ERROR: '" << directive << "' (" << name << ") depends on '" << *dep << "'\n"; - exit(1); + exit(EXIT_FAILURE); } } return; } std::cerr << "ERROR: Dependencies for cf.data type '" << name << "' used in ' " << directive << "' not defined\n" ; - exit(1); + exit(EXIT_FAILURE); } static void usage(const char *program_name) { std::cerr << "Usage: " << program_name << " cf.data cf.data.depend\n"; - exit(1); + exit(EXIT_FAILURE); } static void @@ -204,7 +204,7 @@ main(int argc, char *argv[]) if (fp.fail()) { std::cerr << "Error while opening type dependencies file '" << type_depend << "': " << strerror(errno) << std::endl; - exit(1); + exit(EXIT_FAILURE); } while (fp.good()) { @@ -231,7 +231,7 @@ main(int argc, char *argv[]) if (fp.fail()) { std::cerr << "Error while opening input file '" << input_filename << "': " << strerror(errno) << std::endl; - exit(1); + exit(EXIT_FAILURE); } state = sSTART; @@ -247,14 +247,14 @@ main(int argc, char *argv[]) if (strncmp(buff, "IF ", 3) == 0) { if ((ptr = strtok(buff + 3, WS)) == NULL) { errorMsg(input_filename, linenum, "Missing IF parameter"); - exit(1); + exit(EXIT_FAILURE); } IFDEFS.push(ptr); continue; } else if (strcmp(buff, "ENDIF") == 0) { if (IFDEFS.size() == 0) { errorMsg(input_filename, linenum, "ENDIF without IF first"); - exit(1); + exit(EXIT_FAILURE); } IFDEFS.pop(); } else if (!IFDEFS.size() || isDefined(IFDEFS.top())) @@ -270,7 +270,7 @@ main(int argc, char *argv[]) if ((name = strtok(buff + 5, WS)) == NULL) { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } entries.push_back(name); @@ -287,7 +287,7 @@ main(int argc, char *argv[]) state = sDOC; } else { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } break; @@ -336,14 +336,14 @@ main(int argc, char *argv[]) } else if (!strncmp(buff, "LOC:", 4)) { if ((ptr = strtok(buff + 4, WS)) == NULL) { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } curr.loc = ptr; } else if (!strncmp(buff, "TYPE:", 5)) { if ((ptr = strtok(buff + 5, WS)) == NULL) { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } /* hack to support arrays, rather than pointers */ @@ -357,7 +357,7 @@ main(int argc, char *argv[]) } else if (!strncmp(buff, "IFDEF:", 6)) { if ((ptr = strtok(buff + 6, WS)) == NULL) { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } curr.ifdef = ptr; @@ -367,7 +367,7 @@ main(int argc, char *argv[]) state = sSTART; } else { errorMsg(input_filename, linenum, buff); - exit(1); + exit(EXIT_FAILURE); } } break; @@ -402,7 +402,7 @@ main(int argc, char *argv[]) if (state != sEXIT) { errorMsg(input_filename, linenum, "Error: unexpected EOF"); - exit(1); + exit(EXIT_FAILURE); } fp.close(); @@ -421,7 +421,7 @@ main(int argc, char *argv[]) if (!fout.good()) { std::cerr << "Error while opening output .c file '" << output_filename << "': " << strerror(errno) << std::endl; - exit(1); + exit(EXIT_FAILURE); } fout << "/*\n" << @@ -452,7 +452,7 @@ main(int argc, char *argv[]) if (!fout.good()) { std::cerr << "Error while opening output conf file '" << output_filename << "': " << strerror(errno) << std::endl; - exit(1); + exit(EXIT_FAILURE); } gen_conf(entries, fout, 1); @@ -463,7 +463,7 @@ main(int argc, char *argv[]) if (!fout.good()) { std::cerr << "Error while opening output short conf file '" << output_filename << "': " << strerror(errno) << std::endl; - exit(1); + exit(EXIT_FAILURE); } gen_conf(entries, fout, 0); fout.close(); @@ -553,7 +553,7 @@ gen_default_if_none(const EntryList &head, std::ostream &fout) if (!entry->defaults.preset.empty()) { std::cerr << "ERROR: " << entry->name << " has preset defaults. DEFAULT_IF_NONE cannot be true." << std::endl; - exit(1); + exit(EXIT_FAILURE); } if (entry->ifdef.size()) diff --git a/src/debug.cc b/src/debug.cc index 3d42080143..930ac55e0e 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -387,7 +387,7 @@ _db_set_syslog(const char *facility) } fprintf(stderr, "unknown syslog facility '%s'\n", facility); - exit(1); + exit(EXIT_FAILURE); } #else diff --git a/src/dns/rfc1035.cc b/src/dns/rfc1035.cc index 6bfadafb90..c90ef7fc2d 100644 --- a/src/dns/rfc1035.cc +++ b/src/dns/rfc1035.cc @@ -764,14 +764,14 @@ main(int argc, char *argv[]) struct sockaddr_in S; if (3 != argc) { fprintf(stderr, "usage: %s ip port\n", argv[0]); - return 1; + exit(EXIT_FAILURE); } setbuf(stdout, NULL); setbuf(stderr, NULL); s = socket(PF_INET, SOCK_DGRAM, 0); if (s < 0) { perror("socket"); - return 1; + exit(EXIT_FAILURE); } memset(&S, '\0', sizeof(S)); S.sin_family = AF_INET; @@ -836,7 +836,7 @@ main(int argc, char *argv[]) } } } - return 0; + return EXIT_SUCCESS; } #endif diff --git a/src/dns/rfc3596.cc b/src/dns/rfc3596.cc index 2b87238eb3..696056a58f 100644 --- a/src/dns/rfc3596.cc +++ b/src/dns/rfc3596.cc @@ -184,7 +184,7 @@ main(int argc, char *argv[]) if ( argc < 3 || argc > 4) { fprintf(stderr, "usage: %s [-6|-4] ip port\n", argv[0]); - return 1; + exit(EXIT_FAILURE); } setbuf(stdout, NULL); @@ -200,7 +200,7 @@ main(int argc, char *argv[]) else { fprintf(stderr, "usage: %s [-6|-4] [-E packet-size] ip port\n", argv[0]); fprintf(stderr, " EDNS packets my be up to %d\n", PACKET_BUFSZ); - return 1; + exit(EXIT_FAILURE); } var++; @@ -210,7 +210,7 @@ main(int argc, char *argv[]) if (s < 0) { perror("socket"); - return 1; + exit(EXIT_FAILURE); } memset(&S, '\0', sizeof(S)); @@ -224,7 +224,7 @@ main(int argc, char *argv[]) if ( ! inet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) ) { perror("listen address"); - return 1; + exit(EXIT_FAILURE); } s = socket(PF_INET6, SOCK_DGRAM, 0); @@ -235,9 +235,9 @@ main(int argc, char *argv[]) ((struct sockaddr_in *)S)->sin_family = AF_INET; ((struct sockaddr_in *)S)->sin_port = htons(atoi(argv[var+1])); - if ( ! inet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) + if ( ! inet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) { perror("listen address"); - return 1; + exit(EXIT_FAILURE); } } @@ -330,7 +330,7 @@ while (fgets(input, PACKET_BUFSZ, stdin)) } } -return 0; +return EXIT_SUCCESS; } #endif diff --git a/src/fatal.cc b/src/fatal.cc index bdd68841e0..dfd733b37e 100644 --- a/src/fatal.cc +++ b/src/fatal.cc @@ -62,7 +62,7 @@ fatal(const char *message) fatal_common(message); - exit(1); + exit(EXIT_FAILURE); } /* used by fatalf */ diff --git a/src/http/url_rewriters/LFS/rredir.cc b/src/http/url_rewriters/LFS/rredir.cc index b67741efc6..f6cb1c4641 100644 --- a/src/http/url_rewriters/LFS/rredir.cc +++ b/src/http/url_rewriters/LFS/rredir.cc @@ -60,11 +60,11 @@ main() /* make standard output line buffered */ if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) - return 1; + exit(EXIT_FAILURE); /* speed up the access() calls below */ if (chdir(ACCESS_LOCAL_DIR) == -1) - return 1; + exit(EXIT_FAILURE); /* scan standard input */ while (fgets(buf, BUFFER_SIZE, stdin) != NULL) { @@ -105,6 +105,6 @@ dont_redirect: (void) printf("\n"); } - return 0; + return EXIT_SUCCESS; } diff --git a/src/http/url_rewriters/fake/fake.cc b/src/http/url_rewriters/fake/fake.cc index 960ace148a..7b08ce7153 100644 --- a/src/http/url_rewriters/fake/fake.cc +++ b/src/http/url_rewriters/fake/fake.cc @@ -77,7 +77,7 @@ process_options(int argc, char *argv[]) break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); case '?': opt = optopt; /* fall thru to default */ @@ -88,7 +88,7 @@ process_options(int argc, char *argv[]) } } if (had_error) - exit(1); + exit(EXIT_FAILURE); } int @@ -128,6 +128,6 @@ main(int argc, char *argv[]) } } debug("%s " VERSION " " SQUID_BUILD_INFO " shutting down...\n", my_program_name); - return 0; + return EXIT_SUCCESS; } diff --git a/src/icmp/IcmpPinger.cc b/src/icmp/IcmpPinger.cc index d55fdf0e56..95db1ccd95 100644 --- a/src/icmp/IcmpPinger.cc +++ b/src/icmp/IcmpPinger.cc @@ -172,7 +172,7 @@ IcmpPinger::Recv(void) if (n < 0) { debugs(42, DBG_IMPORTANT, "Pinger exiting."); Close(); - exit(1); + exit(EXIT_FAILURE); } if (0 == n) { @@ -180,7 +180,7 @@ IcmpPinger::Recv(void) debugs(42, DBG_CRITICAL, HERE << "EOF encountered. Pinger exiting.\n"); errno = 0; Close(); - exit(1); + exit(EXIT_FAILURE); } guess_size = n - (sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ); @@ -221,7 +221,7 @@ IcmpPinger::SendResult(pingerReplyData &preply, int len) int xerrno = errno; debugs(42, DBG_CRITICAL, "pinger: FATAL error on send: " << xstrerr(xerrno)); Close(); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/src/icmp/pinger.cc b/src/icmp/pinger.cc index bbbd2cd2a3..fa0063c133 100644 --- a/src/icmp/pinger.cc +++ b/src/icmp/pinger.cc @@ -150,14 +150,14 @@ main(int argc, char *argv[]) /** abort if neither worker could open a socket. */ if (icmp4_worker < 0 && icmp6_worker < 0) { debugs(42, DBG_CRITICAL, "FATAL: pinger: Unable to open any ICMP sockets."); - exit(1); + exit(EXIT_FAILURE); } if ( (squid_link = control.Open()) < 0) { debugs(42, DBG_CRITICAL, "FATAL: pinger: Unable to setup Pinger control sockets."); icmp4.Close(); icmp6.Close(); - exit(1); // fatal error if the control channel fails. + exit(EXIT_FAILURE); // fatal error if the control channel fails. } max_fd = max(max_fd, squid_link); @@ -166,14 +166,14 @@ main(int argc, char *argv[]) debugs(42, DBG_CRITICAL, "FATAL: pinger: setgid(" << getgid() << ") failed: " << xstrerr(xerrno)); icmp4.Close(); icmp6.Close(); - exit (1); + exit(EXIT_FAILURE); } if (setuid(getuid()) < 0) { int xerrno = errno; debugs(42, DBG_CRITICAL, "FATAL: pinger: setuid(" << getuid() << ") failed: " << xstrerr(xerrno)); icmp4.Close(); icmp6.Close(); - exit (1); + exit(EXIT_FAILURE); } #if USE_LIBCAP @@ -187,7 +187,7 @@ main(int argc, char *argv[]) debugs(42, DBG_CRITICAL, "FATAL: pinger: cap_init() failed: " << xstrerr(xerrno)); icmp4.Close(); icmp6.Close(); - exit (1); + exit(EXIT_FAILURE); } else { if (cap_set_proc(caps) != 0) { int xerrno = errno; @@ -196,7 +196,7 @@ main(int argc, char *argv[]) cap_free(caps); icmp4.Close(); icmp6.Close(); - exit (1); + exit(EXIT_FAILURE); } cap_free(caps); } @@ -223,7 +223,7 @@ main(int argc, char *argv[]) int xerrno = errno; debugs(42, DBG_CRITICAL, HERE << " FATAL Shutdown. select()==" << x << ", ERR: " << xstrerr(xerrno)); control.Close(); - exit(1); + exit(EXIT_FAILURE); } if (FD_ISSET(squid_link, &R)) { @@ -241,7 +241,7 @@ main(int argc, char *argv[]) if (send(LINK_TO_SQUID, &tv, 0, 0) < 0) { debugs(42, DBG_CRITICAL, "pinger: Closing. No requests in last " << PINGER_TIMEOUT << " seconds."); control.Close(); - exit(1); + exit(EXIT_FAILURE); } last_check_time = squid_curtime; @@ -249,7 +249,7 @@ main(int argc, char *argv[]) } /* NOTREACHED */ - return 0; + return EXIT_SUCCESS; } #else /* !USE_ICMP */ @@ -259,7 +259,7 @@ int main(int argc, char *argv[]) { std::cerr << argv[0] << ": ICMP support not compiled in." << std::endl; - return 1; + return EXIT_FAILURE; } #endif /* USE_ICMP */ diff --git a/src/log/file/log_file_daemon.cc b/src/log/file/log_file_daemon.cc index a2c9c8b1f6..4062f6745b 100644 --- a/src/log/file/log_file_daemon.cc +++ b/src/log/file/log_file_daemon.cc @@ -101,12 +101,12 @@ main(int argc, char *argv[]) if (argc < 2) { printf("Error: usage: %s \n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } fp = fopen(argv[1], "a"); if (fp == NULL) { perror("fopen"); - exit(1); + exit(EXIT_FAILURE); } setbuf(stdout, NULL); /* XXX stderr should not be closed, but in order to support squid must be @@ -137,12 +137,12 @@ main(int argc, char *argv[]) fp = fopen(argv[1], "a"); if (fp == NULL) { perror("fopen"); - exit(1); + exit(EXIT_FAILURE); } fprintf(fp, "%s", buf + 1); } else { perror("fprintf"); - exit(1); + exit(EXIT_FAILURE); } } } @@ -155,7 +155,7 @@ main(int argc, char *argv[]) fp = fopen(argv[1], "a"); if (fp == NULL) { perror("fopen"); - exit(1); + exit(EXIT_FAILURE); } break; case 'T': @@ -181,6 +181,6 @@ main(int argc, char *argv[]) } fclose(fp); fp = NULL; - exit(0); + return EXIT_SUCCESS; } diff --git a/src/main.cc b/src/main.cc index 31bc257542..7cf24a8135 100644 --- a/src/main.cc +++ b/src/main.cc @@ -153,7 +153,7 @@ static int malloc_debug_level = 0; static volatile int do_reconfigure = 0; static volatile int do_rotate = 0; static volatile int do_shutdown = 0; -static volatile int shutdown_status = 0; +static volatile int shutdown_status = EXIT_SUCCESS; static volatile int do_handle_stopped_child = 0; static int RotateSignal = -1; @@ -399,7 +399,7 @@ usage(void) " -X Force full debugging.\n" " -Y Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.\n", APP_SHORTNAME, CACHE_HTTP_PORT, DefaultConfigFile, CACHE_ICP_PORT); - exit(1); + exit(EXIT_FAILURE); } /** @@ -675,7 +675,7 @@ mainParseOptions(int argc, char *argv[]) #endif - exit(0); + exit(EXIT_SUCCESS); /* NOTREACHED */ @@ -757,7 +757,7 @@ shut_down(int sig) ShutdownSignal = sig; #if defined(SIGTTIN) if (SIGTTIN == sig) - shutdown_status = 1; + shutdown_status = EXIT_FAILURE; #endif #if !_SQUID_WINDOWS_ @@ -1415,7 +1415,7 @@ SquidMainSafe(int argc, char **argv) } catch (...) { debugs(1, DBG_CRITICAL, "FATAL: " << CurrentException); } - return -1; // TODO: return EXIT_FAILURE instead + return EXIT_FAILURE; } /// computes name and ID for the current kid process @@ -1829,7 +1829,7 @@ watch_child(char *argv[]) } } - exit(0); + exit(EXIT_SUCCESS); } if (setsid() < 0) { @@ -1979,15 +1979,15 @@ watch_child(char *argv[]) if (TheKids.someSignaled(SIGINT) || TheKids.someSignaled(SIGTERM)) { syslog(LOG_ALERT, "Exiting due to unexpected forced shutdown"); - exit(1); + exit(EXIT_FAILURE); } if (TheKids.allHopeless()) { syslog(LOG_ALERT, "Exiting due to repeated, frequent failures"); - exit(1); + exit(EXIT_FAILURE); } - exit(0); + exit(EXIT_SUCCESS); } masterCheckAndBroadcastSignals(); diff --git a/src/recv-announce.cc b/src/recv-announce.cc index 4bd4bc170d..e812c2d222 100644 --- a/src/recv-announce.cc +++ b/src/recv-announce.cc @@ -49,7 +49,7 @@ sig_handle(int) close(2); close(1); close(0); - exit(0); + exit(EXIT_SUCCESS); } int @@ -77,7 +77,7 @@ main(int argc, char *argv[]) if (open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0660) < 0) { perror(logfile); - exit(1); + exit(EXIT_FAILURE); } close(2); @@ -91,7 +91,7 @@ main(int argc, char *argv[]) if (recvfrom(0, buf, RECV_BUF_SIZE, 0, (sockaddr *)&R, &len) < 0) { perror("recv"); - exit(2); + exit(EXIT_FAILURE); } memcpy(ip, &R.sin_addr.s_addr, 4); @@ -105,6 +105,6 @@ main(int argc, char *argv[]) fflush(stdout); } - return 0; + return EXIT_SUCCESS; } diff --git a/src/security/cert_generators/file/security_file_certgen.cc b/src/security/cert_generators/file/security_file_certgen.cc index c60ff26cb2..47358fb244 100644 --- a/src/security/cert_generators/file/security_file_certgen.cc +++ b/src/security/cert_generators/file/security_file_certgen.cc @@ -274,16 +274,16 @@ int main(int argc, char *argv[]) break; case 'v': std::cout << "security_file_certgen version " << VERSION << std::endl; - exit(0); + exit(EXIT_SUCCESS); break; case 'c': create_new_db = true; break; case 'h': usage(); - exit(0); + exit(EXIT_SUCCESS); default: - exit(0); + exit(EXIT_FAILURE); } } @@ -291,7 +291,7 @@ int main(int argc, char *argv[]) std::cout << "Initialization SSL db..." << std::endl; Ssl::CertificateDb::create(db_path); std::cout << "Done" << std::endl; - exit(0); + exit(EXIT_SUCCESS); } if (fs_block_size == 0) { @@ -321,7 +321,7 @@ int main(int argc, char *argv[]) while (parse_result == Ssl::CrtdMessage::INCOMPLETE) { if (fgets(request, HELPER_INPUT_BUFFER, stdin) == NULL) - return 1; + exit(EXIT_FAILURE); size_t gcount = strlen(request); parse_result = request_message.parse(request, gcount); } @@ -337,8 +337,8 @@ int main(int argc, char *argv[]) } } catch (std::runtime_error & error) { std::cerr << argv[0] << ": " << error.what() << std::endl; - return -1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/src/test_cache_digest.cc b/src/test_cache_digest.cc index 78d4c714fd..a8db6b9984 100644 --- a/src/test_cache_digest.cc +++ b/src/test_cache_digest.cc @@ -518,7 +518,7 @@ usage(const char *prg_name) { fprintf(stderr, "usage: %s ...\n", prg_name); - return -1; + return EXIT_FAILURE; } int @@ -633,6 +633,6 @@ main(int argc, char *argv[]) xfree(fis); cacheDestroy(them); cacheDestroy(us); - return 0; + return EXIT_SUCCESS; } diff --git a/src/tests/STUB.h b/src/tests/STUB.h index 06dc311d9b..5e6150db2d 100644 --- a/src/tests/STUB.h +++ b/src/tests/STUB.h @@ -27,7 +27,7 @@ #include // Internal Special: the STUB framework requires this function -#define stub_fatal(m) { std::cerr<<"FATAL: "<<(m)<<" for use of "<<__FUNCTION__<<"\n"; exit(1); } +#define stub_fatal(m) { std::cerr<<"FATAL: "<<(m)<<" for use of "<<__FUNCTION__<<"\n"; exit(EXIT_FAILURE); } /// macro to stub a void function. #define STUB { stub_fatal(STUB_API " required"); } diff --git a/src/tests/testRefCount.cc b/src/tests/testRefCount.cc index a0a75f41e2..2cd30359a0 100644 --- a/src/tests/testRefCount.cc +++ b/src/tests/testRefCount.cc @@ -21,7 +21,7 @@ public: int someMethod() { if (!Instances) - exit(1); + exit(EXIT_FAILURE); return 1; } @@ -41,7 +41,7 @@ public: int doSomething() { if (!Instances) - exit (1); + exit(EXIT_FAILURE); return 1; } }; @@ -86,12 +86,12 @@ main (int argc, char **argv) ToRefCount anotherObject(new _ToRefCount); if (anObject == anotherObject) - exit (1); + exit(1); anotherObject = NULL; if (!(anObject == anotherObject)) - exit (1); + exit(1); } /* Can we get the pointer for a const object */ { @@ -100,7 +100,7 @@ main (int argc, char **argv) _ToRefCount const *aPointer = aConstObject.getRaw(); if (aPointer != anObject.getRaw()) - exit (2); + exit(2); } /* Can we get a refcounted pointer from a const object */ { @@ -126,6 +126,6 @@ main (int argc, char **argv) aBaseObject = anObject.getRaw(); } } - return _ToRefCount::Instances == 0 ? 0 : 1; + return _ToRefCount::Instances == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/tests/test_http_range.cc b/src/tests/test_http_range.cc index 505441a3d1..94a3bbcbbb 100644 --- a/src/tests/test_http_range.cc +++ b/src/tests/test_http_range.cc @@ -50,7 +50,7 @@ testRangeParser(char const *rangestring) HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) - exit (1); + exit(EXIT_FAILURE); HttpHdrRange copy(*range); @@ -70,7 +70,7 @@ rangeFromString(char const *rangestring) HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) - exit (1); + exit(EXIT_FAILURE); return range; } @@ -106,7 +106,7 @@ testRangeCanonization() /* This passes in the extant code - but should it? */ if (!range->canonize(3)) - exit(1); + exit(EXIT_FAILURE); assert (range->specs.size() == 3); @@ -118,7 +118,7 @@ testRangeCanonization() /* 0-3 needs a content length of 4 */ if (!range->canonize(4)) - exit(1); + exit(EXIT_FAILURE); delete range; @@ -128,7 +128,7 @@ testRangeCanonization() /* 3-6 needs a content length of 4 or more */ if (range->canonize(3)) - exit(1); + exit(EXIT_FAILURE); delete range; @@ -138,7 +138,7 @@ testRangeCanonization() /* 3-6 needs a content length of 4 or more */ if (!range->canonize(4)) - exit(1); + exit(EXIT_FAILURE); delete range; @@ -147,7 +147,7 @@ testRangeCanonization() assert (range->specs.size()== 2); if (!range->canonize(4)) - exit(1); + exit(EXIT_FAILURE); assert (range->specs.size() == 2); @@ -170,11 +170,11 @@ main(int argc, char **argv) testRangeCanonization(); } catch (const std::exception &e) { printf("Error: dying from an unhandled exception: %s\n", e.what()); - return 1; + return EXIT_FAILURE; } catch (...) { printf("Error: dying from an unhandled exception.\n"); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/src/ufsdump.cc b/src/ufsdump.cc index fa895ef733..456841992f 100644 --- a/src/ufsdump.cc +++ b/src/ufsdump.cc @@ -52,14 +52,14 @@ void death(int sig) { std::cout << "Fatal: Signal " << sig; - exit(1); + exit(EXIT_FAILURE); } void fatal(const char *message) { fprintf(stderr, "FATAL: %s\n", message); - exit(1); + exit(EXIT_FAILURE); } /* end stub functions */ @@ -161,7 +161,6 @@ main(int argc, char *argv[]) for_each(*metadata, dumper); - return 0; } catch (const std::exception &e) { std::cout << "Failed : " << e.what() << std::endl; @@ -171,7 +170,9 @@ main(int argc, char *argv[]) if (metadata) StoreMeta::FreeList(&metadata); - return 1; + return EXIT_FAILURE; } + + return EXIT_SUCCESS; } diff --git a/src/unlinkd_daemon.cc b/src/unlinkd_daemon.cc index 116e5a7449..30188db99f 100644 --- a/src/unlinkd_daemon.cc +++ b/src/unlinkd_daemon.cc @@ -65,6 +65,6 @@ main(int, char *[]) std::cout << "OK" << std::endl; } - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/VirtualDeleteOperator.cc b/test-suite/VirtualDeleteOperator.cc index 7d98fb625a..7e6da930c1 100644 --- a/test-suite/VirtualDeleteOperator.cc +++ b/test-suite/VirtualDeleteOperator.cc @@ -113,6 +113,6 @@ main(int argc, char **argv) assert (BaseVirtual::Calls.deletes() == 0); assert (ChildVirtual::Calls.news() == 1); assert (ChildVirtual::Calls.deletes() == 1); - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/debug.cc b/test-suite/debug.cc index 912175357d..b39443fac7 100644 --- a/test-suite/debug.cc +++ b/test-suite/debug.cc @@ -61,6 +61,6 @@ main(int argc, char **argv) StreamTest *streamPointer (&aStreamObject); debugs(1, DBG_IMPORTANT,aStreamObject); debugs(1, DBG_IMPORTANT,streamPointer->getAnInt() << " " << aStreamObject.getACString()); - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/mem_hdr_test.cc b/test-suite/mem_hdr_test.cc index ef5c864996..b950671c72 100644 --- a/test-suite/mem_hdr_test.cc +++ b/test-suite/mem_hdr_test.cc @@ -108,6 +108,6 @@ main(int argc, char **argv) assert (mem_node::InUseCount() == 0); testHdrVisit(); assert (mem_node::InUseCount() == 0); - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/mem_node_test.cc b/test-suite/mem_node_test.cc index cf2b2f3fa8..46d0550b58 100644 --- a/test-suite/mem_node_test.cc +++ b/test-suite/mem_node_test.cc @@ -19,7 +19,7 @@ void xassert(const char *msg, const char *file, int line) { std::cout << "Assertion failed: (" << msg << ") at " << file << ":" << line << std::endl; - exit (1); + exit(EXIT_FAILURE); } #endif @@ -57,6 +57,6 @@ main(int argc, char **argv) assert (!(mem_node (2) < mem_node (0))); delete aNode; assert (mem_node::InUseCount() == 0); - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/splay.cc b/test-suite/splay.cc index 3822374abc..c078899872 100644 --- a/test-suite/splay.cc +++ b/test-suite/splay.cc @@ -82,11 +82,11 @@ SplayCheck::CheckNode(intnode const &A) /* failure */ if (!ExpectedFail) - exit (1); + exit(EXIT_FAILURE); } else /* success */ if (ExpectedFail) - exit (1); + exit(EXIT_FAILURE); LastValue = A.i; } @@ -204,10 +204,10 @@ main(int argc, char *argv[]) Splay *safeTop = new Splay(); if (safeTop->start() != NULL) - exit (1); + exit(EXIT_FAILURE); if (safeTop->finish() != NULL) - exit (1); + exit(EXIT_FAILURE); for (int i = 0; i < 100; ++i) { intnode I; @@ -226,16 +226,16 @@ main(int argc, char *argv[]) } if (!safeTop->start()) - exit (1); + exit(EXIT_FAILURE); if (safeTop->start()->data.i != 50) - exit (1); + exit(EXIT_FAILURE); if (!safeTop->finish()) - exit (1); + exit(EXIT_FAILURE); if (safeTop->finish()->data.i != 10000000) - exit (1); + exit(EXIT_FAILURE); safeTop->destroy(destintref); } @@ -244,30 +244,30 @@ main(int argc, char *argv[]) Splay aSplay; if (aSplay.start() != NULL) - exit (1); + exit(EXIT_FAILURE); if (aSplay.size() != 0) - exit (1); + exit(EXIT_FAILURE); aSplay.insert (new intnode(5), compareint); if (aSplay.start() == NULL) - exit (1); + exit(EXIT_FAILURE); if (aSplay.size() != 1) - exit (1); + exit(EXIT_FAILURE); aSplay.destroy(destint); if (aSplay.start() != NULL) - exit (1); + exit(EXIT_FAILURE); if (aSplay.size() != 0) - exit (1); + exit(EXIT_FAILURE); } /* TODO: also test the other Splay API */ - return 0; + return EXIT_SUCCESS; } diff --git a/test-suite/syntheticoperators.cc b/test-suite/syntheticoperators.cc index 429913ff55..02e0a4aaf6 100644 --- a/test-suite/syntheticoperators.cc +++ b/test-suite/syntheticoperators.cc @@ -155,6 +155,6 @@ main(int argc, char **argv) { CheckHasExplicitWorks(); CheckSyntheticWorks(); - return 0; + return EXIT_SUCCESS; } diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc index c6d1f73ef5..a30c61f6f6 100644 --- a/tools/purge/purge.cc +++ b/tools/purge/purge.cc @@ -171,7 +171,7 @@ REList::REList( const char* what, bool doCase ) char buffer[256]; regerror( result, &rexp, buffer, 256 ); fprintf( stderr, "unable to compile re \"%s\": %s\n", what, buffer ); - exit(1); + exit(EXIT_FAILURE); } } @@ -191,7 +191,7 @@ REList::match( const char* check ) const regerror( result, &rexp, buffer, 256 ); fprintf( stderr, "unable to execute re \"%s\"\n+ on line \"%s\": %s\n", data, check, buffer ); - exit(1); + exit(EXIT_FAILURE); } return ( result == 0 ); } @@ -219,7 +219,7 @@ concat( const char* start, ... ) char* result = new char[size]; if ( result == 0 ) { perror( "string memory allocation" ); - exit(1); + exit(EXIT_FAILURE); } // second run: copy content @@ -657,7 +657,7 @@ parseCommandline( int argc, char* argv[], REList*& head, case 'c': if ( !optarg || !*optarg ) { fprintf( stderr, "%c requires a regex pattern argument!\n", option ); - exit(1); + exit(EXIT_FAILURE); } if ( *conffile ) xfree((void*) conffile); conffile = xstrdup(optarg); @@ -676,7 +676,7 @@ parseCommandline( int argc, char* argv[], REList*& head, case 'e': if ( !optarg || !*optarg ) { fprintf( stderr, "%c requires a regex pattern argument!\n", option ); - exit(1); + exit(EXIT_FAILURE); } if ( head == 0 ) tail = head = new REList( optarg, option=='E' ); @@ -689,7 +689,7 @@ parseCommandline( int argc, char* argv[], REList*& head, case 'f': if ( !optarg || !*optarg ) { fprintf( stderr, "%c requires a filename argument!\n", option ); - exit(1); + exit(EXIT_FAILURE); } if ( (rfile = fopen( optarg, "r" )) != NULL ) { unsigned long lineno = 0; @@ -701,7 +701,7 @@ parseCommandline( int argc, char* argv[], REList*& head, if ( len+2 >= LINESIZE ) { fprintf( stderr, "%s:%lu: line too long, sorry.\n", optarg, lineno ); - exit(1); + exit(EXIT_FAILURE); } // remove trailing line breaks @@ -731,7 +731,7 @@ parseCommandline( int argc, char* argv[], REList*& head, case 'p': if ( !optarg || !*optarg ) { fprintf( stderr, "%c requires a port argument!\n", option ); - exit(1); + exit(EXIT_FAILURE); } colon = strchr( optarg, ':' ); if ( colon == 0 ) { @@ -744,7 +744,7 @@ parseCommandline( int argc, char* argv[], REList*& head, // assume that main() did set the default port if ( convertHostname(optarg,serverHostIp) == -1 ) { fprintf( stderr, "unable to resolve host %s!\n", optarg ); - exit(1); + exit(EXIT_FAILURE); } } else { // assume that main() did set the default host @@ -756,18 +756,18 @@ parseCommandline( int argc, char* argv[], REList*& head, ++colon; if ( convertHostname(optarg,serverHostIp) == -1 ) { fprintf( stderr, "unable to resolve host %s!\n", optarg ); - exit(1); + exit(EXIT_FAILURE); } if ( convertPortname(colon,serverHostPort) == -1 ) { fprintf( stderr, "unable to resolve port %s!\n", colon ); - exit(1); + exit(EXIT_FAILURE); } } break; case 'P': if ( !optarg || !*optarg ) { fprintf( stderr, "%c requires a mode argument!\n", option ); - exit(1); + exit(EXIT_FAILURE); } ::purgeMode = ( strtol( optarg, 0, 0 ) & 0x07 ); break; @@ -780,7 +780,7 @@ parseCommandline( int argc, char* argv[], REList*& head, case '?': default: helpMe(); - exit(1); + exit(EXIT_FAILURE); } } @@ -789,7 +789,7 @@ parseCommandline( int argc, char* argv[], REList*& head, if ( head == 0 ) { fputs( "There was no regular expression defined. If you intend\n", stderr ); fputs( "to match all possible URLs, use \"-e .\" instead.\n", stderr ); - exit(1); + exit(EXIT_FAILURE); } // postcondition: head != 0 @@ -860,7 +860,7 @@ extern "C" { handler( int signo ) { ::term_flag = signo; if ( getpid() == getpgrp() ) kill( -getpgrp(), signo ); - exit(1); + exit(EXIT_FAILURE); } } // extern "C" @@ -894,7 +894,7 @@ main( int argc, char* argv[] ) serverPort = htons(DEFAULTPORT); if ( convertHostname(DEFAULTHOST,serverHost) == -1 ) { fprintf( stderr, "unable to resolve host %s!\n", DEFAULTHOST ); - return 1; + exit(EXIT_FAILURE); } // setup line buffer @@ -912,7 +912,7 @@ main( int argc, char* argv[] ) Signal( SIGINT, handler, true ) == SIG_ERR || Signal( SIGHUP, handler, true ) == SIG_ERR ) { perror( "unable to install signal/exit function" ); - return 1; + exit(EXIT_FAILURE); } // try to read squid.conf file to determine all cache_dir locations @@ -942,7 +942,7 @@ main( int argc, char* argv[] ) // make parent process group leader for easier killings if ( setpgid(getpid(), getpid()) != 0 ) { perror( "unable to set process group leader" ); - return 1; + exit(EXIT_FAILURE); } // -a is mutually exclusive with fork mode @@ -958,7 +958,7 @@ main( int argc, char* argv[] ) // fork error, this is bad! perror( "unable to fork" ); kill( -getpgrp(), SIGTERM ); - return 1; + exit(EXIT_FAILURE); } else if ( child[i] == 0 ) { // child mode // execute OR complain @@ -966,7 +966,7 @@ main( int argc, char* argv[] ) fprintf( stderr, "program terminated due to error: %s\n", strerror(errno) ); xfree((void*) cdv[i].base); - return 0; + exit(EXIT_SUCCESS); } else { // parent mode if ( ::debugFlag ) printf( "forked child %d\n", (int) child[i] ); @@ -992,6 +992,6 @@ main( int argc, char* argv[] ) if ( copydir ) xfree( (void*) copydir ); xfree((void*) conffile); delete list; - return 0; + return EXIT_SUCCESS; } diff --git a/tools/squidclient/squidclient.cc b/tools/squidclient/squidclient.cc index 7b821d848d..71976125a9 100644 --- a/tools/squidclient/squidclient.cc +++ b/tools/squidclient/squidclient.cc @@ -129,7 +129,7 @@ usage(const char *progname) << " -w password Proxy authentication password" << std::endl << " -W password WWW authentication password" << std::endl ; - exit(1); + exit(EXIT_FAILURE); } static void @@ -397,7 +397,7 @@ main(int argc, char *argv[]) if (put_fd < 0) { int xerrno = errno; std::cerr << "ERROR: can't open file (" << xstrerr(xerrno) << ")" << std::endl; - exit(-1); + exit(EXIT_FAILURE); } #if _SQUID_WINDOWS_ setmode(put_fd, O_BINARY); @@ -479,7 +479,7 @@ main(int argc, char *argv[]) #endif if (!password) { std::cerr << "ERROR: Proxy password missing" << std::endl; - exit(1); + exit(EXIT_FAILURE); } uint8_t *pwdBuf = new uint8_t[base64_encode_len(strlen(user)+1+strlen(password))]; blen = base64_encode_update(&ctx, pwdBuf, strlen(user), reinterpret_cast(user)); @@ -499,7 +499,7 @@ main(int argc, char *argv[]) #endif if (!password) { std::cerr << "ERROR: WWW password missing" << std::endl; - exit(1); + exit(EXIT_FAILURE); } uint8_t *pwdBuf = new uint8_t[base64_encode_len(strlen(user)+1+strlen(password))]; blen = base64_encode_update(&ctx, pwdBuf, strlen(user), reinterpret_cast(user)); @@ -559,10 +559,10 @@ main(int argc, char *argv[]) if (bytesWritten < 0) { std::cerr << "ERROR: write" << std::endl; - exit(1); + exit(EXIT_FAILURE); } else if ((unsigned) bytesWritten != strlen(msg)) { std::cerr << "ERROR: Cannot send request?: " << std::endl << msg << std::endl; - exit(1); + exit(EXIT_FAILURE); } debugVerbose(2, "done."); @@ -629,7 +629,7 @@ main(int argc, char *argv[]) Ping::DisplayStats(); Transport::ShutdownTls(); - return 0; + return EXIT_SUCCESS; } void @@ -649,7 +649,7 @@ set_our_signal(void) if (sigaction(SIGPIPE, &sa, NULL) < 0) { std::cerr << "ERROR: Cannot set PIPE signal." << std::endl; - exit(-1); + exit(EXIT_FAILURE); } #else signal(SIGPIPE, pipe_handler);