diff --git a/TODOS.md b/TODOS.md index 4f9e7c4..7f96bbc 100644 --- a/TODOS.md +++ b/TODOS.md @@ -20,7 +20,7 @@ 10. **config.odin:178** — `search_paths` silently ignores `os.user_home_dir` error. If home is empty, `~` isn't expanded. Same class of bug as issue 3. -12. **db.odin:352-353** — `hex.encode` error ignored. `string(hex_bytes)` aliases the byte slice. +12. Consistently ignore allocator errors 13. **cmd_sync.odin:80, cmd_list.odin:33** — `make([]string, 2)` for table rows never freed. Leaks per row. Defer to memory pass. diff --git a/db.odin b/db.odin index 22d29d4..90c43a6 100644 --- a/db.odin +++ b/db.odin @@ -1,5 +1,6 @@ package main +import "base:runtime" import "core:crypto/hash" import "core:encoding/hex" import "core:encoding/ini" @@ -406,9 +407,7 @@ new_env_file :: proc(path: string) -> (EnvFile, bool) { } digest := hash.hash_bytes(hash.Algorithm.SHA256, data, context.temp_allocator) - // TODO: Handle error - hex_bytes, _ := hex.encode(digest) - + hex_bytes := hex.encode(digest, context.allocator) return EnvFile { Path = abs_path, Dir = dir, @@ -453,11 +452,7 @@ db_sync :: proc(db: ^Db, f: ^EnvFile) -> (SyncFlag, SyncError) { } digest := hash.hash_bytes(hash.Algorithm.SHA256, data, context.temp_allocator) - hex_bytes, hex_err := hex.encode(digest, allocator) - if hex_err != nil { - fmt.eprintf("db_sync: failed to encode hash for %s: %v\n", f.Path, hex_err) - return result, .ReadFailed - } + hex_bytes := hex.encode(digest, allocator) current_sha := string(hex_bytes) if current_sha == f.Sha256 { diff --git a/db_test.odin b/db_test.odin index ca0d13a..c11bdee 100644 --- a/db_test.odin +++ b/db_test.odin @@ -436,7 +436,7 @@ test_db_sync_noop :: proc(t: ^testing.T) { transmute([]u8)content, context.temp_allocator, ) - hex_bytes, _ := hex.encode(digest, context.temp_allocator) + hex_bytes := hex.encode(digest, context.temp_allocator) sha := string(hex_bytes) db, ok := db_init()