I cannot believe I let this one slip through (and so did the compilers).
When I refactored "data" to be "main" this included the refactor in the function called "main".
This is dangerous at worst and at best bad practice.
Given that "data" is no longer to be used in the main(), just rename the uses of "main" back to "data" for the variable name only (not the typedef structure name).
#include "byte_dump.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- byte_dump_main_t main = byte_dump_main_t_initialize;
+ byte_dump_main_t data = byte_dump_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = byte_dump_main(arguments, &main);
+ const f_status_t status = byte_dump_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "control.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- control_main_t main = control_data_initialize;
+ control_main_t data = control_data_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = control_main(arguments, &main);
+ const f_status_t status = control_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "controller.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- controller_main_t main = controller_main_t_initialize;
+ controller_main_t data = controller_main_t_initialize;
f_status_t status = F_none;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- main.pid = getpid();
+ data.pid = getpid();
- f_signal_set_empty(&main.signal.set);
- f_signal_set_add(F_signal_abort, &main.signal.set);
- f_signal_set_add(F_signal_hangup, &main.signal.set);
- f_signal_set_add(F_signal_interrupt, &main.signal.set);
- f_signal_set_add(F_signal_quit, &main.signal.set);
- f_signal_set_add(F_signal_termination, &main.signal.set);
- f_signal_mask(SIG_BLOCK, &main.signal.set, 0);
+ f_signal_set_empty(&data.signal.set);
+ f_signal_set_add(F_signal_abort, &data.signal.set);
+ f_signal_set_add(F_signal_hangup, &data.signal.set);
+ f_signal_set_add(F_signal_interrupt, &data.signal.set);
+ f_signal_set_add(F_signal_quit, &data.signal.set);
+ f_signal_set_add(F_signal_termination, &data.signal.set);
+ f_signal_mask(SIG_BLOCK, &data.signal.set, 0);
- status = f_signal_open(&main.signal);
+ status = f_signal_open(&data.signal);
// if there is an error opening a signal descriptor, then do not handle signals.
if (F_status_is_error(status)) {
- f_signal_mask(SIG_UNBLOCK, &main.signal.set, 0);
- f_signal_close(&main.signal);
+ f_signal_mask(SIG_UNBLOCK, &data.signal.set, 0);
+ f_signal_close(&data.signal);
}
// @fixme: bad design in POSIX where there is no get umask without setting it.
- main.umask = umask(0);
+ data.umask = umask(0);
// restore umask.
- umask(main.umask);
+ umask(data.umask);
- status = controller_main(arguments, &main);
+ status = controller_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
close(f_type_descriptor_input);
close(f_type_descriptor_error);
- f_signal_close(&main.signal);
+ f_signal_close(&data.signal);
if (status == F_child) {
- exit(main.child);
+ exit(data.child);
}
if (F_status_is_error(status)) {
* @see exit()
*/
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fake_main_t main = fake_main_t_initialize;
+ fake_main_t data = fake_main_t_initialize;
f_status_t status = F_none;
- f_signal_set_empty(&main.signal.set);
- f_signal_set_add(F_signal_abort, &main.signal.set);
- f_signal_set_add(F_signal_hangup, &main.signal.set);
- f_signal_set_add(F_signal_interrupt, &main.signal.set);
- f_signal_set_add(F_signal_quit, &main.signal.set);
- f_signal_set_add(F_signal_termination, &main.signal.set);
+ f_signal_set_empty(&data.signal.set);
+ f_signal_set_add(F_signal_abort, &data.signal.set);
+ f_signal_set_add(F_signal_hangup, &data.signal.set);
+ f_signal_set_add(F_signal_interrupt, &data.signal.set);
+ f_signal_set_add(F_signal_quit, &data.signal.set);
+ f_signal_set_add(F_signal_termination, &data.signal.set);
- status = f_signal_mask(SIG_BLOCK, &main.signal.set, 0);
+ status = f_signal_mask(SIG_BLOCK, &data.signal.set, 0);
if (F_status_is_error_not(status)) {
- status = f_signal_open(&main.signal);
+ status = f_signal_open(&data.signal);
// if there is an error opening a signal descriptor, then do not handle signals.
if (F_status_is_error(status)) {
- f_signal_mask(SIG_UNBLOCK, &main.signal.set, 0);
- f_signal_close(&main.signal);
+ f_signal_mask(SIG_UNBLOCK, &data.signal.set, 0);
+ f_signal_close(&data.signal);
}
}
// @fixme: bad design in POSIX where there is no get umask without setting it.
- main.umask = umask(0);
+ data.umask = umask(0);
// restore umask.
- umask(main.umask);
+ umask(data.umask);
- status = fake_main(arguments, &main);
+ status = fake_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
close(f_type_descriptor_input);
close(f_type_descriptor_error);
- f_signal_close(&main.signal);
+ f_signal_close(&data.signal);
if (status == F_child) {
- exit(main.child);
+ exit(data.child);
}
if (F_status_is_error(status)) {
#include "firewall.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- firewall_main_t main = firewall_main_t_initialize;
+ firewall_main_t data = firewall_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- if (F_status_is_error(firewall_main(arguments, &main))) {
+ if (F_status_is_error(firewall_main(arguments, &data))) {
return 1;
}
#include "fss_basic_list_read.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_basic_list_read_main_t main = fss_basic_list_read_main_t_initialize;
+ fss_basic_list_read_main_t data = fss_basic_list_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_basic_list_read_main(arguments, &main);
+ const f_status_t status = fss_basic_list_read_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_basic_list_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_basic_list_write_main_t main = fss_basic_list_write_main_t_initialize;
+ fss_basic_list_write_main_t data = fss_basic_list_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_basic_list_write_main(arguments, &main);
+ const f_status_t status = fss_basic_list_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
int main(const int argc, const f_string_t *argv) {
f_console_arguments_t arguments = { argc, argv };
- fss_basic_read_main_t main = fss_basic_read_main_t_initialize;
+ fss_basic_read_main_t data = fss_basic_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_basic_read_main(&arguments, &main);
+ const f_status_t status = fss_basic_read_main(&arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_basic_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_basic_write_main_t main = fss_basic_write_main_t_initialize;
+ fss_basic_write_main_t data = fss_basic_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_basic_write_main(arguments, &main);
+ const f_status_t status = fss_basic_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_embedded_list_read.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_embedded_list_read_main_t main = fss_embedded_list_read_main_t_initialize;
+ fss_embedded_list_read_main_t data = fss_embedded_list_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_embedded_list_read_main(arguments, &main);
+ const f_status_t status = fss_embedded_list_read_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_embedded_list_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_embedded_list_write_main_t main = fss_embedded_list_write_main_t_initialize;
+ fss_embedded_list_write_main_t data = fss_embedded_list_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_embedded_list_write_main(arguments, &main);
+ const f_status_t status = fss_embedded_list_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_extended_list_read.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_extended_list_read_main_t main = fss_extended_list_read_main_t_initialize;
+ fss_extended_list_read_main_t data = fss_extended_list_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_extended_list_read_main(arguments, &main);
+ const f_status_t status = fss_extended_list_read_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_extended_list_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_extended_list_write_main_t main = fss_extended_list_write_main_t_initialize;
+ fss_extended_list_write_main_t data = fss_extended_list_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_extended_list_write_main(arguments, &main);
+ const f_status_t status = fss_extended_list_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_extended_read.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_extended_read_main_t main = fss_extended_read_main_t_initialize;
+ fss_extended_read_main_t data = fss_extended_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_extended_read_main(arguments, &main);
+ const f_status_t status = fss_extended_read_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_extended_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_extended_write_main_t main = fss_extended_write_main_t_initialize;
+ fss_extended_write_main_t data = fss_extended_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_extended_write_main(arguments, &main);
+ const f_status_t status = fss_extended_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "fss_status_code.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- fss_status_code_main_t main = fss_status_code_main_t_initialize;
+ fss_status_code_main_t data = fss_status_code_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = fss_status_code_main(arguments, &main);
+ const f_status_t status = fss_status_code_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "iki_read.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- iki_read_main_t main = iki_read_main_t_initialize;
+ iki_read_main_t data = iki_read_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = iki_read_main(arguments, &main);
+ const f_status_t status = iki_read_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "iki_write.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- iki_write_main_t main = iki_write_main_t_initialize;
+ iki_write_main_t data = iki_write_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = iki_write_main(arguments, &main);
+ const f_status_t status = iki_write_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);
#include "status_code.h"
int main(const int argc, const f_string_t *argv) {
+
const f_console_arguments_t arguments = { argc, argv };
- status_code_main_t main = status_code_main_t_initialize;
+ status_code_main_t data = status_code_main_t_initialize;
if (f_pipe_input_exists()) {
- main.process_pipe = F_true;
+ data.process_pipe = F_true;
}
- const f_status_t status = status_code_main(arguments, &main);
+ const f_status_t status = status_code_main(arguments, &data);
// flush output pipes before closing.
fflush(f_type_output);