From 54b308af97b91ceabb0a482f325d3a8595b01aa3 Mon Sep 17 00:00:00 2001 From: turret Date: Mon, 18 Dec 2023 16:13:36 -0600 Subject: *: enforce 78 char line limit --- init/init.c | 13 +++++++++---- init/log.c | 20 +++++++++++++------- init/subsys.c | 10 +++++++--- 3 files changed, 29 insertions(+), 14 deletions(-) (limited to 'init') diff --git a/init/init.c b/init/init.c index c2ae3c4..e2ece8a 100644 --- a/init/init.c +++ b/init/init.c @@ -45,7 +45,9 @@ static void do_initcall_level(int level) { initcall_entry_t *fn; - for (fn = initcall_levels[level - 1]; fn < initcall_levels[level]; fn++) + for (fn = initcall_levels[level - 1]; + fn < initcall_levels[level]; + fn++) initcall_from_entry(fn)(); } @@ -61,7 +63,8 @@ int main(void) { print("init: Hello world! Running " NAME " v" VERSION "!"); - /* set mainpid for the subsystem service so it is fully accessible during l1 */ + /* set mainpid for the subsystem service so it is fully accessible + during l1 */ mainpid = getpid(); /* set stack_size for subsystem service */ @@ -77,7 +80,8 @@ int main(void) if(!token_base) panic("init: cannot find TOKEN in env"); - token = calloc(strlen(token_base) + strlen("Authorization: Bot ") + 1, sizeof(char)); + token = calloc(strlen(token_base) + strlen("Authorization: Bot ") + 1, + sizeof(char)); strcpy(token, "Authorization: Bot "); strcat(token, token_base); @@ -97,7 +101,8 @@ int main(void) int process = 0; while((process = waitpid(-1, NULL, WNOHANG)) > 0) if(subsystem_handle_term(process) > 0) - print(LOG_WARNING "init: failed to reap process %d", process); + print(LOG_WARNING "init: failed to reap process %d", + process); } } diff --git a/init/log.c b/init/log.c index aba141d..75840a2 100644 --- a/init/log.c +++ b/init/log.c @@ -8,7 +8,6 @@ #include #include #include - #include #include @@ -72,7 +71,8 @@ static int vaprint(const char *fmt, va_list ap) char tsbuf[64] = "\0"; struct timeval time; gettimeofday(&time, NULL); - snprintf(tsbuf, sizeof(tsbuf), "[%5ld.%06ld] ", (long)time.tv_sec % 100000, (long)time.tv_usec); + snprintf(tsbuf, sizeof(tsbuf), "[%5ld.%06ld] ", + (long)time.tv_sec % 100000, (long)time.tv_usec); /* spin lock, at the cost of architecture portability concurrency is something that we need to adjust for, and the @@ -112,7 +112,9 @@ static int vaprint(const char *fmt, va_list ap) return 0; } -void _panic(const char *fileorigin, const int lineorigin, const char *fmt, ...) +void _panic(const char *fileorigin, + const int lineorigin, + const char *fmt, ...) { char mode = PANICMODE_DIE; int pid = getpid(); @@ -132,7 +134,8 @@ void _panic(const char *fileorigin, const int lineorigin, const char *fmt, ...) void **backtrace_addresses = malloc(sizeof(void*) * 32); int backtrace_count = backtrace(backtrace_addresses, 32); - char **backtrace_symbolnames = backtrace_symbols(backtrace_addresses, backtrace_count); + char **backtrace_symbolnames = + backtrace_symbols(backtrace_addresses, backtrace_count); __asm__("_panic.spin_lock:"); __asm__("mov rax, 1"); @@ -141,16 +144,19 @@ void _panic(const char *fileorigin, const int lineorigin, const char *fmt, ...) __asm__("jnz .spin_lock"); print(NOLOCK("5") "------------[ cut here ]------------"); - print(LOG_SOH "\7""0" "%s at %s:%d", mode_to_string[(int)mode], fileorigin, lineorigin); + print(LOG_SOH "\7""0" "%s at %s:%d", mode_to_string[(int)mode], + fileorigin, lineorigin); vaprint(_fmt, ap); print(LOG_SOH "\7""7" "Call Trace:"); for(int i = 0; i < backtrace_count; ++i) { - print(NOLOCK("7") " [0x%016x] %s", backtrace_addresses[i], backtrace_symbolnames[i]); + print(NOLOCK("7") " [0x%016x] %s", backtrace_addresses[i], + backtrace_symbolnames[i]); } if(mainpid == pid){ print(NOLOCK("7") " "); } else { - print(NOLOCK("7") " ", subsystem_get_name(pid), pid); + print(NOLOCK("7") " ", + subsystem_get_name(pid), pid); } /* if we are going to die, we dont really need to clean up */ diff --git a/init/subsys.c b/init/subsys.c index d080ba6..3db2cb5 100644 --- a/init/subsys.c +++ b/init/subsys.c @@ -41,7 +41,8 @@ static int __subsystem_entry(struct subsystem_info *info) prctl(PR_SET_NAME, name); free(name); - print(LOG_DEBUG "subsys: starting subsystem %s (%d)", info->fn_name, getpid()); + print(LOG_DEBUG "subsys: starting subsystem %s (%d)", + info->fn_name, getpid()); int ret = info->fn(); @@ -81,13 +82,16 @@ int subsystem_handle_term(int pid) if(!subsystem || subsystem->pid != pid) continue; - print(LOG_DEBUG "subsys: subsystem terminated %s (%d)", subsystem->fn_name, pid); + print(LOG_DEBUG "subsys: subsystem terminated %s (%d)", + subsystem->fn_name, pid); if(subsystem->mode == PANICMODE_RESPAWN && subsystem->respawn_count < MAX_RESPAWN) { ++(subsystem->respawn_count); - int pid = clone((int (*)(void *))__subsystem_entry, (void *)((long)(subsystem->stack) + stack_size), CLONE_FILES | CLONE_VM | SIGCHLD, subsystem); + int pid = clone((int (*)(void *))__subsystem_entry, + (void *)((long)(subsystem->stack) + stack_size), + CLONE_FILES | CLONE_VM | SIGCHLD, subsystem); subsystem->pid = pid; if(pid < 0) { print(LOG_CRIT "subsys: cannot re-start subsystem %s: " -- cgit v1.2.3