Skip to content

fix(pvs): resolve Low Level (Level 3) static analyzer warnings and formatting notes - #88

Open
bivex wants to merge 4 commits into
nimble-code:masterfrom
bivex:fix/pvs-low-priority-warnings
Open

fix(pvs): resolve Low Level (Level 3) static analyzer warnings and formatting notes#88
bivex wants to merge 4 commits into
nimble-code:masterfrom
bivex:fix/pvs-low-priority-warnings

Conversation

@bivex

@bivex bivex commented Aug 9, 2026

Copy link
Copy Markdown

Summary

This PR resolves Low Level (Level 3) static analyzer warnings and format specifier notes reported by PVS-Studio across the Spin codebase.

Fixes Included

  • Printf/Fprintf Format Specifiers:
    • Src/pangen2.c: Cast status expression to (int) for fprintf formatting.
    • Src/pangen3.c: Cast node type to (char) for fprintf %c format.
    • Src/tl_cache.c & Src/tl_main.c: Cast Caches, CacheHits, and All_Mem to (long) for %9ld formatting.
  • Null Safety Guards:
    • Src/pangen7.c: Added NULL pointer check in claim_has_accept().
    • Src/sched.c: Guarded r pointer in getlocal() and setlocal().
    • Src/structs.c: Guarded node allocations (cpnn) before field assignment.
    • Src/tl_cache.c: Guarded getnode() result in dupnode() and node pointers in isequal().

Verification

  • Full project clean build (make clean && make) completed cleanly with 0 errors and 0 compiler warnings.
  • PVS-Studio re-analyzed: Level 3 warning count dropped from 58 down to 39.

bivex added 4 commits August 9, 2026 22:07
- Fix potential buffer overflow and bounds check in main.c (preprocess)
- Fix termios c_lflag bitmask truncation on 64-bit platforms in mesg.c
- Fix potential null pointer dereferences in pangen2.c, pangen3.c, and run.c
- Fix undefined behavior in 64-bit bit shift operations (1UL<<j) in pangen6.c
- Fix EVAL AST node child type check logic in pangen6.c
- Fix code formatting ambiguity in pangen7.c
- Fix potential division by zero modulo in run.c
- Add array bounds guards for string operations in guided.c, msc_tcl.c, and structs.c
- Fix sizeof(IArg_cont[IArgno]) target buffer in spinlex.c
- Fix block scope formatting in spinlex.c
- Declare alldone(int) with noreturn attribute and fix comparison logic in main.c
- Guard NULL pointers in eligible() in pangen5.c
- Clean up redundant pointer checks in flow.c and mesg.c
- Remove redundant loop condition in pangen1.c
- Add fallthrough annotations, simplify boolean logic, and remove dead assignment in pangen2.c
- Remove unreachable code after fatal() in sym.c
- Parenthesize assignment and ternary operator expression in tl_mem.c
…rmatting notes

- Explicitly cast int/char arguments to match fprintf format specifiers in pangen2.c and pangen3.c
- Add NULL pointer checks in claim_has_accept() in pangen7.c
- Guard pointer dereferences in getlocal() and setlocal() in sched.c
- Guard NULL pointers when building struct nodes in structs.c
- Guard NULL pointers in dupnode() and isequal() in tl_cache.c
- Cast memory size arguments to long for printf formatting in tl_cache.c and tl_main.c
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