chore: Apply code formatting on entire codebase for consistent style
This commit is contained in:
@@ -150,7 +150,7 @@ void arc4_apply(struct arc4 *arc4, uint8_t *bytes, size_t nbytes)
|
||||
|
||||
SWAP(arc4->S[arc4->i], arc4->S[arc4->j], tmp);
|
||||
|
||||
bytes[i] ^= arc4->S[(uint8_t)(arc4->S[arc4->i] + arc4->S[arc4->j])];
|
||||
bytes[i] ^= arc4->S[(uint8_t) (arc4->S[arc4->i] + arc4->S[arc4->j])];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define LOG_MODULE "util-iobuf"
|
||||
|
||||
#include "util/hex.h"
|
||||
#include "util/iobuf.h"
|
||||
#include "util/hex.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
|
||||
+2
-1
@@ -59,7 +59,8 @@ static void log_builtin_format(
|
||||
result = str_format(
|
||||
line, sizeof(line), "%c:%s: %s\n", chars[msg_level], module, msg);
|
||||
|
||||
// TODO move this up because there is no reason to format and do all the above if disabled
|
||||
// TODO move this up because there is no reason to format and do all the
|
||||
// above if disabled
|
||||
if (msg_level <= log_level) {
|
||||
log_writer(log_writer_ctx, line, result);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "util/math.h"
|
||||
|
||||
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound) {
|
||||
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound)
|
||||
{
|
||||
int16_t half_point = bound / 2;
|
||||
|
||||
int16_t delta = val - last;
|
||||
@@ -17,6 +18,7 @@ int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound) {
|
||||
return delta;
|
||||
}
|
||||
|
||||
int16_t sign_s16(int16_t x) {
|
||||
int16_t sign_s16(int16_t x)
|
||||
{
|
||||
return (x > 0) - (x < 0);
|
||||
}
|
||||
|
||||
+10
-8
@@ -13,9 +13,9 @@
|
||||
#define STATUS_SUCCESS (0x00000000)
|
||||
|
||||
typedef LONG NTSTATUS, *PNTSTATUS;
|
||||
typedef NTSTATUS (WINAPI* RtlGetVersion_t)(PRTL_OSVERSIONINFOW);
|
||||
typedef NTSTATUS(WINAPI *RtlGetVersion_t)(PRTL_OSVERSIONINFOW);
|
||||
|
||||
static const char* human_readable_version(DWORD major, DWORD minor)
|
||||
static const char *human_readable_version(DWORD major, DWORD minor)
|
||||
{
|
||||
if (IsWindowsServer()) {
|
||||
if (major == 5 && minor == 2) {
|
||||
@@ -38,7 +38,7 @@ static const char* human_readable_version(DWORD major, DWORD minor)
|
||||
return "Windows 2000";
|
||||
} else if (major == 5 && minor == 1) {
|
||||
return "Windows XP";
|
||||
} else if (major == 5 && minor == 2 ) {
|
||||
} else if (major == 5 && minor == 2) {
|
||||
return "Windows XP 64-bit";
|
||||
} else if (major == 6 && minor == 0) {
|
||||
return "Windows Vista";
|
||||
@@ -76,13 +76,13 @@ static bool os_get_real_win_version(PRTL_OSVERSIONINFOW version)
|
||||
return rtl_get_version(version) == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool os_version_get(struct os_version* version)
|
||||
bool os_version_get(struct os_version *version)
|
||||
{
|
||||
log_assert(version);
|
||||
|
||||
RTL_OSVERSIONINFOW rovi;
|
||||
char* version_str;
|
||||
const char* readable_version;
|
||||
char *version_str;
|
||||
const char *readable_version;
|
||||
|
||||
memset(&rovi, 0, sizeof(RTL_OSVERSIONINFOW));
|
||||
rovi.dwOSVersionInfoSize = sizeof(rovi);
|
||||
@@ -96,7 +96,8 @@ bool os_version_get(struct os_version* version)
|
||||
// Contains additional version info, e.g. "Service Pack 3" for XP
|
||||
wstr_narrow(rovi.szCSDVersion, &version_str);
|
||||
|
||||
readable_version = human_readable_version(rovi.dwMajorVersion, rovi.dwMinorVersion);
|
||||
readable_version =
|
||||
human_readable_version(rovi.dwMajorVersion, rovi.dwMinorVersion);
|
||||
|
||||
strcpy(version->name, readable_version);
|
||||
version->major = rovi.dwMajorVersion;
|
||||
@@ -119,7 +120,8 @@ void os_version_log()
|
||||
if (!os_version_get(&version)) {
|
||||
log_warning("Could not detect OS version");
|
||||
} else {
|
||||
log_info("OS version: %s - %d.%d.%d.%d - %s",
|
||||
log_info(
|
||||
"OS version: %s - %d.%d.%d.%d - %s",
|
||||
version.name,
|
||||
version.major,
|
||||
version.minor,
|
||||
|
||||
+2
-2
@@ -13,11 +13,11 @@ struct os_version {
|
||||
|
||||
/**
|
||||
* Get the (real) version information of the Windows OS.
|
||||
*
|
||||
*
|
||||
* @param verison Pointer to version structure. This will be filled in.
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
bool os_version_get(struct os_version* version);
|
||||
bool os_version_get(struct os_version *version);
|
||||
|
||||
/**
|
||||
* Log the version information of the current Windows OS.
|
||||
|
||||
@@ -7,9 +7,7 @@ void proc_terminate_current_process(uint32_t exit_code)
|
||||
HANDLE hnd;
|
||||
|
||||
hnd = OpenProcess(
|
||||
SYNCHRONIZE | PROCESS_TERMINATE,
|
||||
TRUE,
|
||||
GetCurrentProcessId());
|
||||
|
||||
SYNCHRONIZE | PROCESS_TERMINATE, TRUE, GetCurrentProcessId());
|
||||
|
||||
TerminateProcess(hnd, exit_code);
|
||||
}
|
||||
+14
-8
@@ -7,7 +7,7 @@
|
||||
|
||||
static signal_shutdown_handler_t shutdown_handler;
|
||||
|
||||
static const char* control_code_to_str(DWORD ctrl_code)
|
||||
static const char *control_code_to_str(DWORD ctrl_code)
|
||||
{
|
||||
switch (ctrl_code) {
|
||||
case CTRL_C_EVENT:
|
||||
@@ -28,7 +28,8 @@ static const char* control_code_to_str(DWORD ctrl_code)
|
||||
|
||||
static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType)
|
||||
{
|
||||
log_misc("Console ctrl handler called: %s", control_code_to_str(dwCtrlType));
|
||||
log_misc(
|
||||
"Console ctrl handler called: %s", control_code_to_str(dwCtrlType));
|
||||
|
||||
if (dwCtrlType == CTRL_C_EVENT) {
|
||||
if (shutdown_handler) {
|
||||
@@ -44,20 +45,25 @@ static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LONG WINAPI unhandled_exception_filter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||
static LONG WINAPI
|
||||
unhandled_exception_filter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||
{
|
||||
// no exception info provided
|
||||
if (ExceptionInfo != NULL) {
|
||||
struct _EXCEPTION_RECORD *ExceptionRecord = ExceptionInfo->ExceptionRecord;
|
||||
struct _EXCEPTION_RECORD *ExceptionRecord =
|
||||
ExceptionInfo->ExceptionRecord;
|
||||
|
||||
log_warning(
|
||||
"Exception raised: %s",
|
||||
"Exception raised: %s",
|
||||
signal_exception_code_to_str(ExceptionRecord->ExceptionCode));
|
||||
|
||||
struct _EXCEPTION_RECORD *record_cause = ExceptionRecord->ExceptionRecord;
|
||||
struct _EXCEPTION_RECORD *record_cause =
|
||||
ExceptionRecord->ExceptionRecord;
|
||||
|
||||
while (record_cause != NULL) {
|
||||
log_warning("Caused by: %s", signal_exception_code_to_str(record_cause->ExceptionCode));
|
||||
log_warning(
|
||||
"Caused by: %s",
|
||||
signal_exception_code_to_str(record_cause->ExceptionCode));
|
||||
record_cause = record_cause->ExceptionRecord;
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ void signal_register_shutdown_handler(signal_shutdown_handler_t handler)
|
||||
log_misc("Registered shutdown handler");
|
||||
}
|
||||
|
||||
const char* signal_exception_code_to_str(DWORD code)
|
||||
const char *signal_exception_code_to_str(DWORD code)
|
||||
{
|
||||
switch (code) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
typedef void (*signal_shutdown_handler_t)();
|
||||
|
||||
/**
|
||||
* Initialize signal and exception handlers. Exceptions and signals, are logged using the logger
|
||||
* to create visibility.
|
||||
* Initialize signal and exception handlers. Exceptions and signals, are logged
|
||||
* using the logger to create visibility.
|
||||
*/
|
||||
void signal_exception_handler_init();
|
||||
|
||||
/**
|
||||
* Register a handler function that gets called when the application is supposed to shut down,
|
||||
* e.g. on CTRL + C.
|
||||
* Register a handler function that gets called when the application is supposed
|
||||
* to shut down, e.g. on CTRL + C.
|
||||
*
|
||||
* @param handler Handler function to register.
|
||||
*/
|
||||
@@ -23,8 +23,8 @@ void signal_register_shutdown_handler(signal_shutdown_handler_t handler);
|
||||
|
||||
/**
|
||||
* Convert a (windows) exception code to a human readable representation.
|
||||
*
|
||||
*
|
||||
* @param code Exception code
|
||||
* @return Human readable representation of the given exception code
|
||||
*/
|
||||
const char* signal_exception_code_to_str(DWORD code);
|
||||
*/
|
||||
const char *signal_exception_code_to_str(DWORD code);
|
||||
@@ -51,15 +51,15 @@ int crt_thread_create(
|
||||
|
||||
void crt_thread_destroy(int thread_id)
|
||||
{
|
||||
CloseHandle((HANDLE)(uintptr_t) thread_id);
|
||||
CloseHandle((HANDLE) (uintptr_t) thread_id);
|
||||
}
|
||||
|
||||
void crt_thread_join(int thread_id, int *result)
|
||||
{
|
||||
WaitForSingleObject((HANDLE)(uintptr_t) thread_id, INFINITE);
|
||||
WaitForSingleObject((HANDLE) (uintptr_t) thread_id, INFINITE);
|
||||
|
||||
if (result) {
|
||||
GetExitCodeThread((HANDLE)(uintptr_t) thread_id, (DWORD *) result);
|
||||
GetExitCodeThread((HANDLE) (uintptr_t) thread_id, (DWORD *) result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user