Convert global std::string to constexpr const char*#563
Closed
gaul wants to merge 15 commits into
Closed
Conversation
This avoids unneeded system calls. Signed-off-by: Andrew Gaul <andrew@gaul.org>
Use O_NOFOLLOW to avoid symbolic links. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
The loop had no termination condition, so when no trip point of the requested type existed, the unsigned index underflowed past 0 to UINT_MAX and the loop read trip_points out of bounds indefinitely. Bound the loop with j >= 0 so it exits cleanly when no match is found. Signed-off-by: Andrew Gaul <andrew@gaul.org> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrew Gaul <andrew@gaul.org>
When in the config directory the file "thermald-features.xml" is present, it gives ability to disable some features. Currently it allows DbusControl XMLThermalConfig DataVaultFromFileSystem KobjectUeventSupport When 0 that feature is disabled. If the file is absent all features are enabled. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Use feature configs to enable/disable a feature. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
thd_sys_fs.cpp:203:4: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] 203 | ret = -EIO; Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Use O_NOFOLLOW when opening lock file. Also replace std::ofstream fout with open with O_NOFOLLOW. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Read one less than size of string via pread and foce NULL characted at the last character. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
No need for static for pref_str. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Move to TDRUNDIR instead of /tmp. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Although data vault source is BIOS, check for buffer overflows. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Add get_string_obj() which checks for bounds in GDDV. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
When reading from file system use sysfs class, so that all file operations uses same method. Signed-off-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Found via bugprone-throwing-static-initialization. Signed-off-by: Andrew Gaul <andrew@gaul.org>
cd63cfd to
81c3971
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes non-trivially-initialized global/static std::string storage (flagged by bugprone-throwing-static-initialization) by switching to compile-time string literals (constexpr const char*) for fixed sysfs path lists.
Changes:
- Replaced
std::vector<std::string>blocklist paths with astatic constexpr const char*[]in the Intel platform check. - Removed the
cthd_cdev_backlightstaticstd::stringmember declaration and replaced the implementation with a file-localstatic constexpr const char*[]device path list. - Replaced a preprocessor macro (
#define MAX_BACKLIGHT_DEV) with astatic constexpr int.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/thd_platform_intel.cpp |
Uses a constexpr string-literal array for platform blocklist paths, avoiding static std::string initialization. |
src/thd_cdev_backlight.h |
Removes the static std::string member declaration that required static initialization. |
src/thd_cdev_backlight.cpp |
Defines backlight device paths as a file-local constexpr array and replaces the macro with constexpr. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eb61654 to
d23e243
Compare
Contributor
|
Merged, Closed. |
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.
Found via bugprone-throwing-static-initialization.