]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use EXIT_FAILURE for portability
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 17 Nov 2017 23:39:22 +0000 (23:39 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 17 Nov 2017 23:39:22 +0000 (23:39 +0000)
Apparently not all systems use 1 to indicate failure.  C99 says "Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined."

18 files changed:
src/main/radmin.c
src/main/radwho.c
src/main/unit_test_attribute.c
src/main/unit_test_map.c
src/main/unlang_interpret.c
src/modules/proto_dhcpv4/dhcpclient.c
src/modules/rlm_eap/lib/sim/comp128.c
src/modules/rlm_logintime/timestr.c
src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c
src/tests/util/atomic_queue_test.c
src/tests/util/channel_test.c
src/tests/util/control_test.c
src/tests/util/message_set_test.c
src/tests/util/radius1_test.c
src/tests/util/radius_schedule_test.c
src/tests/util/ring_buffer_test.c
src/tests/util/schedule_test.c
src/tests/util/worker_test.c

index ea1f331bb7bb354cf7427f08db6ca2a22c7eaf46..e375767ed93f3f4993581fd3b0a133d99405ffcb 100644 (file)
@@ -172,14 +172,14 @@ static int client_socket(char const *server)
        if (fr_inet_hton(&ipaddr, AF_INET, buffer, false) < 0) {
                fprintf(stderr, "%s: Failed looking up host %s: %s\n",
                        progname, buffer, fr_syserror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        sockfd = fr_socket_client_tcp(NULL, &ipaddr, port, false);
        if (sockfd < 0) {
                fprintf(stderr, "%s: Failed opening socket %s: %s\n",
                        progname, server, fr_syserror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        return sockfd;
@@ -202,7 +202,7 @@ static ssize_t do_challenge(int sockfd)
        if ((r != 16) || (conduit != FR_CONDUIT_AUTH_CHALLENGE)) {
                fprintf(stderr, "%s: Failed to read challenge.\n",
                        progname);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        fr_hmac_md5(challenge, (uint8_t const *) secret, strlen(secret),
@@ -428,11 +428,11 @@ int main(int argc, char **argv)
                case 'd':
                        if (file) {
                                fprintf(stderr, "%s: -d and -f cannot be used together.\n", progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        if (server) {
                                fprintf(stderr, "%s: -d and -s cannot be used together.\n", progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        radius_dir = optarg;
                        break;
@@ -446,7 +446,7 @@ int main(int argc, char **argv)
                        if (num_commands >= MAX_COMMANDS) {
                                fprintf(stderr, "%s: Too many '-e'\n",
                                        progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        commands[num_commands] = optarg;
@@ -509,7 +509,7 @@ int main(int argc, char **argv)
         */
        if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) {
                fr_perror("radmin");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (radius_dir) {
@@ -541,7 +541,7 @@ int main(int argc, char **argv)
                }
 
                cs = cf_section_alloc(NULL, NULL, "main", NULL);
-               if (!cs) exit(1);
+               if (!cs) exit(EXIT_FAILURE);
 
                if (cf_file_read(cs, buffer) < 0) {
                        fprintf(stderr, "%s: Errors reading or parsing %s\n", progname, buffer);
@@ -571,7 +571,7 @@ int main(int argc, char **argv)
                                              FR_ITEM_POINTER(FR_TYPE_STRING, &file), NULL, T_DOUBLE_QUOTED_STRING);
                        if (rcode < 0) {
                                fprintf(stderr, "%s: Failed parsing listen section 'socket'\n", progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        if (!file) {
@@ -591,7 +591,7 @@ int main(int argc, char **argv)
                                              FR_ITEM_POINTER(FR_TYPE_STRING, &uid_name), NULL, T_DOUBLE_QUOTED_STRING);
                        if (rcode < 0) {
                                fprintf(stderr, "%s: Failed parsing listen section 'uid'\n", progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        if (!uid_name) break;
@@ -599,7 +599,7 @@ int main(int argc, char **argv)
                        pwd = getpwnam(uid_name);
                        if (!pwd) {
                                fprintf(stderr, "%s: Failed getting UID for user %s: %s\n", progname, uid_name, strerror(errno));
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        if (uid != pwd->pw_uid) continue;
@@ -608,7 +608,7 @@ int main(int argc, char **argv)
                                              FR_ITEM_POINTER(FR_TYPE_STRING, &gid_name), NULL, T_DOUBLE_QUOTED_STRING);
                        if (rcode < 0) {
                                fprintf(stderr, "%s: Failed parsing listen section 'gid'\n", progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        if (!gid_name) break;
@@ -617,7 +617,7 @@ int main(int argc, char **argv)
                        if (!grp) {
                                fprintf(stderr, "%s: Failed resolving gid of group %s: %s\n",
                                        progname, gid_name, strerror(errno));
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        if (gid != grp->gr_gid) continue;
@@ -627,7 +627,7 @@ int main(int argc, char **argv)
 
                if (!file) {
                        fprintf(stderr, "%s: Could not find control socket in %s\n", progname, buffer);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                /*
@@ -642,7 +642,7 @@ int main(int argc, char **argv)
 
                                        if (!radmin_log.file) {
                                                fprintf(stderr, "%s: Invalid value for 'radmin' log destination", progname);
-                                               exit(1);
+                                               exit(EXIT_FAILURE);
                                        }
                                }
                        }
@@ -652,7 +652,7 @@ int main(int argc, char **argv)
                        radmin_log.fd = open(radmin_log.file, O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
                        if (radmin_log.fd < 0) {
                                fprintf(stderr, "%s: Failed opening %s: %s\n", progname, radmin_log.file, fr_syserror(errno));
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        radmin_log.dst = L_DST_FILES;
@@ -663,14 +663,14 @@ int main(int argc, char **argv)
                inputfp = fopen(input_file, "r");
                if (!inputfp) {
                        fprintf(stderr, "%s: Failed opening %s: %s\n", progname, input_file, fr_syserror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
        }
 
        if (!file && !server) {
                fprintf(stderr, "%s: Must use one of '-d' or '-f' or '-s'\n",
                        progname);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -692,7 +692,7 @@ int main(int argc, char **argv)
         */
        signal(SIGPIPE, SIG_IGN);
 
-       if (do_connect(&sockfd, file, server) < 0) exit(1);
+       if (do_connect(&sockfd, file, server) < 0) exit(EXIT_FAILURE);
 
        /*
         *      Run commans from the command-line.
@@ -702,7 +702,7 @@ int main(int argc, char **argv)
 
                for (i = 0; i <= num_commands; i++) {
                        len = run_command(sockfd, commands[i], buffer, sizeof(buffer));
-                       if (len < 0) exit(1);
+                       if (len < 0) exit(EXIT_FAILURE);
 
                        if (len == FR_CONDUIT_FAIL) exit_status = EXIT_FAILURE;
                }
@@ -759,7 +759,7 @@ int main(int argc, char **argv)
                        if (!p) {
                                fprintf(stderr, "%s: Input line too long\n",
                                        progname);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        *p = '\0';
@@ -800,7 +800,7 @@ int main(int argc, char **argv)
                }
 
                if (strcmp(line, "reconnect") == 0) {
-                       if (do_connect(&sockfd, file, server) < 0) exit(1);
+                       if (do_connect(&sockfd, file, server) < 0) exit(EXIT_FAILURE);
                        line = NULL;
                        continue;
                }
@@ -843,14 +843,14 @@ int main(int argc, char **argv)
                        if (!quiet) fprintf(stderr, "... reconnecting ...\n");
 
                        if (do_connect(&sockfd, file, server) < 0) {
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        retries++;
                        if (retries < 2) goto retry;
 
                        fprintf(stderr, "Failed to connect to server\n");
-                       exit(1);
+                       exit(EXIT_FAILURE);
 
                } else if (len == FR_CONDUIT_SUCCESS) {
                        break;
index 1c04b699e849faf221ca26afc739694599061141..7228a76c6d85a35514ea28c4264c215480b9ee9e 100644 (file)
@@ -325,28 +325,28 @@ int main(int argc, char **argv)
 
        /* Read radiusd.conf */
        maincs = cf_section_alloc(NULL, NULL, "main", NULL);
-       if (!maincs) exit(1);
+       if (!maincs) exit(EXIT_FAILURE);
 
        snprintf(buffer, sizeof(buffer), "%.200s/radiusd.conf", raddb_dir);
        if (cf_file_read(maincs, buffer) < 0) {
                fprintf(stderr, "%s: Error reading or parsing radiusd.conf\n", argv[0]);
                talloc_free(maincs);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        cs = cf_section_find(maincs, "modules", NULL);
        if (!cs) {
                fprintf(stderr, "%s: No modules section found in radiusd.conf\n", argv[0]);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
        /* Read the radutmp section of radiusd.conf */
        cs = cf_section_find(cs, "radutmp", NULL);
        if (!cs) {
                fprintf(stderr, "%s: No configuration information in radutmp section of radiusd.conf\n", argv[0]);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
-       if (cf_section_rules_push(cs, module_config) < 0) exit(1);
+       if (cf_section_rules_push(cs, module_config) < 0) exit(EXIT_FAILURE);
        cf_section_parse(maincs, NULL, cs);
 
        /* Assign the correct path for the radutmp file */
index 4fcf6f21d1b426cc3995e4472f7c68922b7741fb..3d1d86bebab999b61326d9a5b74dc60d66889e60 100644 (file)
@@ -655,7 +655,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                if (!fp) {
                        fprintf(stderr, "Error opening %s: %s\n",
                                directory, fr_syserror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                filename = directory;
@@ -676,7 +676,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                        if (!feof(fp)) {
                                fprintf(stderr, "Line %d too long in %s\n",
                                        lineno, directory);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                } else {
                        *p = '\0';
@@ -700,7 +700,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                q = strchr(p, ' ');
                if ((size_t)(q - p) > (sizeof(test_type) - 1)) {
                        fprintf(stderr, "Verb \"%.*s\" is too long\n", (int)(q - p), p);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                strlcpy(test_type, p, (q - p) + 1);
@@ -710,7 +710,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                        if (outlen == 0) {
                                fprintf(stderr, "Parse error in line %d of %s\n",
                                        lineno, directory);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                print_hex:
@@ -739,7 +739,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                        if (strcmp(p + 5, output) != 0) {
                                fprintf(stderr, "Mismatch at line %d of %s\n\tgot      : %s\n\texpected : %s\n",
                                        lineno, directory, output, p + 5);
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        continue;
                }
@@ -770,7 +770,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                                if (len < 0) {
                                        fprintf(stderr, "Failed encoding %s: %s\n",
                                                vp->da->name, fr_strerror());
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
 
                                attr += len;
@@ -795,7 +795,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                                len = encode_hex(p + 7, data, sizeof(data));
                                if (len == 0) {
                                        fprintf(stderr, "Failed decoding hex string at line %d of %s\n", lineno, directory);
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
                        }
 
@@ -811,7 +811,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
 
                                if (my_len > len) {
                                        fprintf(stderr, "Internal sanity check failed at %d\n", __LINE__);
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
 
                                attr += my_len;
@@ -870,7 +870,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                                if (len < 0) {
                                        fprintf(stderr, "Failed encoding %s: %s\n",
                                                vp->da->name, fr_strerror());
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
                                attr += len;
                        };
@@ -892,7 +892,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                                len = encode_hex(p + 12, data, sizeof(data));
                                if (len == 0) {
                                        fprintf(stderr, "Failed decoding hex string at line %d of %s\n", lineno, directory);
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
                        }
 
@@ -994,7 +994,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
                                len = encode_hex(p + 14, data, sizeof(data));
                                if (len == 0) {
                                        fprintf(stderr, "Failed decoding hex string at line %d of %s\n", lineno, directory);
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
                        }
 
@@ -1099,7 +1099,7 @@ static void process_file(fr_dict_t *dict, const char *root_dir, char const *file
 
                fprintf(stderr, "Unknown input at line %d of %s\n", lineno, directory);
 
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fp != stdin) fclose(fp);
@@ -1115,7 +1115,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -x                     Debugging mode.\n");
        fprintf(stderr, "  -M                     Show talloc memory report.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
index 27b8776e90c51978b9e45c19b31aa57e2c6452d7..cf314944d93f3f62fc27e97aa91e85281995faef 100644 (file)
@@ -68,7 +68,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -x                     Debugging mode.\n");
        fprintf(stderr, "  -M                     Show program version information.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 static int process_file(char const *filename)
@@ -85,7 +85,7 @@ static int process_file(char const *filename)
        if (cf_file_read(main_config.config, filename) < 0) {
                fprintf(stderr, "unit_test_map: Failed parsing %s\n",
                        filename);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -180,17 +180,17 @@ int main(int argc, char *argv[])
         */
        if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) {
                fr_perror("unit_test_attribute");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fr_dict_from_file(autofree, &dict, dict_dir, FR_DICTIONARY_FILE, "radius") < 0) {
                fr_perror("unit_test_attribute");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fr_dict_read(dict, radius_dir, FR_DICTIONARY_FILE) == -1) {
                fr_log_perror(&default_log, L_ERR, "Failed to initialize the dictionaries");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (argc < 2) {
index 06eb9ee2e31dac4589e2309baebe3cfb18a0b723..448914f5e6a00dc9eeec1eb53f73fc21e44a8ca3 100644 (file)
@@ -186,7 +186,7 @@ static inline void unlang_push(unlang_stack_t *stack, unlang_t *program,
 
        if (stack->depth >= (UNLANG_STACK_MAX - 1)) {
                ERROR("Internal sanity check failed: module stack is too deep");
-               fr_exit(1);
+               fr_exit(EXIT_FAILURE);
        }
 
        stack->depth++;
@@ -1466,7 +1466,7 @@ static unlang_action_t unlang_foreach(REQUEST *request,
 
                if (stack->depth >= UNLANG_STACK_MAX) {
                        ERROR("Internal sanity check failed: module stack is too deep");
-                       fr_exit(1);
+                       fr_exit(EXIT_FAILURE);
                }
 
                /*
index d01f2cdf3d6faa7071e96a8e31f095085f525699..145a0301176093e469a78e9aa93911ab691a0a6a 100644 (file)
@@ -101,7 +101,7 @@ static void NEVER_RETURNS usage(void)
        DEBUG("  -v                     Show program version information.");
        DEBUG("  -x                     Debugging mode.");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 
@@ -625,12 +625,12 @@ int main(int argc, char **argv)
 
        if (fr_dict_from_file(NULL, &dict, dict_dir, FR_DICTIONARY_FILE, "radius") < 0) {
                fr_perror("dhcpclient");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fr_dict_read(dict, radius_dir, FR_DICTIONARY_FILE) == -1) {
                fr_log_perror(&default_log, L_ERR, "Failed to initialize the dictionaries");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
        fr_strerror();  /* Clear the error buffer */
 
@@ -641,7 +641,7 @@ int main(int argc, char **argv)
        if (!da) {
                if (fr_dict_read(dict, dict_dir, "dictionary.dhcp") < 0) {
                        ERROR("Failed reading dictionary.dhcp");
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
        }
 
@@ -682,7 +682,7 @@ int main(int argc, char **argv)
                iface_ind = if_nametoindex(iface);
                if (iface_ind <= 0) {
                        ERROR("Unknown interface: %s", iface);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                if (server_ipaddr.addr.v4.s_addr == 0xFFFFFFFF) {
@@ -694,7 +694,7 @@ int main(int argc, char **argv)
        request = request_init(filename);
        if (!request || !request->vps) {
                ERROR("Nothing to send");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -712,7 +712,7 @@ int main(int argc, char **argv)
        if (!request->code) {
                ERROR("Command was %s, and request did not contain DHCP-Message-Type nor Packet-Type",
                      (argc >= 3) ? "'auto'" : "unspecified");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -727,7 +727,7 @@ int main(int argc, char **argv)
         */
        if (fr_dhcpv4_packet_encode(request) < 0) {
                ERROR("Failed encoding packet");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
index 2ec41e2e4af76c8a39b2d035f4be3c71da2b4cfb..1cec824a7db5cff957f8a74969c4d5292e4d88ef 100644 (file)
@@ -396,7 +396,7 @@ static int hextoint(char x)
 
        fprintf(stderr, "Bad input.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char **argv)
@@ -411,7 +411,7 @@ int main(int argc, char **argv)
            !(version = atoi(argv[3]))) {
                error:
                fprintf(stderr, "Usage: %s 0x<key> 0x<rand> [1|2|3]\n", argv[0]);
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        for (i = 0; i < 16; i++) {
index a1fffc6674ef528a639418b6b61c3681724b25b8..aeb14410017982c962393e0d581325ce84f5f933 100644 (file)
@@ -258,7 +258,7 @@ int main(int argc, char **argv)
 
        if (argc != 2) {
                fprintf(stderr, "Usage: test timestring\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
        l = timestr_match(argv[1], time(NULL));
        printf ("%s: %d seconds left\n", argv[1], l);
index a42c35c8dbe5c581e6c2bbdd7b89756d5a98b743..5a8855e756019b951d341aa27a131efc07be39cb 100644 (file)
@@ -1363,7 +1363,7 @@ int main(int argc, char *argv[])
 
        conf = talloc_zero(NULL, ippool_tool_t);
        conf->cs = cf_section_alloc(NULL, NULL, "main", NULL);
-       if (!conf->cs) exit(1);
+       if (!conf->cs) exit(EXIT_FAILURE);
 
        trigger_exec_init(conf->cs);
 
@@ -1450,7 +1450,7 @@ do { \
                break;
 
        case 'f':
-               if (cf_file_read(conf->cs, optarg) < 0) exit(1);
+               if (cf_file_read(conf->cs, optarg) < 0) exit(EXIT_FAILURE);
                break;
 
        default:
@@ -1472,7 +1472,7 @@ do { \
        cp = cf_pair_alloc(conf->cs, "server", argv[0], T_OP_EQ, T_BARE_WORD, T_DOUBLE_QUOTED_STRING);
        if (!cp) {
                ERROR("Failed creating server pair");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
        cf_pair_add(conf->cs, cp);
 
@@ -1508,7 +1508,7 @@ do { \
 
        if (!do_import && !do_export && !list_pools && !print_stats && (p == ops)) {
                ERROR("Nothing to do!");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -1537,7 +1537,7 @@ do { \
 
        if (driver_init(conf, conf->cs, &conf->driver) < 0) {
                ERROR("Driver initialisation failed");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (do_import) {
@@ -1560,7 +1560,7 @@ do { \
                        pools[0] = pool_arg;
                } else {
                        slen = driver_get_pools(conf, &pools, conf->driver);
-                       if (slen < 0) exit(1);
+                       if (slen < 0) exit(EXIT_FAILURE);
                }
 
                for (i = 0; i < (size_t)slen; i++) {
@@ -1568,7 +1568,7 @@ do { \
                        uint64_t acum = 0;
 
                        if (driver_get_stats(&stats, conf->driver,
-                                            pools[i], talloc_array_length(pools[i])) < 0) exit(1);
+                                            pools[i], talloc_array_length(pools[i])) < 0) exit(EXIT_FAILURE);
 
                        pool_str = fr_asprint(conf, (char *)pools[i], talloc_array_length(pools[i]), '"');
                        INFO("pool             : %s", pool_str);
@@ -1600,7 +1600,7 @@ do { \
                uint8_t         **pools;
 
                slen = driver_get_pools(conf, &pools, conf->driver);
-               if (slen < 0) exit(1);
+               if (slen < 0) exit(EXIT_FAILURE);
                if (slen > 0) {
                        for (i = 0; i < (size_t)slen; i++) {
                                char *pool_str;
@@ -1640,7 +1640,7 @@ do { \
                uint64_t count = 0;
 
                if (driver_add_lease(&count, conf->driver, p) < 0) {
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
                INFO("Added %" PRIu64 " address(es)/prefix(es)", count);
        }
@@ -1651,7 +1651,7 @@ do { \
                uint64_t count = 0;
 
                if (driver_remove_lease(&count, conf->driver, p) < 0) {
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
                INFO("Removed %" PRIu64 " address(es)/prefix(es)", count);
        }
@@ -1662,7 +1662,7 @@ do { \
                uint64_t count = 0;
 
                if (driver_release_lease(&count, conf->driver, p) < 0) {
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
                INFO("Released %" PRIu64 " address(es)/prefix(es)", count);
        }
@@ -1674,7 +1674,7 @@ do { \
                size_t len, i;
 
                if (driver_show_lease(&leases, conf->driver, p) < 0) {
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
                rad_assert(leases);
 
@@ -1739,7 +1739,7 @@ do { \
                uint64_t count = 0;
 
                if (driver_modify_lease(&count, conf->driver, p) < 0) {
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
                INFO("Modified %" PRIu64 " address(es)/prefix(es)", count);
        }
index 076567758bfa2c177798f9dabf3bca9d9afa9d98..04fb1f3cdfa1badf71e4ca5a831df95a3e108a0a 100644 (file)
@@ -69,7 +69,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -s size                set queue size.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
 
                if (!fr_atomic_queue_push(aq, data)) {
                        fprintf(stderr, "Failed pushing at %d\n", i);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
 #ifndef NDEBUG
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
         */
        if (fr_atomic_queue_push(aq, data)) {
                fprintf(stderr, "Pushed an entry past the end of the queue.");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
 #ifndef NDEBUG
@@ -157,14 +157,14 @@ int main(int argc, char *argv[])
        for (i = 0; i < size; i++) {
                if (!fr_atomic_queue_pop(aq, &data)) {
                        fprintf(stderr, "Failed popping at %d\n", i);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                val = (intptr_t) data;
                if (val != (i + OFFSET)) {
                        fprintf(stderr, "Pop expected %d, got %d\n",
                                i + OFFSET, (int) val);
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
 #ifndef NDEBUG
@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
         */
        if (fr_atomic_queue_pop(aq, &data)) {
                fprintf(stderr, "Popped an entry past the end of the queue.");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
 #ifndef NDEBUG
index be47c69529b527be0b3a1f03160973d9ebb16616..5915525610fca6aa075eb64cebfdf8aa7da56801 100644 (file)
@@ -83,7 +83,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -t                     Touch memory for fake packets.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 static void *channel_master(void *arg)
@@ -104,7 +104,7 @@ static void *channel_master(void *arg)
        ms = fr_message_set_create(ctx, MAX_MESSAGES, sizeof(fr_channel_data_t), MAX_MESSAGES * 1024);
        if (!ms) {
                fprintf(stderr, "Failed creating message set\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        MPRINT1("Master started.\n");
@@ -115,7 +115,7 @@ static void *channel_master(void *arg)
        rcode = fr_channel_signal_open(channel);
        if (rcode < 0) {
                fprintf(stderr, "Failed signaling open: %s\n", strerror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -204,7 +204,7 @@ check_close:
                        rcode = fr_channel_signal_worker_close(channel);
                        if (rcode < 0) {
                                fprintf(stderr, "Failed signaling close: %s\n", strerror(errno));
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
 
                        signaled_close = true;
@@ -220,7 +220,7 @@ check_close:
                        if (num_events == EINTR) continue;
 
                        fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                if (num_events == 0) continue;
@@ -330,7 +330,7 @@ static void *channel_worker(void *arg)
        ms = fr_message_set_create(ctx, MAX_MESSAGES, sizeof(fr_channel_data_t), MAX_MESSAGES * 1024);
        if (!ms) {
                fprintf(stderr, "Failed creating message set\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        MPRINT1("\tWorker started.\n");
@@ -349,7 +349,7 @@ static void *channel_worker(void *arg)
                        if (errno == EINTR) continue;
 
                        fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                if (num_events == 0) continue;
@@ -559,7 +559,7 @@ int main(int argc, char *argv[])
        channel = fr_channel_create(autofree, control_master, control_worker);
        if (!channel) {
                fprintf(stderr, "channel_test: Failed to create channel\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
index 092b4257af5d6f72aed9b143e1332f2c0f955323..9dc37cb68e1ace4334a6527ded068f5ea8760d7c 100644 (file)
@@ -80,7 +80,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -m <messages>          Send number of messages.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 typedef struct my_message_t {
@@ -111,7 +111,7 @@ static void *control_master(UNUSED void *arg)
                num_events = kevent(kq, NULL, 0, &kev, 1, NULL);
                if (num_events < 0) {
                        fprintf(stderr, "Failed reading kevent: %s\n", strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                MPRINT1("Master draining the control plane.\n");
@@ -124,7 +124,7 @@ static void *control_master(UNUSED void *arg)
 
                        if (data_size < 0) {
                                fprintf(stderr, "Failed reading control message\n");
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                
                        rad_assert(data_size == sizeof(m));
@@ -217,11 +217,11 @@ int main(int argc, char *argv[])
        control = fr_control_create(autofree, kq, aq, 1024);
        if (!control) {
                fprintf(stderr, "control_test: Failed to create control plane\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        rb = fr_ring_buffer_create(autofree, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE);
-       if (!rb) exit(1);
+       if (!rb) exit(EXIT_FAILURE);
 
        /*
         *      Start the two threads, with the channel.
index fa88d38edef9ec34601b5753edd16e587d01abb1..f5493b3a4d57397d43e65d27174ec5223f59e8a8 100644 (file)
@@ -163,7 +163,7 @@ static void  free_blocks(UNUSED fr_message_set_t *ms, UNUSED uint32_t *seed, int
 #ifndef NDEBUG
                rad_assert(rcode == 0);
 #else
-               if (rcode != 0) exit(1);
+               if (rcode != 0) exit(EXIT_FAILURE);
 #endif
 
                used -= array[index];
@@ -188,7 +188,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -t                     Touch 'packet' memory.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
        ms = fr_message_set_create(autofree, ARRAY_SIZE, sizeof(fr_message_t), ARRAY_SIZE * 1024);
        if (!ms) {
                fprintf(stderr, "Failed creating message set\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        seed = 0xabcdef;
index a79f4eb2e045ad47dc2fd66c68b22ac39545968e..9327ddaf88a65c9f30d6cf53f85de1b21f91880e 100644 (file)
@@ -86,7 +86,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -w N                   Create N workers.  Default is 1.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 static fr_io_final_t test_process(REQUEST *request, fr_io_action_t action)
@@ -166,13 +166,13 @@ static void *worker_thread(void *arg)
        el = fr_event_list_alloc(ctx, NULL, NULL);
        if (!el) {
                fprintf(stderr, "radius_test: Failed to create the event list\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        worker = sw->worker = fr_worker_create(ctx, el, &default_log, L_DBG_LVL_MAX);
        if (!worker) {
                fprintf(stderr, "radius_test: Failed to create the worker\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        MPRINT1("\tWorker %d looping.\n", sw->id);
@@ -194,7 +194,7 @@ static void send_reply(int sockfd, fr_channel_data_t *reply)
 
        if (sendto(sockfd, reply->m.data, reply->m.data_size, 0, (struct sockaddr *) &pc->src, pc->salen) < 0) {
                fprintf(stderr, "Failed sending reply: %s\n", strerror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        talloc_free(pc);
@@ -225,7 +225,7 @@ static void master_process(TALLOC_CTX *ctx)
        ms = fr_message_set_create(ctx, MAX_MESSAGES, sizeof(fr_channel_data_t), MAX_MESSAGES * 1024);
        if (!ms) {
                fprintf(stderr, "Failed creating message set\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -243,12 +243,12 @@ static void master_process(TALLOC_CTX *ctx)
        sockfd = fr_socket_server_udp(&my_ipaddr, &my_port, NULL, true);
        if (sockfd < 0) {
                fprintf(stderr, "radius_test: Failed creating socket: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fr_socket_bind(sockfd, &my_ipaddr, &my_port, NULL) < 0) {
                fprintf(stderr, "radius_test: Failed binding to socket: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -257,7 +257,7 @@ static void master_process(TALLOC_CTX *ctx)
        EV_SET(&events[0], sockfd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL);
        if (kevent(kq_master, events, 1, NULL, 0, NULL) < 0) {
                fprintf(stderr, "Failed setting KQ for EVFILT_READ: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        /*
@@ -315,7 +315,7 @@ static void master_process(TALLOC_CTX *ctx)
                        if (errno == EINTR) continue;
 
                        fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                if (num_events == 0) continue;
@@ -405,7 +405,7 @@ static void master_process(TALLOC_CTX *ctx)
                        rcode = fr_channel_send_request(workers[which_worker].ch, cd, &reply);
                        if (rcode < 0) {
                                fprintf(stderr, "Failed sending request: %s\n", strerror(errno));
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        which_worker++;
                        if (which_worker >= num_workers) which_worker = 0;
@@ -550,7 +550,7 @@ int main(int argc, char *argv[])
                case 'i':
                        if (fr_inet_pton_port(&my_ipaddr, &port16, optarg, -1, AF_INET, true, false) < 0) {
                                fprintf(stderr, "Failed parsing ipaddr: %s\n", fr_strerror());
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        my_port = port16;
                        break;
index 8ae7ef2f8bad413cd4069f660a6bb959fdb15e09..0f2a66d82eb2ecf95959f112c337514d9b6b601f 100644 (file)
@@ -119,12 +119,12 @@ static int test_open(void *ctx)
        io_ctx->sockfd = fr_socket_server_udp(&io_ctx->ipaddr, &io_ctx->port, NULL, true);
        if (io_ctx->sockfd < 0) {
                fprintf(stderr, "radius_test: Failed creating socket: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (fr_socket_bind(io_ctx->sockfd, &io_ctx->ipaddr, &io_ctx->port, NULL) < 0) {
                fprintf(stderr, "radius_test: Failed binding to socket: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        return 0;
@@ -211,7 +211,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -s <secret>            Set shared secret.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
                case 'i':
                        if (fr_inet_pton_port(&my_ipaddr, &port16, optarg, -1, AF_INET, true, false) < 0) {
                                fprintf(stderr, "Failed parsing ipaddr: %s\n", fr_strerror());
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        my_port = port16;
                        break;
@@ -282,10 +282,10 @@ int main(int argc, char *argv[])
        sched = fr_schedule_create(autofree, NULL, &default_log, debug_lvl, num_networks, num_workers, NULL, NULL);
        if (!sched) {
                fprintf(stderr, "schedule_test: Failed to create scheduler\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
-       if (listen.app_io->open(listen.app_io_instance) < 0) exit(1);
+       if (listen.app_io->open(listen.app_io_instance) < 0) exit(EXIT_FAILURE);
 
 #if 0
        /*
@@ -294,7 +294,7 @@ int main(int argc, char *argv[])
        EV_SET(&events[0], sockfd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL);
        if (kevent(kq_master, events, 1, NULL, 0, NULL) < 0) {
                fprintf(stderr, "Failed setting KQ for EVFILT_READ: %s\n", fr_strerror());
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 #endif
 
index b3a9a6b6bd2dee3b4e1e924ae898e24969cfba6c..8dc9a326539562a51ab35eab6ce5c7c5e84c5fa8 100644 (file)
@@ -88,10 +88,10 @@ static void  alloc_blocks(fr_ring_buffer_t *rb, uint32_t *seed, UNUSED int *star
                array[index] = hash;
                p = fr_ring_buffer_reserve(rb, 2048);
 
-               if (rad_cond_assert(!p)) exit(1);
+               if (rad_cond_assert(!p)) exit(EXIT_FAILURE);
 
                data[index] = fr_ring_buffer_alloc(rb, hash);
-               if (rad_cond_assert(data[index] != p)) exit(1);
+               if (rad_cond_assert(data[index] != p)) exit(EXIT_FAILURE);
 
                if (debug_lvl > 1) printf("%08x\t", hash);
 
@@ -113,7 +113,7 @@ static void  free_blocks(fr_ring_buffer_t *rb, UNUSED uint32_t *seed, int *start
                index = (*start + i) & (ARRAY_SIZE - 1);
 
                rcode = fr_ring_buffer_free(rb, array[index]);
-               if (!rad_cond_assert(rcode == 0)) exit(1);
+               if (!rad_cond_assert(rcode == 0)) exit(EXIT_FAILURE);
 
                used -= array[index];
                rad_assert(fr_ring_buffer_used(rb) == used);
@@ -135,7 +135,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -x                     Debugging mode.\n");
        fprintf(stderr, "  -s <string>            Set random seed to <string>.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
        rb = fr_ring_buffer_create(autofree, ARRAY_SIZE * 1024);
        if (!rb) {
                fprintf(stderr, "Failed creating ring buffer\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        seed = 0xabcdef;
index 83aecdc12e1f86b750af36e1646eb2f8a61a0321..48647dcbbad61048014c01b0da01c153d4a74e00 100644 (file)
@@ -50,7 +50,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -w <num>               Start num worker threads\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 int main(int argc, char *argv[])
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
        sched = fr_schedule_create(autofree, NULL, &default_log, L_DBG_LVL_MAX, num_networks, num_workers, NULL, NULL);
        if (!sched) {
                fprintf(stderr, "schedule_test: Failed to create scheduler\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        sleep(1);
index a70cafa9f20131aaeb563a04dbb94085b009f6b6..9cba3c676f39a58354df2df718f49b5a94beb775 100644 (file)
@@ -96,7 +96,7 @@ static void NEVER_RETURNS usage(void)
        fprintf(stderr, "  -w N                   Create N workers.  Default is 1.\n");
        fprintf(stderr, "  -x                     Debugging mode.\n");
 
-       exit(1);
+       exit(EXIT_FAILURE);
 }
 
 static fr_io_final_t test_process(REQUEST *request, fr_io_action_t action)
@@ -169,13 +169,13 @@ static void *worker_thread(void *arg)
        el = fr_event_list_alloc(ctx, NULL, NULL);
        if (!el) {
                fprintf(stderr, "worker_test: Failed to create the event list\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        worker = sw->worker = fr_worker_create(ctx, el, &default_log, L_DBG_LVL_MAX);
        if (!worker) {
                fprintf(stderr, "worker_test: Failed to create the worker\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        MPRINT1("\tWorker %d looping.\n", sw->id);
@@ -209,7 +209,7 @@ static void master_process(void)
        ms = fr_message_set_create(ctx, MAX_MESSAGES, sizeof(fr_channel_data_t), MAX_MESSAGES * 1024);
        if (!ms) {
                fprintf(stderr, "Failed creating message set\n");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        MPRINT1("Master started.\n");
@@ -339,7 +339,7 @@ check_close:
                                MPRINT1("Master asked exit for worker %d.\n", workers[i].id);
                                if (rcode < 0) {
                                        fprintf(stderr, "Failed signaling close %d: %s\n", i, strerror(errno));
-                                       exit(1);
+                                       exit(EXIT_FAILURE);
                                }
                        }
                        signaled_close = true;
@@ -355,7 +355,7 @@ check_close:
                        if (errno == EINTR) continue;
 
                        fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
                if (num_events == 0) continue;
@@ -490,7 +490,7 @@ int main(int argc, char *argv[])
 
        if (fr_time_start() < 0) {
                fprintf(stderr, "Failed to start time: %s\n", strerror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        fr_log_init(&default_log, false);