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."
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;
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),
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;
if (num_commands >= MAX_COMMANDS) {
fprintf(stderr, "%s: Too many '-e'\n",
progname);
- exit(1);
+ exit(EXIT_FAILURE);
}
commands[num_commands] = optarg;
*/
if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) {
fr_perror("radmin");
- exit(1);
+ exit(EXIT_FAILURE);
}
if (radius_dir) {
}
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);
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) {
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;
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;
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;
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;
if (!file) {
fprintf(stderr, "%s: Could not find control socket in %s\n", progname, buffer);
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
if (!radmin_log.file) {
fprintf(stderr, "%s: Invalid value for 'radmin' log destination", progname);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
}
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;
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);
}
/*
*/
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.
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;
}
if (!p) {
fprintf(stderr, "%s: Input line too long\n",
progname);
- exit(1);
+ exit(EXIT_FAILURE);
}
*p = '\0';
}
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;
}
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;
/* 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 */
if (!fp) {
fprintf(stderr, "Error opening %s: %s\n",
directory, fr_syserror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
filename = directory;
if (!feof(fp)) {
fprintf(stderr, "Line %d too long in %s\n",
lineno, directory);
- exit(1);
+ exit(EXIT_FAILURE);
}
} else {
*p = '\0';
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);
if (outlen == 0) {
fprintf(stderr, "Parse error in line %d of %s\n",
lineno, directory);
- exit(1);
+ exit(EXIT_FAILURE);
}
print_hex:
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;
}
if (len < 0) {
fprintf(stderr, "Failed encoding %s: %s\n",
vp->da->name, fr_strerror());
- exit(1);
+ exit(EXIT_FAILURE);
}
attr += len;
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);
}
}
if (my_len > len) {
fprintf(stderr, "Internal sanity check failed at %d\n", __LINE__);
- exit(1);
+ exit(EXIT_FAILURE);
}
attr += my_len;
if (len < 0) {
fprintf(stderr, "Failed encoding %s: %s\n",
vp->da->name, fr_strerror());
- exit(1);
+ exit(EXIT_FAILURE);
}
attr += len;
};
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);
}
}
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);
}
}
fprintf(stderr, "Unknown input at line %d of %s\n", lineno, directory);
- exit(1);
+ exit(EXIT_FAILURE);
}
if (fp != stdin) fclose(fp);
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[])
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)
if (cf_file_read(main_config.config, filename) < 0) {
fprintf(stderr, "unit_test_map: Failed parsing %s\n",
filename);
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
*/
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) {
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++;
if (stack->depth >= UNLANG_STACK_MAX) {
ERROR("Internal sanity check failed: module stack is too deep");
- fr_exit(1);
+ fr_exit(EXIT_FAILURE);
}
/*
DEBUG(" -v Show program version information.");
DEBUG(" -x Debugging mode.");
- exit(1);
+ exit(EXIT_FAILURE);
}
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 */
if (!da) {
if (fr_dict_read(dict, dict_dir, "dictionary.dhcp") < 0) {
ERROR("Failed reading dictionary.dhcp");
- exit(1);
+ exit(EXIT_FAILURE);
}
}
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) {
request = request_init(filename);
if (!request || !request->vps) {
ERROR("Nothing to send");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
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);
}
/*
*/
if (fr_dhcpv4_packet_encode(request) < 0) {
ERROR("Failed encoding packet");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
fprintf(stderr, "Bad input.\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
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++) {
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);
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);
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:
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);
if (!do_import && !do_export && !list_pools && !print_stats && (p == ops)) {
ERROR("Nothing to do!");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
if (driver_init(conf, conf->cs, &conf->driver) < 0) {
ERROR("Driver initialisation failed");
- exit(1);
+ exit(EXIT_FAILURE);
}
if (do_import) {
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++) {
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);
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;
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);
}
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);
}
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);
}
size_t len, i;
if (driver_show_lease(&leases, conf->driver, p) < 0) {
- exit(1);
+ exit(EXIT_FAILURE);
}
rad_assert(leases);
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);
}
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[])
if (!fr_atomic_queue_push(aq, data)) {
fprintf(stderr, "Failed pushing at %d\n", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
#ifndef NDEBUG
*/
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
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
*/
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
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)
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");
rcode = fr_channel_signal_open(channel);
if (rcode < 0) {
fprintf(stderr, "Failed signaling open: %s\n", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
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;
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;
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");
if (errno == EINTR) continue;
fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
if (num_events == 0) continue;
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);
}
/*
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 {
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");
if (data_size < 0) {
fprintf(stderr, "Failed reading control message\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
rad_assert(data_size == sizeof(m));
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.
#ifndef NDEBUG
rad_assert(rcode == 0);
#else
- if (rcode != 0) exit(1);
+ if (rcode != 0) exit(EXIT_FAILURE);
#endif
used -= array[index];
fprintf(stderr, " -t Touch 'packet' memory.\n");
fprintf(stderr, " -x Debugging mode.\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
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;
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)
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);
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);
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);
}
/*
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);
}
/*
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);
}
/*
if (errno == EINTR) continue;
fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
if (num_events == 0) continue;
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;
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;
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;
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[])
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;
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
/*
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
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);
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);
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[])
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;
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[])
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);
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)
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);
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");
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;
if (errno == EINTR) continue;
fprintf(stderr, "Failed waiting for kevent: %s\n", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
if (num_events == 0) continue;
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);