From eb0e12a1c1d77bf671b23f55c1f238068d536064 Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Wed, 1 Jan 2025 11:12:58 +0000 Subject: [PATCH] Applied indentation with 'make indent'. --- cl.c | 4 ++-- conf.c | 8 +++---- convert-fcrontab.c | 4 ++-- database.c | 58 +++++++++++++++++++++++----------------------- env_list.c | 18 +++++++------- exe_list.c | 14 +++++------ exe_list_test.c | 4 ++-- fcron.c | 15 +++++++----- fcrondyn.c | 6 ++--- fcrondyn_svr.c | 35 +++++++++++++++------------- fcronsighup.c | 22 ++++++++++-------- fcrontab.c | 9 +++---- fifo_list.c | 16 ++++++------- fileconf.c | 22 +++++++++--------- filesubs.c | 4 ++-- job.c | 27 ++++++++++----------- job.h | 2 +- lavg_list.c | 14 +++++------ log.c | 8 +++---- mail.c | 22 +++++++++++------- mail.h | 5 ++-- save.c | 4 ++-- select.c | 4 ++-- subs.c | 1 - suspend.c | 8 +++---- u_list.c | 20 ++++++++-------- 26 files changed, 184 insertions(+), 170 deletions(-) diff --git a/cl.c b/cl.c index 1b6178c..1480382 100644 --- a/cl.c +++ b/cl.c @@ -26,7 +26,7 @@ #include "mem.h" cl_t * -dups_cl(cl_t * orig) +dups_cl(cl_t *orig) /* Duplicate a line, including the strings it points to. */ { cl_t *cl = NULL; @@ -63,7 +63,7 @@ dups_cl(cl_t * orig) } void -free_line(cl_t * cl) +free_line(cl_t *cl) /* free a line, including its fields */ { if (cl != NULL) { diff --git a/conf.c b/conf.c index 18f9569..87c00be 100644 --- a/conf.c +++ b/conf.c @@ -436,7 +436,7 @@ read_type(int fd, short int *type, short int *size) } int -read_file(const char *file_name, cf_t * cf, int is_system_startup) +read_file(const char *file_name, cf_t *cf, int is_system_startup) /* read a formated fcrontab. * return ERR on error, OK otherwise */ { @@ -559,7 +559,7 @@ read_file(const char *file_name, cf_t * cf, int is_system_startup) /* if we get here, sec_class and access_vec are both defined */ retval = security_compute_av(cf->cf_user_context, cf->cf_file_context, - sec_class, access_vec, &avd); + sec_class, access_vec, &avd); if (retval || ((access_vec & avd.allowed) != access_vec)) { syslog(LOG_ERR, "ENTRYPOINT FAILED for Linux user '%s' " @@ -827,7 +827,7 @@ read_file(const char *file_name, cf_t * cf, int is_system_startup) int -add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str, +add_line_to_file(cl_t *cl, cf_t *cf, uid_t runas, char *runas_str, time_t t_save, int is_system_startup) /* check if the line is valid, and if yes, add it to the file cf */ { @@ -1010,7 +1010,7 @@ delete_file(const char *user_name) void -save_file(cf_t * arg_file) +save_file(cf_t *arg_file) /* Store the informations relatives to the executions * of tasks at a defined frequency of system's running time */ { diff --git a/convert-fcrontab.c b/convert-fcrontab.c index 6b799f7..75f9ff4 100644 --- a/convert-fcrontab.c +++ b/convert-fcrontab.c @@ -83,7 +83,7 @@ usage() char * -read_str(FILE * f, char *buf, int max) +read_str(FILE *f, char *buf, int max) /* return a pointer to string read from file f * if it is non-zero length */ { @@ -103,7 +103,7 @@ read_str(FILE * f, char *buf, int max) void -delete_file(cf_t * file) +delete_file(cf_t *file) /* free a file if user_name is not null * otherwise free all files */ { diff --git a/database.c b/database.c index 5c48777..d73d092 100644 --- a/database.c +++ b/database.c @@ -174,7 +174,7 @@ mktime_no_dst(struct tm *t) void -run_normal_job(cl_t * line, int info_fd) +run_normal_job(cl_t *line, int info_fd) /* run a job, and write "log" on info_fd if positive */ { @@ -192,7 +192,7 @@ run_normal_job(cl_t * line, int info_fd) } void -run_lavg_job(lavg_t * l) +run_lavg_job(lavg_t *l) { run_queue_job(l->l_line); @@ -227,7 +227,7 @@ run_serial_job(void) void -run_queue_job(cl_t * line) +run_queue_job(cl_t *line) /* run a job */ { @@ -254,7 +254,7 @@ is_loop_in_queue(void) * Return 1 if there is a loop, 0 otherwise. * Only intended to be used when running in debug mode really. */ { - const int max_entries = 1000000 ; + const int max_entries = 1000000; int i = 0; struct job_t *j; @@ -272,7 +272,7 @@ is_loop_in_queue(void) } job_t * -job_queue_remove(cl_t * line) +job_queue_remove(cl_t *line) /* remove a job from the queue list * returns a pointer to the previous entry, * or NULL if the line either wasn't in the queue or was the first entry */ @@ -303,8 +303,8 @@ job_queue_remove(cl_t * line) Free_safe(j); if (debug_opt && is_loop_in_queue()) { - error("Loop found in job queue after removing line '%s': aborting.", - line->cl_shell); + error("Loop found in job queue after removing line '%s': " + "aborting.", line->cl_shell); abort(); } @@ -317,7 +317,7 @@ job_queue_remove(cl_t * line) } void -insert_nextexe(cl_t * line) +insert_nextexe(cl_t *line) /* insert a job at the right position in the job queue */ { struct job_t *newjob = NULL; @@ -325,8 +325,8 @@ insert_nextexe(cl_t * line) struct job_t *jprev = NULL; if (debug_opt && is_loop_in_queue()) { - error("Detected loop in queue_base before adding job '%s' to the queue: aborting.", - line->cl_shell); + error("Detected loop in queue_base before adding job '%s' " + "to the queue: aborting.", line->cl_shell); abort(); } @@ -370,15 +370,15 @@ insert_nextexe(cl_t * line) } if (debug_opt && is_loop_in_queue()) { - error("Detected loop in queue_base after adding job '%s' to the queue: aborting.", - line->cl_shell); + error("Detected loop in queue_base after adding job '%s' to the queue:" + " aborting.", line->cl_shell); abort(); } } void -add_serial_job(cl_t * line, int info_fd) +add_serial_job(cl_t *line, int info_fd) /* add the next queued job in serial queue */ { short int i; @@ -443,7 +443,7 @@ add_serial_job(cl_t * line, int info_fd) void -add_lavg_job(cl_t * line, int info_fd) +add_lavg_job(cl_t *line, int info_fd) /* add the next queued job in lavg queue */ /* WARNING : must be run before a set_next_exe() to get the strict option * working correctly */ @@ -521,24 +521,24 @@ add_lavg_job(cl_t * line, int info_fd) if (debug_opt) { if (lavg_entry->l_until == 0) { send_msg_fd_debug(info_fd, - " lavg entry added until:none cmd: '%s'", - line->cl_shell); + " lavg entry added until:none cmd: '%s'", + line->cl_shell); } else { struct tm ftime; struct tm *ft = localtime(&(lavg_entry->l_until)); /* localtime() returns a statically allocated struct which might be - overwritten by subsequent calls: take a copy. - (note: localtime() is used in the debug() function too) */ + * overwritten by subsequent calls: take a copy. + * (note: localtime() is used in the debug() function too) */ memcpy(&ftime, ft, sizeof(struct tm)); send_msg_fd_debug(info_fd, - " lavg entry added until:%04d-%02d-%02d " - "%02d:%02d:%02d (system time) cmd: '%s'", - (ftime.tm_year + 1900), (ftime.tm_mon + 1), - ftime.tm_mday, ftime.tm_hour, - ftime.tm_min, ftime.tm_sec, line->cl_shell); + " lavg entry added until:%04d-%02d-%02d " + "%02d:%02d:%02d (system time) cmd: '%s'", + (ftime.tm_year + 1900), (ftime.tm_mon + 1), + ftime.tm_mday, ftime.tm_hour, + ftime.tm_min, ftime.tm_sec, line->cl_shell); } } @@ -702,7 +702,7 @@ set_wday(struct tm *date) void -goto_beginning_next_period_periodical(cl_t * line, struct tm *ftime) +goto_beginning_next_period_periodical(cl_t *line, struct tm *ftime) /* From ftime, search the first/nearest time and date of the line's next * period of execution. * @@ -853,7 +853,7 @@ goto_beginning_next_period_periodical(cl_t * line, struct tm *ftime) void -move_time_to(int where, cl_t * line, struct tm *ftime) +move_time_to(int where, cl_t *line, struct tm *ftime) /* IF WHERE == BEGIN_NEXT_PERIOD: from ftime, search the first/nearest time and date * of the line's next period of execution. * IF WHERE == END_OF_INTERVAL: search the last time and date @@ -1039,7 +1039,7 @@ move_time_to(int where, cl_t * line, struct tm *ftime) void -set_next_exe(cl_t * line, char option, int info_fd) +set_next_exe(cl_t *line, char option, int info_fd) /* set the cl_nextexe of a given cl_t and insert it in the queue */ { @@ -1354,7 +1354,7 @@ set_next_exe(cl_t * line, char option, int info_fd) } void -set_next_exe_notrun(cl_t * line, char context) +set_next_exe_notrun(cl_t *line, char context) /* set the time of the next execution and send a mail to tell user his job * has not run if necessary */ { @@ -1631,7 +1631,7 @@ set_next_exe_startup(struct cl_t *cl, const int context, void -mail_notrun_time_t(cl_t * line, char context, time_t since_time_t) +mail_notrun_time_t(cl_t *line, char context, time_t since_time_t) /* Same as mail_notrun() but with 'since' defined as a time_t instead of a struct tm */ { struct tm *since2 = NULL; @@ -1651,7 +1651,7 @@ mail_notrun_time_t(cl_t * line, char context, time_t since_time_t) } void -mail_notrun(cl_t * line, char context, struct tm *since) +mail_notrun(cl_t *line, char context, struct tm *since) /* send a mail to tell user a job has not run (and why) */ { int pid = 0; diff --git a/env_list.c b/env_list.c index 2ad71db..5e488d8 100644 --- a/env_list.c +++ b/env_list.c @@ -39,7 +39,7 @@ env_list_init(void) } env_list_t * -env_list_copy(env_list_t * list) +env_list_copy(env_list_t *list) { env_list_t *new_list = NULL; env_t *e = NULL; @@ -57,7 +57,7 @@ env_list_copy(env_list_t * list) } env_t * -env_list_setenv(env_list_t * list, char *name, char *value, int overwrite) +env_list_setenv(env_list_t *list, char *name, char *value, int overwrite) { env_t e = { NULL }; env_t *c = NULL; @@ -89,7 +89,7 @@ env_list_setenv(env_list_t * list, char *name, char *value, int overwrite) } env_t * -env_list_putenv(env_list_t * list, char *envvar, int overwrite) +env_list_putenv(env_list_t *list, char *envvar, int overwrite) { env_t e = { NULL }; env_t *c = NULL; @@ -120,7 +120,7 @@ env_list_putenv(env_list_t * list, char *envvar, int overwrite) } char * -env_list_getenv(env_list_t * list, char *name) +env_list_getenv(env_list_t *list, char *name) { env_t *c = NULL; @@ -141,25 +141,25 @@ env_list_getenv(env_list_t * list, char *name) } env_t * -env_list_first(env_list_t * list) +env_list_first(env_list_t *list) { return (env_t *) u_list_first((u_list_t *) list); } env_t * -env_list_next(env_list_t * list) +env_list_next(env_list_t *list) { return (env_t *) u_list_next((u_list_t *) list); } void -env_list_end_iteration(env_list_t * list) +env_list_end_iteration(env_list_t *list) { u_list_end_iteration((u_list_t *) list); } env_list_t * -env_list_destroy(env_list_t * list) +env_list_destroy(env_list_t *list) /* free() the memory allocated for list and returns NULL */ { env_t *c = NULL; @@ -175,7 +175,7 @@ env_list_destroy(env_list_t * list) } char ** -env_list_export_envp(env_list_t * list) +env_list_export_envp(env_list_t *list) /* export list data as a char **envp structure to use as an argument of execle() */ { env_t *c = NULL; diff --git a/exe_list.c b/exe_list.c index 8cf03b3..4f6e4b5 100644 --- a/exe_list.c +++ b/exe_list.c @@ -39,7 +39,7 @@ exe_list_init(void) } exe_t * -exe_list_add_line(exe_list_t * list, struct cl_t *line) +exe_list_add_line(exe_list_t *list, struct cl_t *line) { exe_t e = { NULL, 0, 0 }; e.e_line = line; /* ANSI C does not allow us to directly replace NULL by line above */ @@ -48,37 +48,37 @@ exe_list_add_line(exe_list_t * list, struct cl_t *line) } exe_t * -exe_list_add(exe_list_t * list, exe_t * e) +exe_list_add(exe_list_t *list, exe_t *e) { return (exe_t *) u_list_add((u_list_t *) list, (u_list_entry_t *) e); } exe_t * -exe_list_first(exe_list_t * list) +exe_list_first(exe_list_t *list) { return (exe_t *) u_list_first((u_list_t *) list); } exe_t * -exe_list_next(exe_list_t * list) +exe_list_next(exe_list_t *list) { return (exe_t *) u_list_next((u_list_t *) list); } void -exe_list_end_iteration(exe_list_t * list) +exe_list_end_iteration(exe_list_t *list) { u_list_end_iteration((u_list_t *) list); } void -exe_list_remove_cur(exe_list_t * list) +exe_list_remove_cur(exe_list_t *list) { u_list_remove_cur((u_list_t *) list); } exe_list_t * -exe_list_destroy(exe_list_t * list) +exe_list_destroy(exe_list_t *list) /* free() the memory allocated for list and returns NULL */ { return (exe_list_t *) u_list_destroy((u_list_t *) list); diff --git a/exe_list_test.c b/exe_list_test.c index cb094ee..08ed930 100644 --- a/exe_list_test.c +++ b/exe_list_test.c @@ -10,14 +10,14 @@ pid_t daemon_pid = 0; uid_t rootuid = 0; void -print_cur(exe_t * e) +print_cur(exe_t *e) { printf("Current entry's shell command: %s\n", e ? e->e_line->cl_shell : "NULL"); } void -print_list(exe_list_t * list) +print_list(exe_list_t *list) { exe_t *e = NULL; printf("Current list:\n"); diff --git a/fcron.c b/fcron.c index 9d292a6..ba35b01 100644 --- a/fcron.c +++ b/fcron.c @@ -547,11 +547,12 @@ void set_signal_handler(int signal, void (*handler)(int), bool first_install) /* (re)install a signal handler, with restartable syscalls retried. */ { +/* *INDENT-OFF* */ #ifdef HAVE_SIGACTION /* The signal handler stays set after the handler is called when set - with sigaction(): we only need to install it once. */ + * with sigaction(): we only need to install it once. */ if (first_install) { - struct sigaction act = {0}; + struct sigaction act = { 0 }; act.sa_flags = SA_RESTART; act.sa_handler = handler; if (sigaction(signal, &act, NULL) < 0) { @@ -560,8 +561,8 @@ set_signal_handler(int signal, void (*handler)(int), bool first_install) } #elif defined(HAVE_SIGNAL) /* Some systems reset the handler to SIG_DFL when the handler - is called when the handler was set with signal(). So we have to install - it (again) every time. */ + * is called when the handler was set with signal(). So we have to install + * it (again) every time. */ if (signal(signal, handler) == SIG_ERR) { die_e("signal() failed on signal %d", signal); } @@ -570,7 +571,7 @@ set_signal_handler(int signal, void (*handler)(int), bool first_install) } #elif defined(HAVE_SIGSET) /* The signal handler stays set after the handler is called when set - with sigset(): we only need to install it once. */ + * with sigset(): we only need to install it once. */ if (first_install) { if (sigset(signal, handler) == -1) { die_e("sigset() failed on signal %d", signal); @@ -579,10 +580,12 @@ set_signal_handler(int signal, void (*handler)(int), bool first_install) #else #error "No signal installation function found" #endif +/* *INDENT-ON* */ } void -install_signal_handler(int signal, void (*handler)(int)) { +install_signal_handler(int signal, void (*handler)(int)) +{ set_signal_handler(signal, handler, true); } diff --git a/fcrondyn.c b/fcrondyn.c index d76224c..57bad29 100644 --- a/fcrondyn.c +++ b/fcrondyn.c @@ -608,16 +608,16 @@ talk_fcron(char *cmd_str, int fd) while (printed_len < read_len) { int str_len = strlen(buf + printed_len); printf("%s", buf + printed_len); - if (str_len > 0 && buf[printed_len+str_len-1] != '\n') { + if (str_len > 0 && buf[printed_len + str_len - 1] != '\n') { printf("\n"); } - printed_len += str_len + 1; /* +1 to account for the end-of-string '\0' marker */ + printed_len += str_len + 1; /* +1 to account for the end-of-string '\0' marker */ } /* check for the end of command output marker */ if (read_len >= sizeof(END_STR) && memcmp(&buf[read_len - sizeof(END_STR)], END_STR, - sizeof(END_STR)) == 0) { + sizeof(END_STR)) == 0) { break; } } diff --git a/fcrondyn_svr.c b/fcrondyn_svr.c index 36dfbe0..bfbfa21 100644 --- a/fcrondyn_svr.c +++ b/fcrondyn_svr.c @@ -105,7 +105,7 @@ char err_others_nallowed_str[] = void -fcrondyn_socket_init(select_instance * si) +fcrondyn_socket_init(select_instance *si) /* do everything needed to get a working listening socket */ { struct sockaddr_un addr; @@ -401,11 +401,12 @@ print_fields(int fd, unsigned char *details) Add_field(field_endline); /* Extra safety (which should be redundant as strncat (used in Add_field - and Test_add_field) always null-terminate the string: */ + * and Test_add_field) always null-terminate the string: */ fields[sizeof(fields) - 1] = '\0'; /* add +1 to include the final end-of-string "\0" */ - if (send(fd, fields, (len+1 < sizeof(fields)) ? len+1 : sizeof(fields), 0) < 0) + if (send(fd, fields, (len + 1 < sizeof(fields)) ? len + 1 : sizeof(fields), + 0) < 0) error_e("error in send()"); } @@ -470,25 +471,26 @@ print_line(int fd, struct cl_t *line, unsigned char *details, pid_t pid, if (bit_test(details, FIELD_SCHEDULE)) { ftime = localtime(&(line->cl_nextexe)); len += - snprintf(buf + len, sizeof(buf) - len, "|%04d-%02d-%02d %02d:%02d:%02d", - (ftime->tm_year + 1900), (ftime->tm_mon + 1), - ftime->tm_mday, ftime->tm_hour, ftime->tm_min, ftime->tm_sec); + snprintf(buf + len, sizeof(buf) - len, + "|%04d-%02d-%02d %02d:%02d:%02d", (ftime->tm_year + 1900), + (ftime->tm_mon + 1), ftime->tm_mday, ftime->tm_hour, + ftime->tm_min, ftime->tm_sec); } len += snprintf(buf + len, sizeof(buf) - len, "|%s\n", line->cl_shell); /* snprintf() returns the length of what would have been written (excluding terminating null byte) - if not limited by maxlen */ - if (len+1 > sizeof(buf)) { + * if not limited by maxlen */ + if (len + 1 > sizeof(buf)) { /* the shell command string was too long and was truncated */ strcpy(buf + sizeof(buf) - sizeof(truncated), truncated); } /* as extra safety to make sure the string is always null-terminated - (even though snprintf man page suggests it does it already) */ + * (even though snprintf man page suggests it does it already) */ buf[sizeof(buf) - 1] = '\0'; /* add +1 to include the final end-of-string "\0" */ - if (send(fd, buf, (len+1 < sizeof(buf)) ? len+1 : sizeof(buf), 0) < 0) { + if (send(fd, buf, (len + 1 < sizeof(buf)) ? len + 1 : sizeof(buf), 0) < 0) { error_e("error in send()"); } } @@ -547,7 +549,8 @@ cmd_ls(struct fcrondyn_cl *client, long int *cmd, int fd, int is_root) getloadavg(lavg, 3); i = snprintf(lavg_str, sizeof(lavg_str), "Current load average : " "%.1f, %.1f, %.1f\n", lavg[0], lavg[1], lavg[2]); - send(fd, lavg_str, (i+1 < sizeof(lavg_str))? i+1 : sizeof(lavg_str), 0); + send(fd, lavg_str, + (i + 1 < sizeof(lavg_str)) ? i + 1 : sizeof(lavg_str), 0); bit_set(fields, FIELD_LAVG); } @@ -719,7 +722,7 @@ cmd_on_exeq(struct fcrondyn_cl *client, long int *cmd, int fd, int is_root) void -cmd_renice(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t * e, +cmd_renice(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t *e, int is_root) /* change nice value of a running job */ { @@ -756,7 +759,7 @@ cmd_renice(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t * e, void -cmd_send_signal(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t * e) +cmd_send_signal(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t *e) /* send a signal to a running job */ { if (e->e_job_pid <= 0 || (int)cmd[1] <= 0) { @@ -860,7 +863,7 @@ exe_cmd(struct fcrondyn_cl *client) void remove_connection(struct fcrondyn_cl **client, struct fcrondyn_cl *prev_client, - select_instance * si) + select_instance *si) /* close the connection, remove it from the list and make client points to the next entry */ { @@ -884,7 +887,7 @@ and make client points to the next entry */ } void -fcrondyn_socket_check(select_instance * si) +fcrondyn_socket_check(select_instance *si) /* check for new connection, command, connection closed */ { int fd = -1, avoid_fd = -1; @@ -1002,7 +1005,7 @@ fcrondyn_socket_check(select_instance * si) void -fcrondyn_socket_close(select_instance * si) +fcrondyn_socket_close(select_instance *si) /* close connections, close socket, remove socket file. * If si is not NULL, then remove the fds from si's readfds */ { diff --git a/fcronsighup.c b/fcronsighup.c index 7621cec..0fcab46 100644 --- a/fcronsighup.c +++ b/fcronsighup.c @@ -91,8 +91,8 @@ sig_daemon(void) max_delay_s = MAX_FCRONTAB_RELOAD_DELAY_SECONDS; #endif if (uid == rootuid) { - /* we don't need to make root wait */ - max_delay_s = 0; + /* we don't need to make root wait */ + max_delay_s = 0; } if (max_delay_s > 0) { @@ -108,22 +108,24 @@ sig_daemon(void) now_epoch = time(NULL); if (now_epoch % 60 < 50) { - /* clocktime is < ##:##:50, so target 10s before the end of the current minute */ - delay_s = 50 - (now_epoch % 60); - } else { - /* clocktime is >= ##:##:50, so target 10s before the end of the next minute */ - delay_s = 50 + (60 - (now_epoch % 60)); + /* clocktime is < ##:##:50, so target 10s before the end of the current minute */ + delay_s = 50 - (now_epoch % 60); + } + else { + /* clocktime is >= ##:##:50, so target 10s before the end of the next minute */ + delay_s = 50 + (60 - (now_epoch % 60)); } if (delay_s > max_delay_s) { - delay_s = max_delay_s; + delay_s = max_delay_s; } target_time_epoch = now_epoch + delay_s; target_time_tm = localtime(&target_time_epoch); - fprintf(stderr, "Modifications will be taken into account at %02d:%02d:%02d.\n", - target_time_tm->tm_hour, target_time_tm->tm_min, target_time_tm->tm_sec); + fprintf(stderr, "Modifications will be taken into account at " + "%02d:%02d:%02d.\n", target_time_tm->tm_hour, + target_time_tm->tm_min, target_time_tm->tm_sec); /* if fcrontabs is too long, snprintf will not be able to add "/fcrontab.sig" * string at the end of sigfile */ diff --git a/fcrontab.c b/fcrontab.c index 6a45476..f074477 100644 --- a/fcrontab.c +++ b/fcrontab.c @@ -887,7 +887,7 @@ parseopt(int argc, char *argv[]) Set(fcronconf, optarg); } else { - char buf[sizeof(orig_dir)+1+strlen(optarg)+1]; + char buf[sizeof(orig_dir) + 1 + strlen(optarg) + 1]; snprintf(buf, sizeof(buf), "%s/%s", orig_dir, optarg); Set(fcronconf, buf); } @@ -1105,7 +1105,6 @@ main(int argc, char **argv) if (file_opt) { if (strcmp(argv[file_opt], "-") == 0) - xexit(install_stdin()); else { @@ -1113,9 +1112,11 @@ main(int argc, char **argv) if (*argv[file_opt] != '/') { /* this is just the file name, not the path : complete it */ - size_t path_len = strlen(orig_dir) + 1 + strlen(argv[file_opt]) + 1; + size_t path_len = + strlen(orig_dir) + 1 + strlen(argv[file_opt]) + 1; alloc_safe(path_len, fcrontab_file_path); - snprintf(fcrontab_file_path, path_len, "%s/%s", orig_dir, argv[file_opt]); + snprintf(fcrontab_file_path, path_len, "%s/%s", orig_dir, + argv[file_opt]); } else { fcrontab_file_path = strdup(argv[file_opt]); diff --git a/fifo_list.c b/fifo_list.c index 589616b..f6f818f 100644 --- a/fifo_list.c +++ b/fifo_list.c @@ -65,7 +65,7 @@ fifo_list_init(size_t entry_size, int init_size, int grow_size) } fifo_list_entry_t * -fifo_list_last(fifo_list_t * l) +fifo_list_last(fifo_list_t *l) /* Returns the pointer of the last entry in the list, or NULL if l is empty */ { fifo_list_entry *e = NULL; @@ -81,7 +81,7 @@ fifo_list_last(fifo_list_t * l) } int -fifo_list_resize_array(fifo_list_t * l) +fifo_list_resize_array(fifo_list_t *l) /* Resize l's entries_array up to l->max_entries * Returns OK on success, ERR if the array is already at maximum size */ { @@ -125,7 +125,7 @@ fifo_list_resize_array(fifo_list_t * l) fifo_list_entry_t * -fifo_list_add(fifo_list_t * l, fifo_list_entry_t * e) +fifo_list_add(fifo_list_t *l, fifo_list_entry_t *e) /* Add one entry to the list * Returns a pointer to the added element, or NULL if list is already at max size */ { @@ -150,7 +150,7 @@ fifo_list_add(fifo_list_t * l, fifo_list_entry_t * e) } fifo_list_entry_t * -fifo_list_first(fifo_list_t * l) +fifo_list_first(fifo_list_t *l) /* Return the first entry of the list (then fifo_list_next() can be used) */ { /* sanity check */ @@ -167,7 +167,7 @@ fifo_list_first(fifo_list_t * l) } fifo_list_entry_t * -fifo_list_next(fifo_list_t * l) +fifo_list_next(fifo_list_t *l) /* Return the entry after e */ { /* // WHAT IF I CALL _ADD() (+RESIZE?) OR _REMOVE() BETWEEN TWO _NEXT CALLS? */ @@ -203,7 +203,7 @@ fifo_list_next(fifo_list_t * l) } void -fifo_list_end_iteration(fifo_list_t * list) +fifo_list_end_iteration(fifo_list_t *list) /* Stop an iteration before _next() reached the end of the list by itself */ { list->cur_entry = NULL; @@ -212,7 +212,7 @@ fifo_list_end_iteration(fifo_list_t * list) void -fifo_list_remove_first(fifo_list_t * l) +fifo_list_remove_first(fifo_list_t *l) { /* // MANAGE L->NEXT_ENTRY (+ SPECIAL CASE FIRST/LAST ENTRY) */ fifo_list_entry_t *last = NULL; @@ -236,7 +236,7 @@ fifo_list_remove_first(fifo_list_t * l) } fifo_list_t * -fifo_list_destroy(fifo_list_t * list) +fifo_list_destroy(fifo_list_t *list) /* free() the memory allocated for list and returns NULL */ { if (list == NULL) diff --git a/fileconf.c b/fileconf.c index b6e6eaf..0bb588f 100644 --- a/fileconf.c +++ b/fileconf.c @@ -99,7 +99,7 @@ get_string(char *ptr) int -get_line(char *str, size_t size, FILE * file) +get_line(char *str, size_t size, FILE *file) /* similar to fgets, but increase line if necessary, * and continue over an "\" followed by an "\n" char */ { @@ -149,7 +149,7 @@ get_line(char *str, size_t size, FILE * file) } void -init_default_line(cl_t * cl, cf_t * cf) +init_default_line(cl_t *cl, cf_t *cf) /* clear all context/options from cl */ { bzero(cl, sizeof(cl_t)); @@ -295,7 +295,7 @@ read_file(char *filename, int fd) } void -read_env(char *ptr, cf_t * cf) +read_env(char *ptr, cf_t *cf) /* append env variable list. * (remove blanks) */ { @@ -500,7 +500,7 @@ get_bool(char *ptr, int *i) char * -read_opt(char *ptr, cl_t * cl) +read_opt(char *ptr, cl_t *cl) /* read one or several options and fill in the field "option" */ { char opt_name[20]; @@ -1207,7 +1207,7 @@ read_opt(char *ptr, cl_t * cl) char * -get_time(char *ptr, time_t * time, int zero_allowed) +get_time(char *ptr, time_t *time, int zero_allowed) /* convert time read in string in time_t format */ { time_t sum; @@ -1262,7 +1262,7 @@ get_time(char *ptr, time_t * time, int zero_allowed) char * -check_username(char *ptr, cf_t * cf, cl_t * cl) +check_username(char *ptr, cf_t *cf, cl_t *cl) /* check ptr to see if the first word is a username, returns new ptr */ { short int indx = 0; @@ -1315,7 +1315,7 @@ read_word(char *ptr, char *buf, size_t buf_size) } int -read_shortcut(char *ptr, cf_t * cf) +read_shortcut(char *ptr, cf_t *cf) /* try to read a shortcut entry, and if it is one then append a line to cf * Return 1 if that was a shortcut entry. If it wasn't, return 0 and make sure * ptr is back to its orig value. */ @@ -1470,7 +1470,7 @@ read_shortcut(char *ptr, cf_t * cf) } void -read_freq(char *ptr, cf_t * cf) +read_freq(char *ptr, cf_t *cf) /* read a freq entry, and append a line to cf */ { cl_t *cl = NULL; @@ -1573,7 +1573,7 @@ read_freq(char *ptr, cf_t * cf) void -read_arys(char *ptr, cf_t * cf) +read_arys(char *ptr, cf_t *cf) /* read a run freq number plus a normal fcron line */ { cl_t *cl = NULL; @@ -1663,7 +1663,7 @@ read_arys(char *ptr, cf_t * cf) } void -read_period(char *ptr, cf_t * cf) +read_period(char *ptr, cf_t *cf) /* read a line to run periodically (i.e. once a day, once a week, etc) */ { cl_t *cl = NULL; @@ -1887,7 +1887,7 @@ get_num(char *ptr, int *num, int max, short int decimal, const char **names) char * -read_field(char *ptr, bitstr_t * ary, int max, const char **names) +read_field(char *ptr, bitstr_t *ary, int max, const char **names) /* read a field like "2,5-8,10-20/2,21-30~25" and fill ary */ { int start = 0; diff --git a/filesubs.c b/filesubs.c index bc601f1..ae225ab 100644 --- a/filesubs.c +++ b/filesubs.c @@ -62,7 +62,7 @@ xclose_check(int *fd, const char *filedesc) /* fclose() a file, and set the FILE* to NULL. * Returns fclose()'s return value and leaves errno as is. */ int -xfclose(FILE ** f) +xfclose(FILE **f) { int retval = EOF; @@ -82,7 +82,7 @@ xfclose(FILE ** f) * Returns fclose()'s return value. * WARNING: do NOT call from log.c to avoid potential infinite loops! */ int -xfclose_check(FILE ** f, const char *filedesc) +xfclose_check(FILE **f, const char *filedesc) { int retval = EOF; diff --git a/job.c b/job.c index d60a7db..b38e09f 100644 --- a/job.c +++ b/job.c @@ -46,8 +46,8 @@ void become_user(struct cl_t *cl, struct passwd *pas, char *home); #ifdef HAVE_LIBPAM void -die_mail_pame(cl_t * cl, int pamerrno, struct passwd *pas, char *str, - env_list_t * env) +die_mail_pame(cl_t *cl, int pamerrno, struct passwd *pas, char *str, + env_list_t *env) /* log an error in syslog, mail user if necessary, and die */ { char buf[MAX_MSG]; @@ -279,7 +279,7 @@ sig_dfl(void) } FILE * -create_mail(cl_t * line, char *subject, char *content_type, char *encoding, +create_mail(cl_t *line, char *subject, char *content_type, char *encoding, char **env) /* create a temp file and write in it a mail header */ { @@ -321,20 +321,22 @@ create_mail(cl_t * line, char *subject, char *content_type, char *encoding, #endif /* HAVE_GETHOSTNAME */ /* write mail header. Global 'maildisplayname' comes from fcronconf.h */ - if (maildisplayname[0] != '\0'){ + if (maildisplayname[0] != '\0') { /* New behavior -- RFC-compliant */ - mailbox_addr = make_mailbox_addr(maildisplayname, mailfrom, hostname_from); - if (! mailbox_addr) { + mailbox_addr = + make_mailbox_addr(maildisplayname, mailfrom, hostname_from); + if (!mailbox_addr) { warn("could not make the mailbox address"); } } if (mailbox_addr) { - fprintf(mailf, FROM_HEADER_KEY"%s\n", mailbox_addr); + fprintf(mailf, FROM_HEADER_KEY "%s\n", mailbox_addr); Free_safe(mailbox_addr); } else { /* Old behavior */ - fprintf(mailf, FROM_HEADER_KEY"%s%s (fcron)\n", mailfrom, hostname_from); + fprintf(mailf, FROM_HEADER_KEY "%s%s (fcron)\n", mailfrom, + hostname_from); } fprintf(mailf, "To: %s%s\n", line->cl_mailto, hostname_to); @@ -483,7 +485,7 @@ write_pipe(int fd, void *buf, size_t size) } void -run_job_grand_child_setup_stderr_stdout(cl_t * line, int *pipe_fd) +run_job_grand_child_setup_stderr_stdout(cl_t *line, int *pipe_fd) /* setup stderr and stdout correctly so as the mail containing * the output of the job can be send at the end of the job. * Close the pipe (both ways). */ @@ -518,7 +520,7 @@ run_job_grand_child_setup_stderr_stdout(cl_t * line, int *pipe_fd) } void -run_job_grand_child_setup_nice(cl_t * line) +run_job_grand_child_setup_nice(cl_t *line) /* set the nice value for the job */ { if (line->cl_nice != 0) { @@ -783,8 +785,7 @@ run_job(struct exe_t *exeent) } void -end_job(cl_t * line, int status, FILE * mailf, short mailpos, - char **sendmailenv) +end_job(cl_t *line, int status, FILE *mailf, short mailpos, char **sendmailenv) /* if task have made some output, mail it to user */ { @@ -870,7 +871,7 @@ end_job(cl_t * line, int status, FILE * mailf, short mailpos, } void -launch_mailer(cl_t * line, FILE * mailf, char **sendmailenv) +launch_mailer(cl_t *line, FILE *mailf, char **sendmailenv) /* mail the output of a job to user */ { #ifdef USE_SENDMAIL diff --git a/job.h b/job.h index 612e87d..9702663 100644 --- a/job.h +++ b/job.h @@ -25,7 +25,7 @@ #ifndef __JOB_H__ #define __JOB_H__ -#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */ +#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */ #define FROM_HEADER_KEY "From: " /* functions prototypes */ diff --git a/lavg_list.c b/lavg_list.c index 02fe0aa..2105d42 100644 --- a/lavg_list.c +++ b/lavg_list.c @@ -42,7 +42,7 @@ lavg_list_init(void) } lavg_t * -lavg_list_add_line(lavg_list_t * list, struct cl_t * line) +lavg_list_add_line(lavg_list_t *list, struct cl_t *line) { lavg_t e = { NULL, 0 }; e.l_line = line; /* ANSI C does not allow us to directly replace NULL by line above */ @@ -51,37 +51,37 @@ lavg_list_add_line(lavg_list_t * list, struct cl_t * line) } lavg_t * -lavg_list_add(lavg_list_t * list, lavg_t * entry) +lavg_list_add(lavg_list_t *list, lavg_t *entry) { return (lavg_t *) u_list_add((u_list_t *) list, (u_list_entry_t *) entry); } lavg_t * -lavg_list_first(lavg_list_t * list) +lavg_list_first(lavg_list_t *list) { return (lavg_t *) u_list_first((u_list_t *) list); } lavg_t * -lavg_list_next(lavg_list_t * list) +lavg_list_next(lavg_list_t *list) { return (lavg_t *) u_list_next((u_list_t *) list); } void -lavg_list_end_iteration(lavg_list_t * list) +lavg_list_end_iteration(lavg_list_t *list) { u_list_end_iteration((u_list_t *) list); } void -lavg_list_remove_cur(lavg_list_t * list) +lavg_list_remove_cur(lavg_list_t *list) { u_list_remove_cur((u_list_t *) list); } lavg_list_t * -lavg_list_destroy(lavg_list_t * list) +lavg_list_destroy(lavg_list_t *list) { return (lavg_list_t *) u_list_destroy((u_list_t *) list); } diff --git a/log.c b/log.c index 4796aa7..f5d6346 100644 --- a/log.c +++ b/log.c @@ -246,7 +246,7 @@ xlog_e(int priority, int fd, char *fmt, va_list args) /* write a message to the file specified by logfile. */ static void -print_line_prefix(FILE * logfile, int priority) +print_line_prefix(FILE *logfile, int priority) { time_t t = time(NULL); struct tm *ft; @@ -285,7 +285,7 @@ print_line_prefix(FILE * logfile, int priority) /* Same as log_syslog(), but also appends an error description corresponding * to the pam_error. */ static void -log_pame(int priority, pam_handle_t * pamh, int pamerrno, char *fmt, +log_pame(int priority, pam_handle_t *pamh, int pamerrno, char *fmt, va_list args) { char *msg; @@ -411,7 +411,7 @@ error_e(char *fmt, ...) #ifdef HAVE_LIBPAM /* Log a "complain" level message, with a PAM error description */ void -error_pame(pam_handle_t * pamh, int pamerrno, char *fmt, ...) +error_pame(pam_handle_t *pamh, int pamerrno, char *fmt, ...) { va_list args; @@ -473,7 +473,7 @@ die_e(char *fmt, ...) #ifdef HAVE_LIBPAM /* Log a "complain" level message, with a PAM error description, and exit */ void -die_pame(pam_handle_t * pamh, int pamerrno, char *fmt, ...) +die_pame(pam_handle_t *pamh, int pamerrno, char *fmt, ...) { va_list args; diff --git a/mail.c b/mail.c index 3428a05..bd06d86 100644 --- a/mail.c +++ b/mail.c @@ -25,8 +25,8 @@ #include "fcron.h" #include "mail.h" -char -*format_maildisplayname(char *displayname_conf) +char * +format_maildisplayname(char *displayname_conf) /* Format the input string `conf_value` according to RFC5322 sec. 3.2.3. * . * Returns: either the formatted displayname (possibly unchanged or empty) @@ -35,13 +35,15 @@ char { bool need_quotes = false; char c = '\0'; - char *ipos = NULL; /* Input position */ + char *ipos = NULL; /* Input position */ char *output = NULL, *quoted_output = NULL; const uint buf_len = MAIL_FROM_VALUE_LEN_MAX; - uint cwritten = 0; /* how many chars we have written */ + uint cwritten = 0; /* how many chars we have written */ - if (strlen(displayname_conf) == 0) return strdup2(""); + if (strlen(displayname_conf) == 0) { + return strdup2(""); + } output = (char *)alloc_safe(buf_len * sizeof(char), "output buffer"); @@ -66,10 +68,12 @@ char } if (need_quotes) { - quoted_output = (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer"); + quoted_output = + (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer"); int needed_len = snprintf(quoted_output, buf_len, "\"%s\"", output); - if (needed_len >= buf_len){ - error("Formatted 'displayname' too long: length:%u > max:%u chars", needed_len, buf_len); + if (needed_len >= buf_len) { + error("Formatted 'displayname' too long: length:%u > max:%u chars", + needed_len, buf_len); Free_safe(output); Free_safe(quoted_output); return NULL; @@ -94,7 +98,7 @@ make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname) uint written = 0; bool need_anglebrackets = false; - const uint buf_len = MAIL_FROM_VALUE_LEN_MAX+1; + const uint buf_len = MAIL_FROM_VALUE_LEN_MAX + 1; buf = (char *)alloc_safe(buf_len * sizeof(char), "mailbox addr buffer"); diff --git a/mail.h b/mail.h index 4dd5cfa..d1e9bb7 100644 --- a/mail.h +++ b/mail.h @@ -25,11 +25,12 @@ #ifndef __MAIL_H__ #define __MAIL_H__ -#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */ +#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */ #define FROM_HEADER_KEY "From: " #define MAIL_FROM_VALUE_LEN_MAX (MAIL_LINE_LEN_MAX - sizeof(FROM_HEADER_KEY)) extern char *format_maildisplayname(char *displayname_conf); -extern char *make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname); +extern char *make_mailbox_addr(char *displayname_conf, char *mail_from, + char *hostname); #endif /* __MAIL_H__ */ diff --git a/save.c b/save.c index e5ddb5b..3751159 100644 --- a/save.c +++ b/save.c @@ -325,7 +325,7 @@ write_file_to_disk(int fd, struct cf_t *file, time_t time_date) int -save_one_file(cf_t * file, char *filename, uid_t own_uid, gid_t own_gid, +save_one_file(cf_t *file, char *filename, uid_t own_uid, gid_t own_gid, time_t save_date) /* save a given file to disk */ { @@ -374,7 +374,7 @@ save_one_file(cf_t * file, char *filename, uid_t own_uid, gid_t own_gid, int -save_file_safe(cf_t * file, char *final_path, char *prog_name, uid_t own_uid, +save_file_safe(cf_t *file, char *final_path, char *prog_name, uid_t own_uid, gid_t own_gid, time_t save_date) /* save a file to a temp path, and then rename it (safely) to avoid loss of data * if a system crash, hardware failure, etc happens. */ diff --git a/select.c b/select.c index a81b10c..0bf4a6a 100644 --- a/select.c +++ b/select.c @@ -39,7 +39,7 @@ select_init(struct select_instance *si) } void -select_add_read(select_instance * si, int fd) +select_add_read(select_instance *si, int fd) /* Add a fd to the read set */ { FD_SET(fd, &si->__readfds_master); @@ -51,7 +51,7 @@ select_add_read(select_instance * si, int fd) } void -select_rm_read(select_instance * si, int fd) +select_rm_read(select_instance *si, int fd) /* remove a fd to the read set */ { FD_CLR(fd, &si->__readfds_master); diff --git a/subs.c b/subs.c index 905ceed..8d88d3e 100644 --- a/subs.c +++ b/subs.c @@ -414,7 +414,6 @@ my_setenv_overwrite(const char *name, const char *value) char buf[PATH_LEN]; snprintf(buf, sizeof(buf) - 1, "%s=%s", name, value) - /* The final \0 may not have been copied because of lack of space: * add it to make sure */ buf[sizeof(buf) - 1] = '\0'; diff --git a/suspend.c b/suspend.c index ac0f24d..dbe74b7 100644 --- a/suspend.c +++ b/suspend.c @@ -211,7 +211,7 @@ read_suspend_duration(time_t slept_from) } void -init_suspend(select_instance * si) +init_suspend(select_instance *si) { #if defined(CLOCK_BOOTTIME) && defined(CLOCK_MONOTONIC) @@ -245,7 +245,7 @@ init_suspend(select_instance * si) void check_suspend(time_t slept_from, time_t nwt, bool *sig_cont, - select_instance * si) + select_instance *si) /* Check if the machine was suspended (to mem or disk), and if so * reschedule jobs accordingly */ { @@ -305,8 +305,8 @@ check_suspend(time_t slept_from, time_t nwt, bool *sig_cont, long int scheduled_sleep = nwt - slept_from; explain("suspend/hibernate detected: The system was suspended for " - "%lus (and we woke up after %lus instead of our intended %lus sleep).", - suspend_duration, actual_sleep, scheduled_sleep); + "%lus (and we woke up after %lus instead of our intended %lus sleep).", + suspend_duration, actual_sleep, scheduled_sleep); reschedule_all_on_resume(suspend_duration); } } diff --git a/u_list.c b/u_list.c index addbbfe..6828c96 100644 --- a/u_list.c +++ b/u_list.c @@ -65,7 +65,7 @@ u_list_init(size_t entry_size, int init_size, int grow_size) } u_list_t * -u_list_copy(u_list_t * list) +u_list_copy(u_list_t *list) { u_list_t *new_list = NULL; @@ -87,7 +87,7 @@ u_list_copy(u_list_t * list) int -u_list_resize_array(u_list_t * l) +u_list_resize_array(u_list_t *l) /* Resize l's entries_array up to l->max_entries * Returns OK on success, ERR if the array is already at maximum size */ { @@ -130,7 +130,7 @@ u_list_resize_array(u_list_t * l) } u_list_entry_t * -u_list_last(u_list_t * l) +u_list_last(u_list_t *l) /* Returns the pointer of the last entry in the list, or NULL if l is empty */ { if (l->num_entries <= 0) @@ -141,7 +141,7 @@ u_list_last(u_list_t * l) } u_list_entry_t * -u_list_add(u_list_t * l, u_list_entry_t * e) +u_list_add(u_list_t *l, u_list_entry_t *e) /* Add one entry to the list * Returns a pointer to the added element, or NULL if list is already at max size */ { @@ -166,7 +166,7 @@ u_list_add(u_list_t * l, u_list_entry_t * e) } int -u_list_is_iterating(u_list_t * l) +u_list_is_iterating(u_list_t *l) { /* sanity check */ if (l == NULL) @@ -176,7 +176,7 @@ u_list_is_iterating(u_list_t * l) } u_list_entry_t * -u_list_first(u_list_t * l) +u_list_first(u_list_t *l) /* Return the first entry of the list (then u_list_next() can be used) */ { /* sanity check */ @@ -193,7 +193,7 @@ u_list_first(u_list_t * l) } u_list_entry_t * -u_list_next(u_list_t * l) +u_list_next(u_list_t *l) /* Return the entry after e */ { /* sanity checks */ @@ -227,7 +227,7 @@ u_list_next(u_list_t * l) } void -u_list_end_iteration(u_list_t * list) +u_list_end_iteration(u_list_t *list) /* Stop an iteration before _next() reached the end of the list by itself */ { list->cur_entry = NULL; @@ -236,7 +236,7 @@ u_list_end_iteration(u_list_t * list) void -u_list_remove_cur(u_list_t * l) +u_list_remove_cur(u_list_t *l) { u_list_entry_t *last = NULL; @@ -259,7 +259,7 @@ u_list_remove_cur(u_list_t * l) } u_list_t * -u_list_destroy(u_list_t * list) +u_list_destroy(u_list_t *list) /* free() the memory allocated for list and returns NULL */ { if (list == NULL) -- 2.47.3