Fix up conventions around unsafe in internal functions

This commit is contained in:
Thom Chiovoloni
2020-04-06 19:38:33 -07:00
parent c0df911946
commit 53c99f940e
7 changed files with 46 additions and 46 deletions

View File

@@ -53,10 +53,10 @@ unsafe extern "C" fn unlock_notify_cb(ap_arg: *mut *mut c_void, n_arg: c_int) {
}
#[cfg(feature = "unlock_notify")]
pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
pub unsafe fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
rc == ffi::SQLITE_LOCKED_SHAREDCACHE
|| (rc & 0xFF) == ffi::SQLITE_LOCKED
&& unsafe { ffi::sqlite3_extended_errcode(db) } == ffi::SQLITE_LOCKED_SHAREDCACHE
&& ffi::sqlite3_extended_errcode(db) == ffi::SQLITE_LOCKED_SHAREDCACHE
}
/// This function assumes that an SQLite API call (either `sqlite3_prepare_v2()`
@@ -72,16 +72,14 @@ pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
/// this case the caller should not retry the operation and should roll
/// back the current transaction (if any).
#[cfg(feature = "unlock_notify")]
pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
pub unsafe fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
let mut un = UnlockNotification::new();
/* Register for an unlock-notify callback. */
let rc = unsafe {
ffi::sqlite3_unlock_notify(
db,
Some(unlock_notify_cb),
&mut un as *mut UnlockNotification as *mut c_void,
)
};
let rc = ffi::sqlite3_unlock_notify(
db,
Some(unlock_notify_cb),
&mut un as *mut UnlockNotification as *mut c_void,
);
debug_assert!(
rc == ffi::SQLITE_LOCKED || rc == ffi::SQLITE_LOCKED_SHAREDCACHE || rc == ffi::SQLITE_OK
);
@@ -92,12 +90,12 @@ pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
}
#[cfg(not(feature = "unlock_notify"))]
pub fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool {
pub unsafe fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool {
unreachable!()
}
#[cfg(not(feature = "unlock_notify"))]
pub fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int {
pub unsafe fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int {
unreachable!()
}