Skip to content

Commit

Permalink
Fixes unsafe_op_in_unsafe_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Feb 20, 2025
1 parent 10d6cb1 commit 376745c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/connection/_notice_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ impl Connection {
proc: NoticeProcessor,
arg: *mut raw::c_void,
) -> NoticeProcessor {
pq_sys::PQsetNoticeProcessor(self.into(), proc, arg)
unsafe {
pq_sys::PQsetNoticeProcessor(self.into(), proc, arg)
}
}

/**
Expand All @@ -25,6 +27,8 @@ impl Connection {
proc: NoticeReceiver,
arg: *mut raw::c_void,
) -> NoticeReceiver {
pq_sys::PQsetNoticeReceiver(self.into(), proc, arg)
unsafe {
pq_sys::PQsetNoticeReceiver(self.into(), proc, arg)
}
}
}
8 changes: 6 additions & 2 deletions src/connection/_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ impl Connection {
pub unsafe fn ssl_struct(&self, struct_name: &str) -> *const std::ffi::c_void {
let c_struct_name = crate::ffi::to_cstr(struct_name);

pq_sys::PQsslStruct(self.into(), c_struct_name.as_ptr())
unsafe {
pq_sys::PQsslStruct(self.into(), c_struct_name.as_ptr())
}
}

/**
Expand All @@ -269,6 +271,8 @@ impl Connection {
* This function returns a `void*` pointer.
*/
pub unsafe fn ssl(&self) -> *const std::ffi::c_void {
pq_sys::PQgetssl(self.into())
unsafe {
pq_sys::PQgetssl(self.into())
}
}
}
2 changes: 1 addition & 1 deletion src/connection/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ impl PqString {
* [`Connection::client_encoding`](crate::Connection::client_encoding).
*/
pub unsafe fn to_str_unchecked(&self) -> &str {
std::str::from_utf8_unchecked(self.as_ref())
unsafe { std::str::from_utf8_unchecked(self.as_ref()) }
}
}
2 changes: 1 addition & 1 deletion src/result/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl PQResult {
* This function return a `void*` pointer.
*/
pub unsafe fn alloc(&mut self, nbytes: usize) -> crate::errors::Result<*mut core::ffi::c_void> {
let space = pq_sys::PQresultAlloc(self.into(), nbytes);
let space = unsafe { pq_sys::PQresultAlloc(self.into(), nbytes) };

if space.is_null() {
Err(crate::errors::Error::Unknow)
Expand Down

0 comments on commit 376745c

Please sign in to comment.