clang-format: Apply formatting

Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
This commit is contained in:
jp9000
2019-06-22 22:13:45 -07:00
parent 53615ee10f
commit f53df7da64
567 changed files with 34068 additions and 32903 deletions

View File

@@ -47,15 +47,14 @@ error:
}
static inline bool ipc_pipe_internal_create_pipe(ipc_pipe_server_t *pipe,
const char *name)
const char *name)
{
SECURITY_ATTRIBUTES sa;
char new_name[512];
void *sd;
const DWORD access = PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED;
const DWORD flags = PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT;
const DWORD flags = PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE |
PIPE_WAIT;
strcpy_s(new_name, sizeof(new_name), "\\\\.\\pipe\\");
strcat_s(new_name, sizeof(new_name), name);
@@ -70,14 +69,15 @@ static inline bool ipc_pipe_internal_create_pipe(ipc_pipe_server_t *pipe,
sa.bInheritHandle = false;
pipe->handle = CreateNamedPipeA(new_name, access, flags, 1,
IPC_PIPE_BUF_SIZE, IPC_PIPE_BUF_SIZE, 0, &sa);
IPC_PIPE_BUF_SIZE, IPC_PIPE_BUF_SIZE, 0,
&sa);
free(sd);
return pipe->handle != INVALID_HANDLE_VALUE;
}
static inline void ipc_pipe_internal_ensure_capacity(ipc_pipe_server_t *pipe,
size_t new_size)
size_t new_size)
{
if (pipe->capacity >= new_size) {
return;
@@ -88,7 +88,7 @@ static inline void ipc_pipe_internal_ensure_capacity(ipc_pipe_server_t *pipe,
}
static inline void ipc_pipe_internal_append_bytes(ipc_pipe_server_t *pipe,
uint8_t *bytes, size_t size)
uint8_t *bytes, size_t size)
{
size_t new_size = pipe->size + size;
ipc_pipe_internal_ensure_capacity(pipe, new_size);
@@ -118,7 +118,7 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param)
bool success;
success = !!ReadFile(pipe->handle, buf, IPC_PIPE_BUF_SIZE, NULL,
&pipe->overlap);
&pipe->overlap);
if (!success && !ipc_pipe_internal_io_pending()) {
break;
}
@@ -129,7 +129,7 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param)
}
success = !!GetOverlappedResult(pipe->handle, &pipe->overlap,
&bytes, true);
&bytes, true);
if (!success || !bytes) {
break;
}
@@ -138,7 +138,7 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param)
if (success) {
pipe->read_callback(pipe->param, pipe->read_data,
pipe->size);
pipe->size);
pipe->size = 0;
}
}
@@ -147,16 +147,16 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param)
return 0;
}
static inline bool ipc_pipe_internal_start_server_thread(
ipc_pipe_server_t *pipe)
static inline bool
ipc_pipe_internal_start_server_thread(ipc_pipe_server_t *pipe)
{
pipe->thread = CreateThread(NULL, 0, ipc_pipe_internal_server_thread,
pipe, 0, NULL);
pipe, 0, NULL);
return pipe->thread != NULL;
}
static inline bool ipc_pipe_internal_wait_for_connection(
ipc_pipe_server_t *pipe)
static inline bool
ipc_pipe_internal_wait_for_connection(ipc_pipe_server_t *pipe)
{
bool success;
@@ -166,7 +166,7 @@ static inline bool ipc_pipe_internal_wait_for_connection(
}
static inline bool ipc_pipe_internal_open_pipe(ipc_pipe_client_t *pipe,
const char *name)
const char *name)
{
DWORD mode = PIPE_READMODE_MESSAGE;
char new_name[512];
@@ -174,8 +174,8 @@ static inline bool ipc_pipe_internal_open_pipe(ipc_pipe_client_t *pipe,
strcpy_s(new_name, sizeof(new_name), "\\\\.\\pipe\\");
strcat_s(new_name, sizeof(new_name), name);
pipe->handle = CreateFileA(new_name, GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
pipe->handle = CreateFileA(new_name, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (pipe->handle == INVALID_HANDLE_VALUE) {
return false;
}
@@ -186,7 +186,7 @@ static inline bool ipc_pipe_internal_open_pipe(ipc_pipe_client_t *pipe,
/* ------------------------------------------------------------------------- */
bool ipc_pipe_server_start(ipc_pipe_server_t *pipe, const char *name,
ipc_pipe_read_t read_callback, void *param)
ipc_pipe_read_t read_callback, void *param)
{
pipe->read_callback = read_callback;
pipe->param = param;
@@ -253,7 +253,7 @@ void ipc_pipe_client_free(ipc_pipe_client_t *pipe)
}
bool ipc_pipe_client_write(ipc_pipe_client_t *pipe, const void *data,
size_t size)
size_t size)
{
DWORD bytes;

View File

@@ -19,21 +19,21 @@
#include <windows.h>
struct ipc_pipe_server {
OVERLAPPED overlap;
HANDLE handle;
HANDLE ready_event;
HANDLE thread;
OVERLAPPED overlap;
HANDLE handle;
HANDLE ready_event;
HANDLE thread;
uint8_t *read_data;
size_t size;
size_t capacity;
uint8_t *read_data;
size_t size;
size_t capacity;
ipc_pipe_read_t read_callback;
void *param;
ipc_pipe_read_t read_callback;
void *param;
};
struct ipc_pipe_client {
HANDLE handle;
HANDLE handle;
};
static inline bool ipc_pipe_client_valid(ipc_pipe_client_t *pipe)

View File

@@ -35,13 +35,13 @@ typedef struct ipc_pipe_client ipc_pipe_client_t;
typedef void (*ipc_pipe_read_t)(void *param, uint8_t *data, size_t size);
bool ipc_pipe_server_start(ipc_pipe_server_t *pipe, const char *name,
ipc_pipe_read_t read_callback, void *param);
ipc_pipe_read_t read_callback, void *param);
void ipc_pipe_server_free(ipc_pipe_server_t *pipe);
bool ipc_pipe_client_open(ipc_pipe_client_t *pipe, const char *name);
void ipc_pipe_client_free(ipc_pipe_client_t *pipe);
bool ipc_pipe_client_write(ipc_pipe_client_t *pipe, const void *data,
size_t size);
size_t size);
static inline bool ipc_pipe_client_valid(ipc_pipe_client_t *pipe);
#ifdef _WIN32