Update code style

Limit source code to 80 chars, and declare functions return type and
modifiers on a separate line.

This allows to avoid very long lines, and all function names are
aligned.

(We do this on VLC, and I like it.)
This commit is contained in:
Romain Vimont
2019-03-02 20:09:56 +01:00
parent b2fe005498
commit aeda583a2c
45 changed files with 813 additions and 409 deletions

View File

@@ -11,7 +11,8 @@
#include <unistd.h>
#include "log.h"
enum process_result cmd_execute(const char *path, const char *const argv[], pid_t *pid) {
enum process_result
cmd_execute(const char *path, const char *const argv[], pid_t *pid) {
int fd[2];
if (pipe(fd) == -1) {
@@ -72,15 +73,18 @@ end:
return ret;
}
SDL_bool cmd_terminate(pid_t pid) {
SDL_bool
cmd_terminate(pid_t pid) {
if (pid <= 0) {
LOGC("Requested to kill %d, this is an error. Please report the bug.\n", (int) pid);
LOGC("Requested to kill %d, this is an error. Please report the bug.\n",
(int) pid);
abort();
}
return kill(pid, SIGTERM) != -1;
}
SDL_bool cmd_simple_wait(pid_t pid, int *exit_code) {
SDL_bool
cmd_simple_wait(pid_t pid, int *exit_code) {
int status;
int code;
if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status)) {

View File

@@ -2,15 +2,18 @@
# include <unistd.h>
SDL_bool net_init(void) {
SDL_bool
net_init(void) {
// do nothing
return SDL_TRUE;
}
void net_cleanup(void) {
void
net_cleanup(void) {
// do nothing
}
SDL_bool net_close(socket_t socket) {
SDL_bool
net_close(socket_t socket) {
return !close(socket);
}

View File

@@ -4,7 +4,8 @@
#include "log.h"
#include "str_util.h"
static int build_cmd(char *cmd, size_t len, const char *const argv[]) {
static int
build_cmd(char *cmd, size_t len, const char *const argv[]) {
// Windows command-line parsing is WTF:
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
// only make it work for this very specific program
@@ -17,7 +18,8 @@ static int build_cmd(char *cmd, size_t len, const char *const argv[]) {
return 0;
}
enum process_result cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
enum process_result
cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
STARTUPINFOW si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
@@ -40,7 +42,8 @@ enum process_result cmd_execute(const char *path, const char *const argv[], HAND
#else
int flags = 0;
#endif
if (!CreateProcessW(NULL, wide, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi)) {
if (!CreateProcessW(NULL, wide, NULL, NULL, FALSE, flags, NULL, NULL, &si,
&pi)) {
free(wide);
*handle = NULL;
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
@@ -54,13 +57,16 @@ enum process_result cmd_execute(const char *path, const char *const argv[], HAND
return PROCESS_SUCCESS;
}
SDL_bool cmd_terminate(HANDLE handle) {
SDL_bool
cmd_terminate(HANDLE handle) {
return TerminateProcess(handle, 1) && CloseHandle(handle);
}
SDL_bool cmd_simple_wait(HANDLE handle, DWORD *exit_code) {
SDL_bool
cmd_simple_wait(HANDLE handle, DWORD *exit_code) {
DWORD code;
if (WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0 || !GetExitCodeProcess(handle, &code)) {
if (WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0
|| !GetExitCodeProcess(handle, &code)) {
// cannot wait or retrieve the exit code
code = -1; // max value, it's unsigned
}

View File

@@ -2,7 +2,8 @@
#include "log.h"
SDL_bool net_init(void) {
SDL_bool
net_init(void) {
WSADATA wsa;
int res = WSAStartup(MAKEWORD(2, 2), &wsa) < 0;
if (res < 0) {
@@ -12,10 +13,12 @@ SDL_bool net_init(void) {
return SDL_TRUE;
}
void net_cleanup(void) {
void
net_cleanup(void) {
WSACleanup();
}
SDL_bool net_close(socket_t socket) {
SDL_bool
net_close(socket_t socket) {
return !closesocket(socket);
}