Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scx_lavd: use c_char consistently #246

Merged
merged 1 commit into from
Apr 27, 2024
Merged

scx_lavd: use c_char consistently #246

merged 1 commit into from
Apr 27, 2024

Conversation

arighi
Copy link
Contributor

@arighi arighi commented Apr 27, 2024

In Rust c_char can be aliased to i8 or u8, depending on the particular target architecture.

For example, trying to build scx_lavd on ppc64 triggers the following error:

error[E0308]: mismatched types
--> src/main.rs:200:38
|
200 | let c_tx_cm: *const c_char = (&tx.comm as *const [i8; 17]) as *const i8;
| ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected *const u8, found *const i8
| |
| expected due to this
|
= note: expected raw pointer *const u8
found raw pointer *const i8

To fix this, consistently use c_char instead of assuming it corresponds to i8.

In Rust c_char can be aliased to i8 or u8, depending on the particular
target architecture.

For example, trying to build scx_lavd on ppc64 triggers the following
error:

error[E0308]: mismatched types
   --> src/main.rs:200:38
    |
200 |         let c_tx_cm: *const c_char = (&tx.comm as *const [i8; 17]) as *const i8;
    |                      -------------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |                      |
    |                      expected due to this
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`

To fix this, consistently use c_char instead of assuming it corresponds
to i8.

Signed-off-by: Andrea Righi <[email protected]>
@arighi arighi requested a review from multics69 April 27, 2024 15:29
Copy link
Contributor

@multics69 multics69 left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for trying lavd on PPC64.

@multics69 multics69 merged commit 0495a52 into main Apr 27, 2024
1 check passed
@multics69 multics69 deleted the lavd-fix-arch-build branch April 27, 2024 15:49
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