-
Notifications
You must be signed in to change notification settings - Fork 2k
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
core: Express -1 as ~0 in thread_status_t cast #19976
core: Express -1 as ~0 in thread_status_t cast #19976
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tempting as it would be to start asking different C compilers for their interpretation of the relevant rules on whether the cast is OK, let's be pragmatic. (That also extends to drilling down how that worked earlier and doesn't now: I'm doing a bit of that, but there is no outcome that'd make this patch less valid).
Thanks for the fix, ACK.
As it's probably hard to spot: The CI is unhappy with your commit message, as it says "fix:" (which it interprets like git's "fixup!" convention); a coding style compliant message could be "core: Express -1 as ~0 in thread_status_t cast" (The first word indicates the core area). By the way, that means I'll need a 2nd ACK, because it is touching core. |
Out of curiosity on the drilling down side: What's the exact setup you used, like, which version of LLVM, and which version of c2rust? I've tested various more recent versions of c2rust (its 0.18 and its HEAD) with LLVM-15, and neither of them showed me this as an issue while building the riot-wrappers tests. |
My c2rust version is: C2Rust unknown (0ba4903f3 2023-09-18) dirty 1 modification Should I make a new commit with a new message? (I was normally using conventional commit style for them, hence the fix) It has to do something with the device because for other boards, it builds perfectly fine |
That'd be extremely weird ... can you try the same test on your machine with
Yes, please
Yeah ... it's one of those things that seem to catch on just because someone picked a very presumptuous name for it :-/ |
1c0d510
to
d778e2e
Compare
Okay, interestingly the error appears on both boards only when building with our own branches https://github.com/ATACAMA-Project/rust-riot-sys/tree/NOG and https://github.com/ATACAMA-Project/rust-riot-wrappers/tree/7-nanocoap_sock-wrapper |
Thx, the change IMO even makes the code more readable. |
bors merge |
Build failed:
|
#19978 should fix the static test failure. It is a pity that the version of |
bors merge |
For documentation purposes: pub const STATUS_NOT_FOUND: libc::c_int = -(1 as libc::c_int);
pub const unsafe fn macro_STATUS_NOT_FOUND() -> thread_status_t {
let mut result: thread_status_t = STATUS_NOT_FOUND as thread_status_t;
return result;
} which successful compiles, this: pub const unsafe fn macro_STATUS_NOT_FOUND() -> thread_status_t {
let mut result: thread_status_t = -1 as thread_status_t;
return result;
} was generated |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
When compiling rust-hello-world for the nrf52840dongle, c2rust seem to generate code which casts -1 to u8 which fails because it's unsigned. Changing to ~0 fixes this.
Contribution description
Change
-1
to~0
for casting tou8
Testing procedure
Issues/PRs references
make BOARD=nrf52840dongle
in rust-hello-world