[CODE HEALTH] Qualify C library calls with std:: after modernize-deprecated-headers - #4356
Open
om7057 wants to merge 3 commits into
Open
[CODE HEALTH] Qualify C library calls with std:: after modernize-deprecated-headers#4356om7057 wants to merge 3 commits into
om7057 wants to merge 3 commits into
Conversation
Follow-up to open-telemetry#4349: swapping deprecated C headers for their C++ equivalents left the underlying calls unqualified (memcpy, strcmp, isspace, strtod, snprintf, strftime, etc.), relying on most implementations also exposing these names in the global namespace, which isn't guaranteed by the standard. Adds std:: to call sites for the functions covered by <cstring>, <cctype>, <cstdlib>, <cstdio>, and <ctime>, plus the FILE and tm types, across api, sdk, exporters, ext, examples, and functional. Leaves already ::-qualified call sites, vendored code (absl, TraceLoggingDynamic.h), and platform-specific functions (gmtime_r/gmtime_s, strtok_s/strtok_r) untouched. Fixes open-telemetry#4354
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4356 +/- ##
==========================================
+ Coverage 80.86% 80.86% +0.01%
==========================================
Files 450 450
Lines 19216 19230 +14
==========================================
+ Hits 15537 15549 +12
- Misses 3679 3681 +2
🚀 New features to boost your workflow:
|
instrument_metadata_validator.cc only calls isalpha/isalnum in the !OPENTELEMETRY_HAVE_WORKING_REGEX fallback path, so an unconditional <cctype> include is unused whenever the regex path is taken, which is what IWYU's zero-warning CI jobs flagged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4354
Changes
Follow-up to #4349. Swapping deprecated C headers for their C++ equivalents left the underlying library calls unqualified (
memcpy,strcmp,isspace,strtod,snprintf,strftime, etc.), relying on most implementations also exposing these names in the global namespace, which the standard does not guarantee.Adds
std::to call sites for the functions covered by<cstring>,<cctype>,<cstdlib>,<cstdio>, and<ctime>, plus theFILEandtmtypes, acrossapi,sdk,exporters,ext,examples, andfunctional. Also adds a couple of#includes that were missing and relied on transitive inclusion.Left untouched, per review feedback on #4349:
api/include/opentelemetry/nostd/internal/absl,exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h)::(explicit global scope), since that looked like a deliberate choice rather than an oversightstd::form (gmtime_r/gmtime_s,strtok_s/strtok_r)Test plan
cmake --build .) withBUILD_TESTING,WITH_EXAMPLES,WITH_FUNC_TESTS,WITH_OTLP_FILE,WITH_OTLP_HTTP,WITH_CONFIGURATION, andWITH_EXAMPLES_HTTPenabled, 0 errors, 0 warnings.cteston both configs, 796/796 and 1233/1237 passed (the 4 failures wereext.http.curltiming tests that are flaky under parallel load in this environment; all pass at-j1).