Skip to content

Commit

Permalink
Update the coding style.
Browse files Browse the repository at this point in the history
Update the coding style and ensure consistency across the code-base.

From now on, "return;" should be used instead of "return ;", and functions without parameters should have a coding style more similar to other functions.
  • Loading branch information
Arignir committed Mar 16, 2024
1 parent 5bea52f commit 5a7b3da
Show file tree
Hide file tree
Showing 34 changed files with 91 additions and 81 deletions.
10 changes: 6 additions & 4 deletions include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ hs_usleep(

static inline
uint64_t
hs_time(void)
{
hs_time(
void
) {
FILETIME ts;
uint64_t time;

Expand Down Expand Up @@ -198,8 +199,9 @@ hs_basename(

static inline
uint64_t
hs_time(void)
{
hs_time(
void
) {
struct timespec ts;

hs_assert(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
Expand Down
4 changes: 2 additions & 2 deletions source/app/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ app_bindings_handle(

/* The next binds are only triggered when the key is pressed, not when it is released. */
if (!pressed) {
return ;
return;
}

/* Bindings that can be used outside of a game */
Expand All @@ -150,7 +150,7 @@ app_bindings_handle(
}

if (!app->emulation.is_started) {
return ;
return;
}

/* Bindings that cannot be used outside of a game */
Expand Down
4 changes: 2 additions & 2 deletions source/app/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ app_config_load(
config_file = hs_fopen(path, "r");
if (!config_file) {
logln(HS_ERROR, "Failed to open \"%s\": %s", path, strerror(errno));
return ;
return;
}

data_len = fread(data, 1, sizeof(data) - 1, config_file);
Expand Down Expand Up @@ -229,7 +229,7 @@ app_config_save(
config_file = hs_fopen(path, "w");
if (!config_file) {
logln(HS_ERROR, "Failed to open \"%s\": %s", path, strerror(errno));
return ;
return;
}

// We need to fill `keyboard_binds_name` with a copy of all the keyboard's bind name because
Expand Down
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/apu.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ debugger_cmd_apu(
size_t i;

if (debugger_check_arg_type(CMD_APU, &argv[0], ARGS_STRING)) {
return ;
return;
}

for (i = 0; i < array_length(values); ++i) {
Expand All @@ -69,7 +69,7 @@ debugger_cmd_apu(
g_reset
);
app_emulator_settings(app);
return ;
return;
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/app/dbg/cmd/break.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ debugger_cmd_break(
if (debugger_check_arg_type(CMD_BREAK, &argv[0], ARGS_STRING)
|| debugger_check_arg_type(CMD_BREAK, &argv[1], ARGS_INTEGER)
) {
return ;
return;
}

if (strcmp(argv[0].value.s, "delete") && strcmp(argv[0].value.s, "d")) {
printf("Usage: %s\n", g_commands[CMD_BREAK].usage);
return ;
return;
}

idx = argv[1].value.i64;
if (idx <= 0 || idx > app->debugger.breakpoints_len) {
printf("Unknown breakpoint with ID %zu.\n", idx);
return ;
return;
}
idx -= 1;

Expand Down
5 changes: 3 additions & 2 deletions source/app/dbg/cmd/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ debugger_dump_context_auto(
}

void
debugger_dump_context_compact_header(void)
{
debugger_dump_context_compact_header(
void
) {
size_t i;

printf(" %sCycle Counter%s ", g_light_green, g_reset);
Expand Down
10 changes: 5 additions & 5 deletions source/app/dbg/cmd/disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ debugger_cmd_disas(
ptr = core->pc >= op_len * 2 ? core->pc - op_len * 2 : 0;
} else if (argc == 1) {
if (debugger_check_arg_type(CMD_DISAS, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

ptr = argv[0].value.i64;
Expand All @@ -318,7 +318,7 @@ debugger_cmd_disas(
if (debugger_check_arg_type(CMD_DISAS, &argv[0], ARGS_STRING)
|| debugger_check_arg_type(CMD_DISAS, &argv[1], ARGS_INTEGER)
) {
return ;
return;
}

mode = argv[0].value.s;
Expand All @@ -331,18 +331,18 @@ debugger_cmd_disas(
op_len = 4;
} else {
printf("Unknown mode \"%s\".\n", mode);
return ;
return;
}

ptr = argv[1].value.i64;
} else {
printf("Usage: %s\n", g_commands[CMD_DISAS].usage);
return ;
return;
}

if (ptr % op_len) {
printf("The address to disassemble (0x%08x) isn't aligned.\n", ptr);
return ;
return;
}

debugger_cmd_disas_around(
Expand Down
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ debugger_cmd_frame(
debugger_dump_context_auto(app);
} else if (argc == 1) {
if (debugger_check_arg_type(CMD_FRAME, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

app_emulator_frame(app, argv[0].value.i64);
debugger_wait_for_emulator(app);
debugger_dump_context_auto(app);
} else {
printf("Usage: %s\n", g_commands[CMD_FRAME].usage);
return ;
return;
}
}
2 changes: 1 addition & 1 deletion source/app/dbg/cmd/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ debugger_cmd_help(
printf("Usage: %s\n", cmd->usage);
printf("\n");
printf("%s\n", cmd->description);
return ;
return;
}
++cmd;
}
Expand Down
6 changes: 3 additions & 3 deletions source/app/dbg/cmd/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ debugger_cmd_io(
struct io_register *reg;

if (debugger_check_arg_type(CMD_IO, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

reg = debugger_io_lookup_reg(argv[0].value.i64);
Expand All @@ -217,7 +217,7 @@ debugger_cmd_io(
debugger_check_arg_type(CMD_IO, &argv[0], ARGS_INTEGER)
|| debugger_check_arg_type(CMD_IO, &argv[1], ARGS_INTEGER)
) {
return ;
return;
}

reg = debugger_io_lookup_reg(argv[0].value.i64);
Expand All @@ -239,6 +239,6 @@ debugger_cmd_io(
}
} else {
printf("Usage: %s\n", g_commands[CMD_IO].usage);
return ;
return;
}
}
6 changes: 3 additions & 3 deletions source/app/dbg/cmd/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ debugger_cmd_key(
if (debugger_check_arg_type(CMD_KEY, &argv[0], ARGS_STRING)
|| debugger_check_arg_type(CMD_KEY, &argv[1], ARGS_INTEGER)
) {
return ;
return;
}

for (i = KEY_MIN; i < KEY_MAX; ++i) {
Expand All @@ -52,13 +52,13 @@ debugger_cmd_key(
argv[0].value.s,
argv[1].value.i64 ? "true" : "false"
);
return ;
return;
}
}

printf("Error: unknown key \"%s\".\n", argv[0].value.s);
} else {
printf("Usage: %s\n", g_commands[CMD_KEY].usage);
return ;
return;
}
}
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ debugger_cmd_ppu(
size_t i;

if (debugger_check_arg_type(CMD_PPU, &argv[0], ARGS_STRING)) {
return ;
return;
}

for (i = 0; i < array_length(values); ++i) {
Expand All @@ -67,7 +67,7 @@ debugger_cmd_ppu(
g_reset
);
app_emulator_settings(app);
return ;
return;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ debugger_cmd_print(

if (argc != 2 && argc != 3) {
printf("Usage: %s\n", g_commands[CMD_PRINT].usage);
return ;
return;
}

if (debugger_check_arg_type(CMD_PRINT, &argv[0], ARGS_STRING)
|| debugger_check_arg_type(CMD_PRINT, &argv[1], ARGS_INTEGER)
|| (argc == 3 && debugger_check_arg_type(CMD_PRINT, &argv[2], ARGS_INTEGER))
) {
return ;
return;
}

type = argv[0].value.s;
Expand Down
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/screenshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ debugger_cmd_screenshot(
app_emulator_screenshot(app);
} else if (argc == 1) {
if (debugger_check_arg_type(CMD_SCREENSHOT, &argv[0], ARGS_STRING)) {
return ;
return;
}

app_emulator_screenshot_path(app, argv[0].value.s);
} else {
printf("Usage: %s\n", g_commands[CMD_SCREENSHOT].usage);
return ;
return;
}
}
8 changes: 4 additions & 4 deletions source/app/dbg/cmd/step.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ debugger_cmd_step_in(
} else if (argc == 1) {

if (debugger_check_arg_type(CMD_STEP_IN, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

app_emulator_step_in(app, argv[0].value.i64);
debugger_wait_for_emulator(app);
debugger_dump_context_auto(app);
} else {
printf("Usage: %s\n", g_commands[CMD_STEP_IN].usage);
return ;
return;
}
}

Expand All @@ -59,14 +59,14 @@ debugger_cmd_step_over(
} else if (argc == 1) {

if (debugger_check_arg_type(CMD_STEP_OVER, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

app_emulator_step_over(app, argv[0].value.i64);
debugger_wait_for_emulator(app);
debugger_dump_context_auto(app);
} else {
printf("Usage: %s\n", g_commands[CMD_STEP_OVER].usage);
return ;
return;
}
}
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ debugger_cmd_trace(
debugger_dump_context_compact_header();
} else if (argc == 1) {
if (debugger_check_arg_type(CMD_TRACE, &argv[0], ARGS_INTEGER)) {
return ;
return;
}

debugger_dump_context_compact_header();
Expand All @@ -38,6 +38,6 @@ debugger_cmd_trace(
debugger_dump_context_compact_header();
} else {
printf("Usage: %s\n", g_commands[CMD_TRACE].usage);
return ;
return;
}
}
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/verbose.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ debugger_cmd_verbose(
uint32_t i;

if (debugger_check_arg_type(CMD_VERBOSE, &argv[0], ARGS_STRING)) {
return ;
return;
}

// Easily toggle all verbosities on or off
Expand All @@ -84,7 +84,7 @@ debugger_cmd_verbose(
g_reset
);

return ;
return;
}

for (i = 0; verbosities[i].name; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions source/app/dbg/cmd/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ debugger_cmd_watch(
|| debugger_check_arg_type(CMD_WATCH, &argv[1], ARGS_INTEGER)
) {
printf("Usage: %s\n", g_commands[CMD_WATCH].usage);
return ;
return;
}

read = !strcmp(argv[0].value.s, "read") || !strcmp(argv[0].value.s, "r");
Expand Down Expand Up @@ -78,7 +78,7 @@ debugger_cmd_watch(
idx = argv[1].value.i64;
if (idx <= 0 || idx > app->debugger.watchpoints_len) {
printf("Unknown watchpoint with ID %zu.\n", idx);
return ;
return;
}
idx -= 1;

Expand Down
9 changes: 5 additions & 4 deletions source/app/dbg/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ debugger_run_command(
if (ast->error) {
printf("Error: %s.\n", ast->error);
// TODO FIXME free stuff
return ;
return;
}

args = realloc(args, sizeof(*args) * (len + 1));
Expand All @@ -394,7 +394,7 @@ debugger_run_command(
if (eval.error) {
printf("Error: %s.\n", eval.error);
// TODO FIXME free stuff
return ;
return;
}

args[len - 1].type = ARGS_INTEGER;
Expand Down Expand Up @@ -565,8 +565,9 @@ debugger_run(
}

void
debugger_reset_terminal(void)
{
debugger_reset_terminal(
void
) {
rl_reset_terminal(NULL);
}

Expand Down

0 comments on commit 5a7b3da

Please sign in to comment.