Skip to content

Convert global std::string to constexpr const char*#563

Open
gaul wants to merge 1 commit intointel:thermald_nextfrom
gaul:error-prone/throwing-static-init
Open

Convert global std::string to constexpr const char*#563
gaul wants to merge 1 commit intointel:thermald_nextfrom
gaul:error-prone/throwing-static-init

Conversation

@gaul
Copy link
Copy Markdown
Contributor

@gaul gaul commented May 6, 2026

Found via bugprone-throwing-static-initialization.

Found via bugprone-throwing-static-initialization.

Signed-off-by: Andrew Gaul <andrew@gaul.org>
@gaul gaul force-pushed the error-prone/throwing-static-init branch from cd63cfd to 81c3971 Compare May 6, 2026 00:13
@spandruvada spandruvada requested a review from Copilot May 7, 2026 17:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a static constexpr const char*[] in the Intel platform check.
  • Removed the cthd_cdev_backlight static std::string member declaration and replaced the implementation with a file-local static constexpr const char*[] device path list.
  • Replaced a preprocessor macro (#define MAX_BACKLIGHT_DEV) with a static 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.

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.

2 participants