Skip to content

Commit 8c8b12a

Browse files
Gnurouvireshk
authored andcommitted
rust: cpufreq: always inline functions using build_assert with arguments
`build_assert` relies on the compiler to optimize out its error path. Functions using it with its arguments must thus always be inlined, otherwise the error path of `build_assert` might not be optimized out, triggering a build error. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 7e3debb commit 8c8b12a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

rust/kernel/cpufreq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,8 @@ impl<T: Driver> Registration<T> {
10151015
..pin_init::zeroed()
10161016
};
10171017

1018+
// Always inline to optimize out error path of `build_assert`.
1019+
#[inline(always)]
10181020
const fn copy_name(name: &'static CStr) -> [c_char; CPUFREQ_NAME_LEN] {
10191021
let src = name.to_bytes_with_nul();
10201022
let mut dst = [0; CPUFREQ_NAME_LEN];

0 commit comments

Comments
 (0)