Skip to content

std: fix the ownership and snake_case warnings std prints in user builds - #3692

Merged
BaseMax merged 20 commits into
mainfrom
fix/std-ownership-warnings
Nov 19, 2026
Merged

BaseMax merged 20 commits into
mainfrom
fix/std-ownership-warnings

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

A macOS build of examples/ui/calculator.salam printed std warnings (W163 in image webp_encode and webp_lossy_encode, W144 in gui/ui anim). This fixes those and every other std warning a sweep found.

Ownership (all checker false positives, restructured so each buffer has one owner):

  • image webp_encode: lens_out = lens moved the buffer before _wp_codes(lens) read it (two sites); codes_out is computed first.
  • image webp_lossy_encode: after tw.probs = newp, the code reads tw.probs instead of newp.
  • gui/ui anim: old_a was only used before the Push, but the checker flagged it across the loop back edge; a helper _anim_finish(k) takes the reference inside its own scope.
  • csv multirow: the header keys are copied for the header row.
  • opensearch os_bulk: the item count is read from out.items.

W175 (snake_case call spellings): 307 std call sites in tui, ai (onnx, gguf, llm, ml), opencv, data, npy, graph, decimal, excel, encoding/json, encoding/protobuf, chan and matrix now call the PascalCase spelling. Function valued fields (on_click and similar), string literal contents and calls whose snake name is also a builtin str or Vector method were left alone.

Before and after with a main built compiler: W175 307 to 0, W163 4 to 0, W144 1 to 0; an import of 240 std packages prints no warning, and checking 981 existing tests prints no std W14x to W17x warning. The tests of the touched packages (chan, excel, data, graph and others) match their .out files.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected handling of truncated tensor data and bulk-action counts.
    • Fixed CSV conversion to preserve a copy of generated header keys.
    • Improved animation replacement handling and WebP encoding behavior.
  • Refactor
    • Updated library components to use their current public APIs across AI, data, graph, matrix, spreadsheet, image, and terminal UI features. Existing algorithms, formats, and interaction behavior are otherwise unchanged.

@BaseMax
BaseMax requested a review from a team as a code owner November 19, 2026 22:23
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change updates standard-library call sites to use exported PascalCase APIs across AI, data, encoding, Excel, graph, matrix, OpenCV, and TUI packages. It also changes CSV header copying, bulk parsing counts, animation replacement, and WebP encoding.

Changes: Standard-library API migration

Layer / File(s) Summary
AI API calls
std/ai/*
GGUF, ONNX, and matrix-based AI code now uses the exported accessor names. GGUF truncation errors use the current error methods and include the calculated data offset.
Channels, data, and encoding
std/chan/*, std/data/*, std/encoding/*, std/npy/*
Call sites use capitalized channel and error methods. Existing selection behavior and error details remain as described.
Excel operations and file formats
std/excel/*
Sheet and workbook operations use capitalized methods across bridges, readers, and writers.
Graph algorithms
std/graph/*
Graph and heap access uses exported method names. The described algorithms and outcomes remain unchanged.
Numeric and OpenCV operations
std/decimal/*, std/matrix/*, std/opencv/*
Call sites use capitalized sign, matrix, error, and image methods. The described calculations and conversions remain unchanged.
TUI event, focus, and rendering
std/tui/*
Widgets, buffers, events, focus handling, and screen loops use capitalized methods. The described conditions and flow remain unchanged.

Targeted behavior fixes

Layer / File(s) Summary
Bulk parsing, CSV headers, animation, and WebP
std/db/opensearch/os_bulk.salam, std/encoding/csv/multirow.salam, std/gui/ui/anim.salam, std/image/webp_*
Bulk parsing reads the item count from out.items. CSV header construction copies the keys. Animation replacement calls a helper that marks the prior animation done. WebP encoding writes probability values from tw.probs and frees that table.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: bdadmehr0, erfangnu

Merge Risk: Minimal · up to d788d

This change moves standard-library calls to PascalCase names and fixes a few ownership warnings. No concrete defect was found, so it looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two warning types the PR targets, ownership and snake_case warnings in std. The changeset does both: it fixes ownership-checker false positives in webp, anim, csv multirow, and os_…
Description check Passed The description covers the purpose (W163, W144, W175 warnings from a macOS build), the proposed changes (ownership restructuring and PascalCase call-site updates), and the testing done (warning counts…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two warning types the PR targets, ownership and snake_case warnings in std. The changeset does both: it fixes ownership-checker false positives in webp, anim, csv multirow, and os_bulk, and renames about 307 snake_case std call sites to PascalCase. The title is specific and matches the main change, though it does not name the affected packages.

Full details: Description check

Explanation

The description covers the purpose (W163, W144, W175 warnings from a macOS build), the proposed changes (ownership restructuring and PascalCase call-site updates), and the testing done (warning counts before and after, 240-package import, 981 tests, touched package tests). It does not follow the template headings, and it has no related issue reference and no checklist. Those sections are missing, but the core content is present.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b02b0fb8-3158-416c-8c0b-92f3b10df297
Commits

Reviewing files that changed from the base of the PR and between ce92ace and d788d34.

Files selected for processing: 90

  • std/ai/gguf/gguf_quant.salam
  • std/ai/llm/llm_gguf.salam
  • std/ai/ml/ml_bayes.salam
  • std/ai/ml/ml_discriminant.salam
  • std/ai/onnx/onnx_ops.salam
  • std/ai/onnx/onnx_ops2.salam
  • std/ai/onnx/onnx_run.salam
  • std/chan/chan.salam
  • std/data/data_csv.salam
  • std/data/data_idx.salam
  • std/db/opensearch/os_bulk.salam
  • std/decimal/dec_fmt.salam
  • std/decimal/dec_money.salam
  • std/decimal/dec_round.salam
  • std/encoding/csv/multirow.salam
  • std/encoding/json/marshal.salam
  • std/encoding/protobuf/lexer.salam
  • std/encoding/protobuf/parser.salam
  • std/encoding/protobuf/wire.salam
  • std/excel/csv_bridge.salam
  • std/excel/json_bridge.salam
  • std/excel/meta.salam
  • std/excel/ods_reader.salam
  • std/excel/ods_writer.salam
  • std/excel/sheet.salam
  • std/excel/workbook.salam
  • std/excel/xls.salam
  • std/excel/xlsx_reader.salam
  • std/excel/xlsx_writer.salam
  • std/graph/gr_apsp.salam
  • std/graph/gr_central.salam
  • std/graph/gr_chromatic.salam
  • std/graph/gr_clique.salam
  • std/graph/gr_cluster.salam
  • std/graph/gr_color.salam
  • std/graph/gr_community.salam
  • std/graph/gr_connect.salam
  • std/graph/gr_cut.salam
  • std/graph/gr_dag.salam
  • std/graph/gr_flow.salam
  • std/graph/gr_gen.salam
  • std/graph/gr_io.salam
  • std/graph/gr_iso.salam
  • std/graph/gr_metrics.salam
  • std/graph/gr_mst.salam
  • std/graph/gr_ops.salam
  • std/graph/gr_shortest.salam
  • std/graph/gr_tour.salam
  • std/graph/gr_traverse.salam
  • std/graph/gr_tree.salam
  • std/graph/gr_treeindex.salam
  • std/gui/ui/anim.salam
  • std/image/webp_encode.salam
  • std/image/webp_lossy_encode.salam
  • std/matrix/mat_chol.salam
  • std/matrix/mat_eig.salam
  • std/matrix/mat_eigsym.salam
  • std/matrix/mat_elem.salam
  • std/matrix/mat_func.salam
  • std/matrix/mat_iter.salam
  • std/matrix/mat_lu.salam
  • std/matrix/mat_mul.salam
  • std/matrix/mat_norm.salam
  • std/matrix/mat_pred.salam
  • std/matrix/mat_rref.salam
  • std/matrix/mat_shape.salam
  • std/matrix/mat_stack.salam
  • std/matrix/mat_stats.salam
  • std/matrix/mat_svd.salam
  • std/npy/npy_header.salam
  • std/npy/npy_npz.salam
  • std/opencv/dnn.salam
  • std/opencv/interop.salam
  • std/opencv/mat.salam
  • std/tui/border.salam
  • std/tui/buffer.salam
  • std/tui/button.salam
  • std/tui/checkbox.salam
  • std/tui/event.salam
  • std/tui/focus.salam
  • std/tui/input.salam
  • std/tui/keymap.salam
  • std/tui/list.salam
  • std/tui/modal.salam
  • std/tui/progress.salam
  • std/tui/rect.salam
  • std/tui/screen.salam
  • std/tui/separator.salam
  • std/tui/table.salam
  • std/tui/text.salam

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor
sha=d788d34a9989531d0e1a721d53b114d93c9f7019

🤖 Salam AI review

Verdict: ✅ Good to merge

commit d788d34 · 90 files · +713 −709 · model salam

Summary

This pull request removes stdlib warnings by fixing ownership issues in image/webp, GUI animation, CSV, and OpenSearch code and by renaming 307 internal snake_case call sites to their PascalCase spellings across many std packages. The visible diffs correctly apply the described ownership changes in webp_encode, webp_lossy_encode, multirow, and os_bulk, and they show consistent, mechanical API-name updates in the packages shown. Based on the portions I could review, the change appears correct and focused, although part of the diff was unavailable for inspection.

What changed

  • Ownership fixes in the visible diff match the stated intent: std/image/webp_encode.salam computes codes_out with _wp_codes(lens) before moving lens into lens_out at both call sites; std/image/webp_lossy_encode.salam reads tw.probs after tw.probs = newp; std/encoding/csv/multirow.salam copies header keys for the header row via header.Copy(); and std/db/opensearch/os_bulk.salam reports failures using out.items.Len() after storing the items.
  • W175 cleanup is applied consistently in the shown packages (ai, chan, data, decimal, encoding/json, encoding/protobuf, excel, graph, etc.), renaming internal calls to PascalCase methods such as Count(), WithCode()/Wrap()/Locate(), Sign()/IsZero(), AddEdge()/EdgeFrom()/Adj*(), and sheet/workbook helpers, without altering surrounding logic.

Tests

The PR states that, with a compiler built from main, W175 drops from 307 to 0, W163 from 4 to 0, and W144 from 1 to 0; importing 240 std packages prints no warning; checking 981 existing tests prints no std W14x-W17x warnings; and tests for touched packages match their .out files. I did not run a build or tests.

Risks

  • The provided diff was truncated mid-std/graph/gr_ops.salam, and 42 modified files had no diff shown (including std/gui/ui/anim.salam and all changed files under matrix, npy, opencv, and tui). I could not verify those edits; do they follow the same ownership-fix and PascalCase-rename patterns described?
  • std/encoding/csv/multirow.salam now relies on header.Copy() to duplicate header keys, can you confirm this is the intended copy operation for that value in this context?

⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

@BaseMax
BaseMax merged commit ed4cb80 into main Nov 19, 2026
22 checks passed
@BaseMax
BaseMax deleted the fix/std-ownership-warnings branch November 19, 2026 22:47
BaseMax added a commit that referenced this pull request Nov 20, 2026
…Linux, macOS and Windows (#3698)

* std/os/desktop: check again on Linux, macOS and Windows

Plain imports instead of the removed 'import X as Y', shell.open called as
open, platform chains end in an else arm so no code follows a folded ret,
associations no longer imports os.desktop back, and PrimaryDisplaySummary
uses the display API that exists (PrimaryResolution, Monitors, ScaleFactor).

* std/os/winreg: parse and check on every target

Constants use 'const NAME := value as Type', the link and extern block sits
with the imports, folded Windows branches get an else arm, keys passed by
reference are mut, and KeyExists/ValueExists stop referring to Windows-only
helpers on other systems.

* std/os/service, autostart: fix ordering and platform folds

Private platform helpers now come before the public functions, the Windows
registry externs and constants move up with the imports, the XDG helpers no
longer load on macOS (it also sets SALAM_OS_BSD and got _mkdirs twice), and
the remaining return paths become else arms.

* std: fs/meta, lockfile, updater, diagnostics check on all targets

POSIX fallbacks move into else arms of the Windows branch, lockfile calls
shell.Run directly and parses the pid as int, version parts use AtoiOr, and
reassigned locals are mut.

* examples/native-desktop: platform notes come from os.desktop.capabilities

Platform, RegistryNote, AutoStartNote, ServiceNote, SupportsDragDrop,
DragDropNote and PrintSummary moved out of os.desktop. The winreg example
imports mem and str only on Windows, the drop example builds its handlers
with drop.NewHandlers and dispatches the sample event through them, and
vectors handed to std are no longer freed under the old name.

* examples/native-desktop: drop unused imports, use current std calls

str.Free becomes mem.Free, time.SleepMs becomes time.Sleep, '_ = x' goes,
values passed by reference are mut, and imports that a target never uses
are removed.

* std/os/shell: a command that fails to start returns owned empty output

Run and Exec returned CmdResult with literal "" in out and err when the
process never started, and every caller frees both, so the desktop helpers
aborted with free(): invalid pointer (gui.drag probing for dragon, for one).

* std: settings keeps its keys alive, sysinfo returns owned strings

OrderedMap stores the pointers it is given, so SetSection and Load freed
keys (and loaded values) that the map still used, and section reads fell
back to defaults. Load also freed the literal io.ReadFile returns for a
missing file. sysinfo.OS and Arch passed on platform literals that
GetInfo callers free.

* std/gui/drop: link glib-2.0 on Linux for g_free and g_strfreev

* examples/native-desktop: StorageGet returns a borrowed value, do not free it

* docs/ai: refresh the stdlib index

Picks up the winreg constants, desktop.TrashInfo's open.TrashMetadata, and
three method calls #3692 renamed that the committed index still showed.

* std/fs/meta: run the test/stat/chmod probes through a shell

They use redirections, ';' and '||', which shell.Exec passes to the program
as literal arguments, so CanRead, CanWrite, Mode and ModTime always failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant