Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: pointer and signal handler casts#12488

Open
xtqqczze wants to merge 1 commit intofish-shell:masterfrom
xtqqczze:fix-ptr
Open

fix: pointer and signal handler casts#12488
xtqqczze wants to merge 1 commit intofish-shell:masterfrom
xtqqczze:fix-ptr

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Feb 26, 2026

  • avoid UB from usize → pointer cast
  • use correct type for sa_sigaction

See also: rust-lang/libc#4918

- avoid UB from `usize` → pointer cast
- use correct type for `sa_sigaction`
@xtqqczze xtqqczze marked this pull request as ready for review February 26, 2026 21:53
assert_fmt!("%p", 0xDEADBEEF_usize as *const u8 => "0xdeadbeef");
assert_fmt!("%p", core::ptr::null::<()>() => "0");

let tmp = core::ptr::without_provenance::<()>(0xDEADBEEF);
Copy link
Contributor Author

@xtqqczze xtqqczze Feb 26, 2026

Choose a reason for hiding this comment

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

This temporary is necessary, otherwise it is error[E0716]: temporary value dropped while borrowed

In theory, we could refactor the assert_fmt macro to handle temporary lifetime extension.

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.

1 participant