Skip to content

Fix static analysis issues found by cppcheck#8

Merged
vbp1 merged 3 commits intomasterfrom
fix/linter-sourced
Dec 15, 2025
Merged

Fix static analysis issues found by cppcheck#8
vbp1 merged 3 commits intomasterfrom
fix/linter-sourced

Conversation

@vbp1
Copy link
Copy Markdown
Owner

@vbp1 vbp1 commented Dec 14, 2025

Summary

  • Fix uninitialized variable rc in archive.c when compression is requested but zlib is not available
  • Fix resource leaks in data.c by adding fclose(in) before early return statements in validate_file_pages()
  • Replace unsafe realloc() with pgut_realloc() in file.c to prevent memory leaks on allocation failure
  • Remove dead stores in validate.c and initialize base_full_backup to NULL
  • Configure cppcheck to suppress false positives on PostgreSQL macros (unknownMacro)

vbp1 added 2 commits December 14, 2025 19:04
- archive.c: Fix uninitialized variable 'rc' when compression is
  requested but HAVE_LIBZ is not defined. Add proper error handling
  for this case.

- data.c: Fix resource leaks in validate_file_pages() by adding
  fclose(in) before all early return statements.

- file.c: Replace unsafe realloc() calls with pgut_realloc() which
  properly handles allocation failures and prevents memory leaks.

- validate.c: Remove dead stores to base_full_backup variable and
  initialize it to NULL to avoid uninitialized variable warnings.

- lint.yml: Add --suppress=unknownMacro to cppcheck to suppress
  false positives on PostgreSQL format macros (UINT64_FORMAT,
  INT64_FORMAT, pg_attribute_printf).
Clang Static Analyzer produces too many false positive warnings:
- Cannot track NULL checks across function calls
- Reports issues in PostgreSQL symlinked files (xlogreader.c, receivelog.c)
- No simple way to suppress individual warnings inline

cppcheck provides sufficient static analysis coverage for C code
with better configurability and fewer false positives.
@vbp1 vbp1 changed the title Fix static analysis issues found by cppcheck and clang-analyzer Fix static analysis issues found by cppcheck Dec 14, 2025
Add append-timestamp: false to ccache-action configuration.
Without this, each CI run creates a new cache with a timestamp suffix,
leading to dozens of duplicate caches (~60MB each) instead of reusing
the existing one.
@vbp1 vbp1 merged commit 1483049 into master Dec 15, 2025
12 of 22 checks passed
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