From 6fa68d10b14db981bacc67c3121a83e8958080ca Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Thu, 25 Jun 2026 17:27:26 -0400 Subject: [PATCH] style: Ignored allocation errors where possible. --- TODOS.md | 24 +++++++++++------------- config.odin | 2 +- db.odin | 4 ++-- findr/repos.odin | 4 ++-- findr/test_env.odin | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/TODOS.md b/TODOS.md index c3dcc59..6ba7b35 100644 --- a/TODOS.md +++ b/TODOS.md @@ -1,6 +1,6 @@ # TODOs -1. Commands are still leaking. (Do 13. first) +1. Commands are still leaking. (Write tests for everything first) 2. Add color flag and support non colored output. @@ -8,27 +8,25 @@ 4. Generate md and man pages again. -5. Consistently ignore allocator errors +5. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`. -6. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`. +6. Add a text filter to the multi_select. -7. Add a text filter to the multi_select. +7. Add tests for untested commands. -8. Add tests for untested commands. +8. add --format -f flag to commands that draw tables. -9. add --format -f flag to commands that draw tables. +9. procedures should be ordered by use, main at the top, then in the order they are called from main. -10. procedures should be ordered by use, main at the top, then in the order they are called from main. +10. Shell completion -11. Shell completion +11. Bring back windows support / cross-compilation. -12. Bring back windows support / cross-compilation. +12. Test all cmds / terminal branches. -13. Test all cmds / terminal branches. +13. Pass allocator to findr? -14. Pass allocator to findr? - -15. Update `read_wire_string` to use a slice. +14. Update `read_wire_string` to use a slice. ## Double-check AI output diff --git a/config.odin b/config.odin index 8d648b4..556c174 100644 --- a/config.odin +++ b/config.odin @@ -123,7 +123,7 @@ new_config :: proc( for priv in private_key_paths { // TODO: Is this bad? priv_key := strings.clone(priv) - pub, _ := strings.concatenate([]string{priv_key, ".pub"}) + pub := strings.concatenate([]string{priv_key, ".pub"}) append(&keys, SshKeyPair{private = priv_key, public = pub}) } diff --git a/db.odin b/db.odin index 33d59f9..5ec8853 100644 --- a/db.odin +++ b/db.odin @@ -572,7 +572,7 @@ try_move_dir :: proc(db: ^Db, f: ^EnvFile, allocator: mem.Allocator) -> (bool, S case 0: return false, .DirMissing case 1: - f.dir, _ = strings.clone(matched_dir, allocator) + f.dir = strings.clone(matched_dir, allocator) base := filepath.base(f.path) new_path, _ := filepath.join({f.dir, base}, allocator) f.path = new_path @@ -613,7 +613,7 @@ get_git_remotes :: proc(dir: string, allocator: mem.Allocator) -> [dynamic]strin } if !found { // FIXME: Currently leaks when adding a file with envr scan - cloned, _ := strings.clone(url, allocator) + cloned := strings.clone(url, allocator) append(&remotes, cloned) } } diff --git a/findr/repos.odin b/findr/repos.odin index 2cd54e6..197354e 100644 --- a/findr/repos.odin +++ b/findr/repos.odin @@ -26,7 +26,7 @@ find_repos :: proc(roots: []string, results: ^[dynamic]string, thread_count: int pool.threads = make([]^thread.Thread, thread_count) for root in roots { - root_clone, _ := strings.clone(root) + root_clone := strings.clone(root) append(&pool.queue, root_clone) sync.atomic_sema_post(&pool.queue_sema) } @@ -97,7 +97,7 @@ process_repo_dir :: proc(pool: ^RepoPool, dir_path: string) { defer linux.close(fd) if has_git_dir(fd) { - cloned, _ := strings.clone(dir_path) + cloned := strings.clone(dir_path) sync.mutex_lock(&pool.results_lock) append(pool.results, cloned) sync.mutex_unlock(&pool.results_lock) diff --git a/findr/test_env.odin b/findr/test_env.odin index 2c13631..654f79b 100644 --- a/findr/test_env.odin +++ b/findr/test_env.odin @@ -137,7 +137,7 @@ collect_results :: proc(env: TestEnv, args: []string, opts: WalkOptions) -> [dyn if len(stripped) > 0 && stripped[0] == os.Path_Separator { stripped = stripped[1:] } - new_r, _ := strings.clone(stripped) + new_r := strings.clone(stripped) delete(r) results[i] = new_r }