Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions smoke/src/exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ impl Db {
let c_name = CString::new(name).unwrap();
let mut handle = std::ptr::null_mut();
let flags = ffi::SQLITE_OPEN_READWRITE | ffi::SQLITE_OPEN_CREATE;
// `c_name` outlives the call, and SQLite copies it.
// SAFETY: `c_name` is live and NUL-terminated, and `handle` is writable for the call.
let rc = unsafe {
ffi::sqlite3_open_v2(c_name.as_ptr(), &raw mut handle, flags, std::ptr::null())
ffi::sqlite3_open_v2(
c_name.as_ptr(),
std::ptr::addr_of_mut!(handle),
flags,
std::ptr::null(),
)
};
let db = Self(handle, name.to_owned());
assert_eq!(rc, ffi::SQLITE_OK, "{name}: {}", db.error());
Expand Down Expand Up @@ -79,13 +84,13 @@ impl Db {
pub fn text(&self, sql: &str) -> String {
let c_sql = CString::new(sql).unwrap();
let mut stmt = std::ptr::null_mut();
// `c_sql` outlives the call, which reads it up to its NUL.
// SAFETY: The connection is live, `c_sql` is NUL-terminated, and `stmt` is writable for the call.
let rc = unsafe {
ffi::sqlite3_prepare_v2(
self.0,
c_sql.as_ptr(),
-1,
&raw mut stmt,
std::ptr::addr_of_mut!(stmt),
std::ptr::null_mut(),
)
};
Expand Down
15 changes: 15 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,20 @@ sqlite-wasm-vfs = { version = "0.3", features = ["sahpool"] }
sqlite3mc-src = { path = ".." }
wasm-bindgen-test = "0.3"

[lints.rust]
missing_docs = "forbid"
rust_2018_idioms = { level = "warn", priority = -1 }
unreachable_pub = "warn"
unsafe_op_in_unsafe_fn = "deny"
unused_unsafe = "warn"

[lints.clippy]
all = { level = "deny", priority = -1 }
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }
allow_attributes = "deny"
allow_attributes_without_reason = "deny"

# Standalone, so the root crate never adopts it as a member.
[workspace]
8 changes: 7 additions & 1 deletion wasm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ fn main() {
})
.collect();
files.sort();
let mut table = String::from("pub const NATIVE_FILES: &[(&str, &[u8])] = &[\n");
let mut table = String::from(
"/// Native encrypted fixtures embedded for interop.\npub const NATIVE_FILES: &[(&str, &[u8])] = &[\n",
);
for path in files {
let name = path.file_name().unwrap().to_string_lossy().into_owned();
#[expect(
clippy::unnecessary_debug_formatting,
reason = "Debug formatting emits a quoted and escaped Rust path literal"
)]
writeln!(
table,
"({name:?}, include_bytes!({:?})),",
Expand Down
Loading