Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove null pointer check in favour of assert
Browse files Browse the repository at this point in the history
urschrei committed Aug 16, 2021

Verified

This commit was signed with the committer’s verified signature.
oliviertassinari Olivier Tassinari
1 parent dbb86b4 commit 3b57482
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/proj.rs
Original file line number Diff line number Diff line change
@@ -94,8 +94,6 @@ pub enum ProjError {
HeaderConversion(#[from] reqwest::header::ToStrError),
#[error("A {0} error occurred for url {1} after {2} retries")]
DownloadError(String, String, u8),
#[error("Got a null pointer while attempting to build an error String")]
NullPointer
}

/// The bounding box of an area of use
@@ -127,15 +125,13 @@ impl Area {

/// Easily get a String from the external library
pub(crate) unsafe fn _string(raw_ptr: *const c_char) -> Result<String, ProjError> {
if raw_ptr.is_null() {
return Err(ProjError::NullPointer);
}
let c_str = CStr::from_ptr(raw_ptr);
Ok(str::from_utf8(c_str.to_bytes())?.to_string())
}

/// Look up an error message using the error code
fn error_message(code: c_int) -> Result<String, ProjError> {
assert_ne!(code, 0);
unsafe {
let rv = proj_errno_string(code);
_string(rv)

0 comments on commit 3b57482

Please sign in to comment.