Repository navigation
std: fix the ownership and snake_case warnings std prints in user builds - #3692
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
sha=d788d34a9989531d0e1a721d53b114d93c9f7019
🤖 Salam AI reviewVerdict: ✅ Good to merge commit SummaryThis 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 What changed
TestsThe 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 Risks
|
…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.
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):
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