Skip to content

refactor(profiling): add explicit casts to avoid narrowing conversions#16571

Draft
KowalskiThomas wants to merge 3 commits intomainfrom
fix/clang-tidy-bugprone-narrowing-conversions
Draft

refactor(profiling): add explicit casts to avoid narrowing conversions#16571
KowalskiThomas wants to merge 3 commits intomainfrom
fix/clang-tidy-bugprone-narrowing-conversions

Conversation

@KowalskiThomas
Copy link
Contributor

Description

https://datadoghq.atlassian.net/browse/PROF-13775

Use explicit static_cast where implicit narrowing conversions occur:

  • danger.cc: Cast page calculations to safe_memcpy_return_t
  • mirrors.cc: Cast table_size calculation to ssize_t
  • greenlets.cc: Cast count to int before adding
  • stack_renderer.cpp: Cast microsecond_t to int64_t for push_* calls
  • vm.cc: Cast size_t to off_t for ftruncate, riovcnt to int for pwritev
  • uploader.cpp: Cast len to std::streamsize for write()
  • frame.cc: Cast offsetof result to int
  • sampler.cpp: Cast uint64_t to double before subtraction

Fixes clang-tidy bugprone-narrowing-conversions warnings.

Use explicit static_cast where implicit narrowing conversions occur:
- danger.cc: Cast page calculations to safe_memcpy_return_t
- mirrors.cc: Cast table_size calculation to ssize_t
- greenlets.cc: Cast count to int before adding
- stack_renderer.cpp: Cast microsecond_t to int64_t for push_* calls
- vm.cc: Cast size_t to off_t for ftruncate, riovcnt to int for pwritev
- uploader.cpp: Cast len to std::streamsize for write()
- frame.cc: Cast offsetof result to int
- sampler.cpp: Cast uint64_t to double before subtraction

Fixes clang-tidy bugprone-narrowing-conversions warnings.
@cit-pr-commenter-54b7da
Copy link

Codeowners resolved as

ddtrace/internal/datadog/profiling/stack/echion/echion/timing.h         @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/include/stack_renderer.hpp     @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/echion/greenlets.cc        @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/echion/mirrors.cc          @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/echion/threads.cc          @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/stack_renderer.cpp         @DataDog/profiling-python

@KowalskiThomas KowalskiThomas changed the title Fix/clang tidy bugprone narrowing conversions refactor(profiling): add explicit casts to avoid narrowing conversions Feb 19, 2026
@KowalskiThomas KowalskiThomas added changelog/no-changelog A changelog entry is not required for this PR. Profiling Continous Profling labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR. Profiling Continous Profling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments