Skip to content

Cleanup warnings by scanBuild#444

Draft
zhengyu123 wants to merge 12 commits intomainfrom
zgu/cleanup-scanbuild
Draft

Cleanup warnings by scanBuild#444
zhengyu123 wants to merge 12 commits intomainfrom
zgu/cleanup-scanbuild

Conversation

@zhengyu123
Copy link
Copy Markdown
Contributor

@zhengyu123 zhengyu123 commented Mar 26, 2026

What does this PR do?:

This PR is a scan-build (static analysis) warning cleanup. The changes span 29 files and fall into these categories:

Signed/unsigned comparison fixes (most of the work)

  • Loop variables changed from int to size_t where iterating over std::vector / array sizes (flightRecorder.cpp, symbols_linux.cpp, livenessTracker.cpp, codeCache.cpp,
    reservoirSampler.h)
  • Mixed signed/unsigned comparisons cast explicitly: size_t(r), (uint32_t), (int)sizeof(...), etc. (os_linux.cpp, perfEvents_linux.cpp, libraries.h, vmStructs.cpp)

Constructor initializer list ordering (fixes warnings about out-of-order init)

  • Profiler, PidController, BaseWallClock, CallTraceHashTable, Arguments constructors reordered to match declaration order

Type correctness

  • VMStructs::_tls_index changed from int to pthread_key_t (vmStructs.h/cpp)
  • FrameDesc::cfa changed from int to u32 (dwarf.h)
  • HeapUsage::_maxSize comparison uses size_t(-1) instead of -1

ODR / linkage fixes (functions defined in headers)

  • static → inline for jniExceptionCheck, convertJvmExecutionState, cpuHasGoodTimestampCounter
  • static Context DD_EMPTY_CONTEXT moved from header to .cpp to avoid multiple-definition issues

Dead code removal

  • Removed unused orig_trapHandler, range_for_fbase(), _min(), and blank private: section

Minor fixes

  • javaApi.cpp: dumpContext guarded with #ifdef DEBUG, format specifiers corrected (%llu for u64)
  • Makefile: -DEBUG → -DDEBUG (was a typo — the define was never actually set)
  • Whitespace/indentation cleanup in several files

Motivation:
Code cleanup and improve maintainability.

Additional Notes:

How to test the change?:

  • CI tests

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-14135

Unsure? Have a question? Request a review!

@dd-octo-sts
Copy link
Copy Markdown

dd-octo-sts bot commented Mar 26, 2026

CI Test Results

Run: #23666468155 | Commit: 50184bb | Duration: 19m 38s (longest job)

10 of 32 test jobs failed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Failed Tests

musl-aarch64/debug / 21-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-amd64/debug / 17-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 8-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-amd64/debug / 25-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 17-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 25-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-amd64/debug / 21-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-amd64/debug / 8-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 11-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-amd64/debug / 11-librca

Job: View logs

No detailed failure information available. Check the job logs.

Summary: Total: 32 | Passed: 22 | Failed: 10


Updated: 2026-03-27 21:01:25 UTC

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 26, 2026

Integration Tests

All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 24d08a10

@zhengyu123 zhengyu123 changed the title Zgu/cleanup scanbuild WIP: Cleanup warnings by scanBuild Mar 27, 2026
@zhengyu123 zhengyu123 changed the title WIP: Cleanup warnings by scanBuild Cleanup warnings by scanBuild Mar 27, 2026
@zhengyu123 zhengyu123 marked this pull request as ready for review March 27, 2026 14:17
@zhengyu123 zhengyu123 requested a review from a team as a code owner March 27, 2026 14:17
@zhengyu123 zhengyu123 marked this pull request as draft March 27, 2026 22:04
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