[tor-bugs] #28077 [Core Tor/Tor]: remove unsafe block from cstr! macro
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Nov 1 13:50:48 UTC 2018
#28077: remove unsafe block from cstr! macro
--------------------------+------------------------------------
Reporter: cyberpunks | Owner: (none)
Type: defect | Status: needs_review
Priority: Medium | Milestone: Tor: 0.3.6.x-final
Component: Core Tor/Tor | Version: Tor: 0.3.4.1-alpha
Severity: Normal | Resolution:
Keywords: rust | Actual Points:
Parent ID: | Points:
Reviewer: ahf | Sponsor:
--------------------------+------------------------------------
Comment (by ahf):
The way I read the `default()` implementation for `CStr` is that it is:
{{{
#[stable(feature = "cstr_default", since = "1.10.0")]
impl<'a> Default for &'a CStr {
fn default() -> &'a CStr {
const SLICE: &'static [c_char] = &[0];
unsafe { CStr::from_ptr(SLICE.as_ptr()) }
}
}
}}}
Which seems to be what we are doing too, which means that to me it seems
sensible to use the `unwrap_or_default()` method.
Opened a PR to see what Travis says:
https://github.com/torproject/tor/pull/466
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/28077#comment:8>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list