-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yo1dog/code-prep #52
base: master
Are you sure you want to change the base?
yo1dog/code-prep #52
Conversation
Just noticed #51 Can wait until that gets merged and then I can rebase. |
Yeah, let's merge that. You should be able to follow this to do your rebase automatically: https://stackoverflow.com/a/71812873. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round, reviewed up to 90e797b (use BOOT_PAYLOAD struct).
I'll let you rebase and address my comments before continuing.
source/main.c
Outdated
@@ -38,6 +37,18 @@ struct shortcut { | |||
}; | |||
int num_shortcuts = sizeof(shortcuts)/sizeof(shortcuts[0]); | |||
|
|||
u16 all_buttons_held; | |||
void scan_all_buttons_held() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is named after the function it calls, but this name feels a bit awkward.
source/shortcut.h
Outdated
#define INC_SHORTCUT_H | ||
#include <gctypes.h> | ||
|
||
#define NUM_SHORTCUTS 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're changing this from calculating the length to hardcoding a value. This is easy to miss and forget updating. Just export the symbol from the new file.
source/main.c
Outdated
if (all_buttons_held & shortcuts[i].pad_buttons) { | ||
paths[num_paths++] = shortcuts[i].path; | ||
break; | ||
} | ||
} | ||
|
||
paths[num_paths++] = default_path; | ||
paths[num_paths++] = shortcuts[0].path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the special case could be removed entirely.
Move the default path to the bottom of the list, then adjust the condition in the loop.
source/main.c
Outdated
typedef struct | ||
{ | ||
u8 *dol; | ||
int dol_argc; | ||
char *dol_argv[MAX_NUM_ARGV]; | ||
} BOOT_PAYLOAD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably avoid typedef
(and when you must, suffix the name with _t
). Type names should be lowercase.
source/main.c
Outdated
@@ -34,7 +38,7 @@ void scan_all_buttons_held() | |||
); | |||
} | |||
|
|||
void dol_alloc(int size) | |||
void dol_alloc(u8 **_dol, int size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're a two-star codebase now. :)
There is absolutely no reason to use indirection here, simply return the address.
source/main.c
Outdated
} | ||
|
||
void load_parse_cli(char *path) | ||
void load_parse_cli(char **_dol_argv, int *_dol_argc, char *path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the first two arguments here, take in a pointer to a struct boot_payload
.
source/main.c
Outdated
BOOT_PAYLOAD payload; | ||
payload.dol = NULL; | ||
payload.dol_argc = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct boot_payload payload = { 0 };
- Condense 2 instances of scanning and assigning `all_buttons_held` into a single function.
- Move shortcut definitions to its own file.
- Add a special shortcut definition for default `ipl.dol`. - This prepares for future in which shortcuts are referenced rather than just paths and prevents requiring explicit handling of the special no-shortcut/default case.
- Defines the `BOOT_PAYLOAD` struct for containerizing boot data (`dol` and `dol_argc`). - Removes boot data from global scope.
- Splits `load_parse_cli` into `read_cli_file` and `parse_cli_file`. - Moves DOL file reading to `read_dol_file`.
- Reference shortcuts rather just the shortcut's paths. - Prepares for future in which shortcuts define more than just a path.
- Moves finding and reading of shortcut DOL and CLI files to `load_shortcut_files`.
- Moves all filesystem reading and handling code to its own `filesystem.c` file. - `FS_RESULT` enum extends and replaces `FRESULT` enum. - Colapses `utils.c` into `filesystem.c`. - `dol_alloc` function removed. Filesystem and USB geko routines handle malloc independently. - Dropped `_size` param from `read_cli_file` in favor of `strenlen`
- Rather than track `argc` and `argv` array and combine into `__argv` struct later, create `__argv` struct immediately. - Moves CLI parsing to its own file. - Renames `parse_cli_file` to `parse_cli_args` as it is source agnostic.
- Silence erroneous `TB_BUS_CLOCK` undefined error in some IDEs. - Group global state to top of `main.c`. - Copy and modify rather than overwriting DOL path for CLI path in `read_cli_file`. - `dol` -> `dol_file`, `cli` -> `cli_file`, and other variable name clarifications. - Add comments to describe function return codes. - Add various comments. - Various stylistic changes and delinting for consistency.
9c25698
to
87fd89a
Compare
Rebased. Automatic rebase was cool, but the always-take-theirs strategy did the wrong things a few times that I noticed. I didn't really trust it (always skeptical of anything that automates code edits) so I just did the rebase manually. |
A few things to keep in mind:
|
I went to address some of the comments you have made already, but most seem moot as the change is overwritten or removed in a later commit. Rather than stepping through each commit it may be better to evaluate the final result. |
All of that's fine. It's a hobby for me too, and there is no rush to get any of this merged. Do let me know if you feel like I'm putting too much pressure on you though, I can be overly perfectionist but I don't mind putting in some work to help get this where I want it.
The code has not actually changed much since then. Most of the work has gone into the new build system, which helped remove almost all prebuilt binaries from the repo (all that's left now is the flasher for the Qoob series, which will be replaced by open source rewrites in due time).
It's important that the individual commits make sense. For one, it's much easier to review commits one by one than the final diff, and it's also useful in the future to understand why the code looks the way it does.
This possibly warrants a reorganization of the commits then? Do let me know what doesn't make sense to you and we can try to adjust that. |
Eh. Probably not. When I did the work of splitting up the commits it was for that purpose: So that the changes could be stepped through to get a clear view of the history. But I wasn't necessarily trying to get every commit to stand on its own, which sounds like is your goal. To that end I am happy to make inter-commit fixes to clean it up, even if it doesn't affect the final result because it is replaced in a later commit. Funny enough, I have spent way more time rebasing and splitting up commits than I did on the actual improvements lol. |
Here's the thing: if the commits are split for reviewability, they should be reviewed as such. In general, it's a common expectation that every commit will at least build and run (and pass tests, but we don't have those). This helps understand the context for a change, and it makes tool like As a tangential note, I've been putting a lot of work into making gekkoboot reproducible. This means that the repo contains enough information at this point for anyone to clone it at any point in the future, and build any commit from source with a matching checksum. This is extremely valuable for debugging, and it's also why I care so much about history that makes sense.
Can you point out such an occurrence within this PR? I agree that it's not really worth it to put too much effort into transitional states, but I'm also a bit confused about what you mean. What changes are going to be replaced later that I commented on? I'm happy to accept some imperfect things if they're not going to stay, just show me what they are.
Hopefully we're done with major rebases. Sorry about the whole formatting thing, I'm putting the master branch on a soft freeze until we're done (or at least have made significant progress) with merging your work. |
Does not change any functionality. Cleans up the code base in preparation for upcoming changes.
In our previous convo we discussed the fact that their was actually not yet any "established coding style." I left the commits as-is to avoid conflicts in child commits for now. I am fine with whatever style you want of course.