From a3c4efc13aac027b98c5fa055554eacf96e3b3a9 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sat, 8 Jun 2024 08:38:11 +0300 Subject: [PATCH] Random code cleanups --- core/pager.rs | 6 ++++++ core/schema.rs | 2 +- sqlite3/include/sqlite3.h | 2 +- sqlite3/src/lib.rs | 7 +++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/pager.rs b/core/pager.rs index 907b65dd4..3665eba67 100644 --- a/core/pager.rs +++ b/core/pager.rs @@ -21,6 +21,12 @@ const PAGE_LOCKED: usize = 0b010; /// Page had an I/O error. const PAGE_ERROR: usize = 0b100; +impl Default for Page { + fn default() -> Self { + Self::new() + } +} + impl Page { pub fn new() -> Page { Page { diff --git a/core/schema.rs b/core/schema.rs index 438a9eefd..1e88f77c7 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -20,7 +20,7 @@ impl Schema { } pub fn add_table(&mut self, name: &str, table: Table) { - let name = normalize_ident(&name); + let name = normalize_ident(name); self.tables.insert(name, table); } diff --git a/sqlite3/include/sqlite3.h b/sqlite3/include/sqlite3.h index 9e0913f40..192a56614 100644 --- a/sqlite3/include/sqlite3.h +++ b/sqlite3/include/sqlite3.h @@ -29,7 +29,7 @@ int sqlite3_open(const char *filename, sqlite3 **db_out); int sqlite3_close(sqlite3 *db); -int sqlite3_prepare_v2(sqlite3 *db, const char *sql, int len, sqlite3_stmt **out_stmt, const char **tail); +int sqlite3_prepare_v2(sqlite3 *db, const char *sql, int _len, sqlite3_stmt **out_stmt, const char **_tail); int sqlite3_finalize(sqlite3_stmt *stmt); diff --git a/sqlite3/src/lib.rs b/sqlite3/src/lib.rs index f31e52347..7e2665789 100644 --- a/sqlite3/src/lib.rs +++ b/sqlite3/src/lib.rs @@ -2,7 +2,6 @@ use std::cell::RefCell; use std::ffi; -use std::ffi::CString; use std::rc::Rc; pub const SQLITE_OK: ffi::c_int = 0; @@ -62,7 +61,7 @@ pub unsafe extern "C" fn sqlite3_open( *db_out = Box::leak(Box::new(sqlite3::new(db, conn))); SQLITE_OK } - Err(e) => SQLITE_NOTFOUND, + Err(_e) => SQLITE_NOTFOUND, } } @@ -79,9 +78,9 @@ pub unsafe extern "C" fn sqlite3_close(db: *mut sqlite3) -> ffi::c_int { pub unsafe extern "C" fn sqlite3_prepare_v2( db: *mut sqlite3, sql: *const ffi::c_char, - len: ffi::c_int, + _len: ffi::c_int, out_stmt: *mut *mut sqlite3_stmt, - tail: *mut *const ffi::c_char, + _tail: *mut *const ffi::c_char, ) -> ffi::c_int { if db.is_null() || sql.is_null() || out_stmt.is_null() { return SQLITE_MISUSE;