]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: use EXIT_FAILURE and EXIT_SUCCESS instead of magic numbers in exit()
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Jun 2017 18:38:19 +0000 (06:38 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Jun 2017 18:38:19 +0000 (06:38 +1200)
... and return EXIT_SUCCESS from main() functions.

64 files changed:
lib/hash.cc
src/DiskIO/DiskDaemon/diskd.cc
src/WinSvc.cc
src/acl/external/AD_group/ext_ad_group_acl.cc
src/acl/external/LDAP_group/ext_ldap_group_acl.cc
src/acl/external/LM_group/ext_lm_group_acl.cc
src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc
src/acl/external/file_userip/ext_file_userip_acl.cc
src/acl/external/kerberos_ldap_group/kerberos_ldap_group.cc
src/acl/external/session/ext_session_acl.cc
src/acl/external/time_quota/ext_time_quota_acl.cc
src/acl/external/unix_group/check_group.cc
src/auth/basic/LDAP/basic_ldap_auth.cc
src/auth/basic/NCSA/basic_ncsa_auth.cc
src/auth/basic/NIS/basic_nis_auth.cc
src/auth/basic/PAM/basic_pam_auth.cc
src/auth/basic/RADIUS/basic_radius_auth.cc
src/auth/basic/SASL/basic_sasl_auth.cc
src/auth/basic/SMB/basic_smb_auth.cc
src/auth/basic/SMB_LM/msntauth.cc
src/auth/basic/SSPI/basic_sspi_auth.cc
src/auth/basic/fake/fake.cc
src/auth/basic/getpwnam/basic_getpwnam_auth.cc
src/auth/digest/LDAP/digest_pw_auth.cc
src/auth/digest/LDAP/ldap_backend.cc
src/auth/digest/eDirectory/digest_pw_auth.cc
src/auth/digest/eDirectory/ldap_backend.cc
src/auth/digest/file/digest_file_auth.cc
src/auth/digest/file/text_backend.cc
src/auth/negotiate/SSPI/negotiate_sspi_auth.cc
src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc
src/auth/negotiate/kerberos/negotiate_kerberos_auth_test.cc
src/auth/negotiate/wrapper/negotiate_wrapper.cc
src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc
src/auth/ntlm/SSPI/ntlm_sspi_auth.cc
src/auth/ntlm/fake/ntlm_fake_auth.cc
src/cache_diff.cc
src/cf_gen.cc
src/debug.cc
src/dns/rfc1035.cc
src/dns/rfc3596.cc
src/fatal.cc
src/http/url_rewriters/LFS/rredir.cc
src/http/url_rewriters/fake/fake.cc
src/icmp/IcmpPinger.cc
src/icmp/pinger.cc
src/log/file/log_file_daemon.cc
src/main.cc
src/recv-announce.cc
src/security/cert_generators/file/security_file_certgen.cc
src/test_cache_digest.cc
src/tests/STUB.h
src/tests/testRefCount.cc
src/tests/test_http_range.cc
src/ufsdump.cc
src/unlinkd_daemon.cc
test-suite/VirtualDeleteOperator.cc
test-suite/debug.cc
test-suite/mem_hdr_test.cc
test-suite/mem_node_test.cc
test-suite/splay.cc
test-suite/syntheticoperators.cc
tools/purge/purge.cc
tools/squidclient/squidclient.cc

index 3bd3bf38b37150db4f1b54ff738fbfafa3dfbb83..30c387b056e55785675a9f26002841aa03d52038 100644 (file)
@@ -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
 
index f2ad7cb1232fd4a4935ddcb83717aae172e40400..2b698d02e79e643d90719f54b7c6931ca848ce69 100644 (file)
@@ -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;
 }
 
index 2042b1f83652b58a88d75b3cc11d4378f5ef3af5..21a515bd9b8205f9e12893759489d6ef88de7c3c 100644 (file)
@@ -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));
index 18e7cf4f2089c392d278500e2e8d102e8ffd38a6..64dae2ae2d97a612c8803fb29cffda26def82df4 100644 (file)
@@ -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;
 }
 
index 6bf5a5e9069b63fa0cab84aa440ebb23a0be1587..ac6e10ff28e6fcde0780d063f1f14222a41d75b3 100644 (file)
@@ -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
index 7d2cc8a084450feef78106d8d1823ad54377f19d..52713efe2e0f2713a738f7bd21f6385ca55bec86 100644 (file)
@@ -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;
 }
 
index 68dcd53142ae93c3815f6a6a7d7c29596dc39218..776dcb3b75be0f1ff04080532a9d5140c33cddf9 100644 (file)
@@ -1474,7 +1474,7 @@ SigTrap(int s)
         CloseLDAP(&edui_ldap);
 
     debug("Terminating, Signal: %d\n", s);
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
 
 /*
index e0c73e5ba7b93a1362323b8f7fb49f0808b5bd15..6d184f7a1fa37071f723598840722beb40ce1357 100644 (file)
@@ -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;
 }
 
index 5e7277d9f3d77cfb029c0bc8c59505ba42170199..b5117a3bb7c85d4597fe51e1962f51dd0676ec5f 100644 (file)
@@ -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
 
index bd023bd13ad0e22830d815e1141a524fb36bfd92..009f67c3577f4cb56f27e100b509352a3d4fdc8b 100644 (file)
@@ -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;
 }
 
index 3c7ec6933ddd0cc6ac67855fd024f740ed6cc92b..0027f58aa59b3f35815eba459777b652f21a42ba 100644 (file)
@@ -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;
 }
 
index b7fdf598c76cd3acf79abe5ff28210d515da766c..5b8d23640ea40d08026944da7d8eb59815766f97 100644 (file)
@@ -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;
 }
 
index 3c0a92f9749357911c240d37ad4b5274d53cafc8..b5d46fbd758f6c4d774d5bb906fd9f0d6b8bc2e4 100644 (file)
@@ -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 <userattr>=user,basedn\n\twill be used (same as specifying a search filter of '<userattr>=',\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;
index 97655554f8e0f9c41fdb9256a4045cb5c8533dd9..50e7f96f0d3aa8891e5e66b35b8e5fe1722f8ea4 100644 (file)
@@ -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 <passwordfile>\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;
 }
 
index f53dfe307927fa96722cba8e104f6f81e38caa90..47c53359fb7e30709f8a2c8f2a4f2ba9b6fd9e6c 100644 (file)
@@ -47,7 +47,7 @@ main(int argc, char **argv)
         fprintf(stderr, "Usage: basic_nis_auth <domainname> <nis map for password>\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;
 }
 
index d6cff854db7b09dcbbe9e088dd22db1816693940..e907345860d992f6a27f420e347addac6f6e9fb4 100644 (file)
@@ -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;
 }
 
index c4510980b20aa5ae07037058c95eac9864d06558..24d65e1d935b067c5aaeb30b0b888702ed9f260e 100644 (file)
@@ -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;
 }
 
index 8622e586da9a136d9d6141dfcc7365bf3694482c..f9f93af3b191ca516e632f957bf6e64ec2a10bb7 100644 (file)
@@ -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;
 }
 
index ce101a5755628583d335b3d677702f49637f717d..dca4574197c81c21f13e09c4d6ae41610ba23f98 100644 (file)
@@ -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;
 }
 
index fe4aab95494f204a4af3dcbee38946be400d0003..78c488f6c42bfd9a0a2ddad0284d314ee7d378f4 100644 (file)
@@ -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;
 }
 
index 158baefd944b876d40dcb85858cd6986d9cb3cd8..f55a3dccd59d8f8523ca413bea98dbf394c7b1d5 100644 (file)
@@ -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;
 }
 
index fd656d0bf769aa2d5876ad61552b9618f6967bfc..1dc224d4c5182e1ac2d748f26b13535d70fdc362 100644 (file)
@@ -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<char>(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;
 }
 
index f3218f93738c964d5d96b836d3bb9d0d997d6f0d..bce573432c77a126c184c3d0d10d3a264595cf5b 100644 (file)
@@ -125,6 +125,6 @@ main(int, char **)
             }
         }
     }
-    return 0;
+    return EXIT_SUCCESS;
 }
 
index e6720bc095ddeda59dd629f31c85fb01f641d482..bfb28f183332f3e1895ef63fab417f85fe0de9ba 100644 (file)
@@ -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;
 }
 
index 7f167e5567ce1e6e848f329858742a668ed6d66c..932014c222f191532fd929b18f3919e1794808b5 100644 (file)
@@ -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");
index 53a2c496842e2813eeecec0b6e43062292704683..23f23628dfef7fd0844a43e76030d7bea8d13c25 100644 (file)
@@ -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;
 }
 
index 02848ed5b6333015454577932d80096124a8cbbf..86aa8da2d16557830f2fdfa663510bacc292d3e1 100644 (file)
@@ -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
index da4e9d76637681d600ec359a0e3b9777f6d49af5..a194408d7daa19f78db1f1c32dcace19f67f48c5 100644 (file)
@@ -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;
 }
 
index 23e8104f0262279951ed55d12ac277545bd12afe..6c73a7d6f040a0d2e2d06de2458be5e418b46bd5 100644 (file)
@@ -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] <passwordfile>\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);
     }
 }
 
index 52de73cf8a21a597e38722415f693c9c54a8596a..420ac70b6ee95c8a33ba40af34bae13b0db322ee 100644 (file)
@@ -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;
 }
 
index 61775d2d81db3814594e8780e29a90d6d4c4f5c1..7195689514dd7d1205059f11129568750afeac70 100644 (file)
@@ -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 <cstdlib>
@@ -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 */
 
index a597e7ed8acac44292ed3c77c83699331db526f5..afe0737896697b879ea753b66dcf133e38552420 100644 (file)
@@ -241,7 +241,7 @@ main(int argc, char *argv[])
         fprintf(stdout, "Token: %s\n", Token ? Token : "NULL");
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 #else
index 57ceed6f54c6b3759333c0e60ed4dc65119b9597..9943a99b86f0c3c09d5c798d9a4568671997c56e 100644 (file)
@@ -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);
index 1443fc7839350c9dd3a01c9b20cff040b889a9e5..e0b9329244b0b57bec4b82480923c43c3d89935e 100644 (file)
@@ -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;
 }
 
index 5c66a8f0701ab6c4c135d9ee39b33faec22d19e4..cc70a72aa5ba287e33452080507c5c9a5ae9a0b6 100644 (file)
@@ -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;
 }
 
index 19f2abdd613766975b8348cf90eeba0a3b6e42c5..ac9fb281d7f07bbcb23f8d294bc9e45e3a18d2d3 100644 (file)
@@ -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;
 }
 
index 1b4d1d829967365cdd3ada6c18d60495217e97e4..ad362c859a7d2c7c42be24c50ea014bdb5e44ace 100644 (file)
@@ -225,7 +225,7 @@ usage(const char *prg_name)
 {
     fprintf(stderr, "usage: %s <label1>: <swap_state>... <label2>: <swap_state>...\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;
 }
 
index 0f76c0ee1867afcaec4d50418e01d89e7a85cfa2..01e849604f63521440babb098a451b597e1e7ef2 100644 (file)
@@ -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())
index 3d420801434b7da388b2243a4e45d7e24ad1f9c2..930ac55e0ee12afdf4d738689c3060d6d30d7128 100644 (file)
@@ -387,7 +387,7 @@ _db_set_syslog(const char *facility)
         }
 
         fprintf(stderr, "unknown syslog facility '%s'\n", facility);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #else
index 6bfadafb901571bbebcc5de41bf658e697e670bb..c90ef7fc2d2ca717f501cf31d2e785f08ba5fa09 100644 (file)
@@ -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
 
index 2b87238eb3f9439579e59f0387d7b7b69f79909e..696056a58f20ecaf038be936dad393222a6a21ec 100644 (file)
@@ -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
index bdd68841e0283e489e820fde5bb6f4bbad35c81d..dfd733b37e8d750f6504b09485bf3b8145607731 100644 (file)
@@ -62,7 +62,7 @@ fatal(const char *message)
 
     fatal_common(message);
 
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 /* used by fatalf */
index b67741efc6bff3e47faee5c34018f384a2da81e1..f6cb1c4641c183b148d841e2b9ea625d3868e4d9 100644 (file)
@@ -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;
 }
 
index 960ace148a0e2114e7f0fa4ae146ee9861d64741..7b08ce7153a7cfa47c74f4d2ab8134e7e853d22d 100644 (file)
@@ -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;
 }
 
index d55fdf0e561002dd62f22aa6ca27fe021022a64a..95db1ccd953c6b3101935caf99d785f36f1d7c6f 100644 (file)
@@ -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);
     }
 }
 
index bbbd2cd2a35a37f621488e5ae9af774b213cea78..fa0063c133a75658ee276987689514fa76424f00 100644 (file)
@@ -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 */
index a2c9c8b1f610329cb7c5650bcf18d69cd5515130..4062f6745ba8d61dafe2d87a6b7cea348074daa8 100644 (file)
@@ -101,12 +101,12 @@ main(int argc, char *argv[])
 
     if (argc < 2) {
         printf("Error: usage: %s <logfile>\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;
 }
 
index 31bc25754270053abc5a5c707123f077200cbb04..7cf24a8135ab8048a63e27f612815ddb9a505dc3 100644 (file)
@@ -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();
index 4bd4bc170dff4b0342a766f38d18c0d1d2813592..e812c2d222c7a78812bb79604d3a053e4e822b4c 100644 (file)
@@ -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;
 }
 
index c60ff26cb29e745cf89752ff99b4c55a527cefe3..47358fb244f6f9b057e6bad3e23f3f979d9731ac 100644 (file)
@@ -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;
 }
 
index 78d4c714fd1d15c6edfb0024657a4783d700c203..a8db6b99849f8df7d72a404ce83261026d733e31 100644 (file)
@@ -518,7 +518,7 @@ usage(const char *prg_name)
 {
     fprintf(stderr, "usage: %s <access_log> <swap_state> ...\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;
 }
 
index 06dc311d9bfcd0aae7d8ddbe4474de8218815fc9..5e6150db2df7f65e05dad59a92a405c4105a9c29 100644 (file)
@@ -27,7 +27,7 @@
 #include <iostream>
 
 // 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"); }
index a0a75f41e2f1d72c1e60f9602d2bbd004c7c221c..2cd30359a04250df618a0e0b4df38816d9b7b125 100644 (file)
@@ -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;
 }
 
index 505441a3d19f3a347858429d0ebba297aab696a9..94a3bbcbbb9e784e55e3802bd1c6d3ef5418db45 100644 (file)
@@ -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;
 }
 
index fa895ef733bc6f229c4ce805b8a86659745897d7..456841992f0b7dff9d88fdb3474bdfefd78b1ca9 100644 (file)
@@ -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;
 }
 
index 116e5a744962b93b0d9c9b5d95a89e4eb196e300..30188db99f7a577a565ded8e8592f23664bde308 100644 (file)
@@ -65,6 +65,6 @@ main(int, char *[])
             std::cout << "OK" << std::endl;
     }
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
index 7d98fb625ad7b76eab0631376bcd311f833f62d2..7e6da930c1f1a6c3dda4c511297193e899b3a038 100644 (file)
@@ -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;
 }
 
index 912175357dcc86ad896388fc12739403c1310952..b39443fac794d35c5b235eacc5e52eb7d5d11d1f 100644 (file)
@@ -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;
 }
 
index ef5c86499603a8326db98c6baff65f460e97153f..b950671c721f01ef250aa400f294a90d0df0970b 100644 (file)
@@ -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;
 }
 
index cf2b2f3fa831d1ae502c945ac0bcea719304fdb1..46d0550b589498a4c22417ec0fb0e8aa85ee90e0 100644 (file)
@@ -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;
 }
 
index 3822374abc5a85f8513990e713b26f9181a0bd3d..c07889987263590196dca8ad1cac514a6d43b864 100644 (file)
@@ -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<intnode> *safeTop = new Splay<intnode>();
 
         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<intnode *> 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;
 }
 
index 429913ff55aececeba96f942c091fa084587317e..02e0a4aaf6ff8aaad08cb3ae2c0de7f7dc7978b7 100644 (file)
@@ -155,6 +155,6 @@ main(int argc, char **argv)
 {
     CheckHasExplicitWorks();
     CheckSyntheticWorks();
-    return 0;
+    return EXIT_SUCCESS;
 }
 
index c6d1f73ef5a376c0a8f9e3384f16d1bd9ae4e356..a30c61f6f6952c661ecffb467dab64dbdf8e683a 100644 (file)
@@ -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;
 }
 
index 7b821d848ddeacad96eefdaf36fc941564246dce..71976125a95ee17ec8eeee9e6df5c7ffa8f9d9d4 100644 (file)
@@ -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<const uint8_t*>(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<const uint8_t*>(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);