From 7db052d1fdb1a349b0fc306dee005ea7cf334d19 Mon Sep 17 00:00:00 2001 From: James Roome Date: Fri, 2 Oct 2026 14:20:46 +0530 Subject: [PATCH] qodana: treat findings as errors, and fix the one it reports A full scan of main (dispatched run 36986040675; the CLI ran with no diff range) reports one problem in the whole hand-written codebase: IGlobalSession.pinDownstreamCompilersToPayload called equals on DownstreamPath.SEGMENT, which the data-flow analysis cannot prove non-null (it held MemorySegment.NULL as a "no payload" sentinel via Optional.orElse). The field now holds null for that case and the method null-checks it, which says the same thing without the sentinel. qodana.yaml gains a quality gate (failureConditions.severityThresholds.any: 0), so any finding fails the Qodana job instead of leaving a neutral check. PR and push runs analyse only changed files, so this gates new findings; a dispatched run still covers everything. Tested: :slang:test 43/43 against the 2026.19 macos-aarch64 payload, which takes the payload-directory path through the changed method. Co-Authored-By: Claude Opus 5.5 --- qodana.yaml | 6 ++++++ .../github/refux/slang/ffi/IGlobalSession.java | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/qodana.yaml b/qodana.yaml index c32ef54..c22a5cc 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -12,6 +12,12 @@ linter: jetbrains/qodana-jvm-community:2026.1 profile: name: qodana.recommended +# Warnings are errors: any finding fails the run (and so the check). On PRs and pushes the action +# analyses only the changed files, so this gates new findings; a dispatched run scans everything. +failureConditions: + severityThresholds: + any: 0 + # Generated code is emitted clean and is not hand-maintained; exclude it from findings. exclude: - name: All diff --git a/slang/src/main/java/io/github/refux/slang/ffi/IGlobalSession.java b/slang/src/main/java/io/github/refux/slang/ffi/IGlobalSession.java index 69fd5a5..7078219 100644 --- a/slang/src/main/java/io/github/refux/slang/ffi/IGlobalSession.java +++ b/slang/src/main/java/io/github/refux/slang/ffi/IGlobalSession.java @@ -38,16 +38,16 @@ public static IGlobalSession create() { } /** - * The payload directory as a native string, allocated once per process, or {@link - * MemorySegment#NULL} when the library came from the platform's search path. Held globally - * because Slang's lifetime contract for the string handed to {@code setDownstreamCompilerPath} - * is not documented, so it must outlive the call. + * The payload directory as a native string, allocated once per process, or {@code null} when + * the library came from the platform's search path. Held globally because Slang's lifetime + * contract for the string handed to {@code setDownstreamCompilerPath} is not documented, so it + * must outlive the call. */ private static final class DownstreamPath { static final MemorySegment SEGMENT = SlangLibrary.get() .directory() .map(dir -> Arena.global().allocateFrom(dir.toString())) - .orElse(MemorySegment.NULL); + .orElse(null); } /** @@ -65,7 +65,8 @@ private static final class DownstreamPath { * the same pinning {@link SlangLibrary}'s class-path case already promises. */ private void pinDownstreamCompilersToPayload() { - if (DownstreamPath.SEGMENT.equals(MemorySegment.NULL)) { + MemorySegment payloadDir = DownstreamPath.SEGMENT; + if (payloadDir == null) { return; // Loaded off the platform search path; the host's own search order applies. } for (int passThrough : new int[] { @@ -73,8 +74,7 @@ private void pinDownstreamCompilersToPayload() { SlangPassThrough.SLANG_PASS_THROUGH_SPIRV_DIS, SlangPassThrough.SLANG_PASS_THROUGH_SPIRV_OPT }) { - io.github.refux.slang.ffi.gen.IGlobalSession.setDownstreamCompilerPath( - segment(), passThrough, DownstreamPath.SEGMENT); + io.github.refux.slang.ffi.gen.IGlobalSession.setDownstreamCompilerPath(segment(), passThrough, payloadDir); } }