Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
radumarias committed Aug 8, 2024
1 parent c07378b commit acc3616
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.21.2"
zeroize_rs = { version = "1.8.1", package = "zeroize"}
zeroize_rs = { version = "1.8.1", package = "zeroize" }
numpy = "0.21"
memsec = "0.7.0"

[profile.release]
panic = "abort"

[lints.clippy]
too_many_arguments = "allow"
2 changes: 2 additions & 0 deletions examples/lock_and_zeroize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

print("locking memory")


mlock
mlock(arr)
mlock(arr_np)

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ use zeroize_rs::Zeroize;

/// A Python module implemented in Rust.
#[pymodule]
fn zeroize(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
pub fn zeroize(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(zeroize1, m)?)?;
m.add_function(wrap_pyfunction!(mlock, m)?)?;
m.add_function(wrap_pyfunction!(munlock, m)?)?;
Ok(())
}

#[pyfunction]
fn zeroize1(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
pub fn zeroize1(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
as_array_mut(arr, py)?.zeroize();
Ok(())
}

#[pyfunction]
fn mlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
pub fn mlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
let arr = as_array_mut(arr, py)?;
unsafe {
if !_mlock(arr.as_mut_ptr(), arr.len()) {
Expand All @@ -50,7 +50,7 @@ fn mlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
}

#[pyfunction]
fn munlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
pub fn munlock(arr: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> {
let arr = as_array_mut(arr, py)?;
unsafe {
if !_munlock(arr.as_mut_ptr(), arr.len()) {
Expand Down

0 comments on commit acc3616

Please sign in to comment.