Skip to content

fix(pvs): resolve all High Level (Level 1) static analyzer warnings - #86

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

fix(pvs): resolve all High Level (Level 1) static analyzer warnings#86
bivex wants to merge 2 commits into
nimble-code:masterfrom
bivex:fix/pvs-high-priority-warnings

Conversation

@bivex

@bivex bivex commented Aug 9, 2026

Copy link
Copy Markdown

Summary

This PR resolves all High Level (Level 1) static analyzer warnings reported by PVS-Studio in the Spin C codebase.

Fixes Included

  • .gitignore: Added ignores for PVS-Studio log/report files and compile_commands.json.
  • Src/main.c: Fixed buffer overflow bounds check during PreArg concatenation in preprocess() and removed impossible post-hoc strlen check.
  • Src/mesg.c: Added (tcflag_t) casts to ~ICANON, ~ECHO, and ~ISIG in peek_ch_init() to prevent 64-bit mask truncation.
  • Src/pangen2.c & Src/pangen3.c: Added null guards for now->lft before dereferencing sym.
  • Src/pangen3.c: Removed redundant if (now->ntyp == PRINT) inside case PRINT:.
  • Src/pangen6.c: Fixed AST node child type check logic for EVAL cases (v->lft->lft->ntyp == ',') and updated 32-bit integer shifts (1 << j) to 64-bit unsigned long shifts (1UL << j) in bitmask operations.
  • Src/pangen7.c: Cleaned up else if formatting to remove ambiguity.
  • Src/run.c: Added zero guard for modulo operation (Rand() % j) and null guard for e->sub in case UNLESS:.

Verification

  • Full project clean build (make clean && make) completed with zero errors.
  • Re-analyzed with PVS-Studio to verify all High Level code warnings are resolved.

bivex added 2 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
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