chore: fix some clippy warnings

This commit is contained in:
Nathan Fiedler
2023-09-17 14:45:35 -07:00
parent ce0792f27b
commit ef1867e9f9
3 changed files with 12 additions and 12 deletions

View File

@ -14,7 +14,7 @@ build = "build.rs"
libc = "0.2"
[build-dependencies]
bindgen = "0.66.1"
bindgen = "0.68.1"
pkg-config = "0.3"
[features]

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 Nathan Fiedler
* Copyright 2023 Nathan Fiedler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,8 +36,8 @@ pub const PATH_SEPARATOR: &str = match cfg!(target_os = "windows") {
fn main() {
let check_cppflags = Command::new("MagickCore-config").arg("--cppflags").output();
if check_cppflags.is_ok() {
let cppflags = check_cppflags.unwrap().stdout;
if let Ok(ok_cppflags) = check_cppflags {
let cppflags = ok_cppflags.stdout;
let cppflags = String::from_utf8(cppflags).unwrap();
env_var_set_default("BINDGEN_EXTRA_CLANG_ARGS", &cppflags);
}
@ -147,9 +147,9 @@ fn main() {
// Work around the include! issue in rustc (as described in the
// rust-bindgen README file) by wrapping the generated code in a
// `pub mod` declaration; see issue #359 in (old) rust-bindgen.
file.write(b"pub mod bindings {\n").unwrap();
file.write(bindings.to_string().as_bytes()).unwrap();
file.write(b"\n}").unwrap();
file.write_all(b"pub mod bindings {\n").unwrap();
file.write_all(bindings.to_string().as_bytes()).unwrap();
file.write_all(b"\n}").unwrap();
std::fs::remove_file(&gen_h_path).expect("could not remove header file");
}

View File

@ -487,12 +487,12 @@ impl MagickWand {
/// Retrieve the width of the image.
pub fn get_image_width(&self) -> usize {
unsafe { bindings::MagickGetImageWidth(self.wand) as usize }
unsafe { bindings::MagickGetImageWidth(self.wand) }
}
/// Retrieve the height of the image.
pub fn get_image_height(&self) -> usize {
unsafe { bindings::MagickGetImageHeight(self.wand) as usize }
unsafe { bindings::MagickGetImageHeight(self.wand) }
}
/// Retrieve the page geometry (width, height, x offset, y offset) of the image.
@ -695,9 +695,9 @@ impl MagickWand {
let c_map = CString::new(map).unwrap();
let capacity = width * height * map.len();
let mut pixels = Vec::with_capacity(capacity);
pixels.resize(capacity, 0);
unsafe {
pixels.set_len(capacity as usize);
if bindings::MagickExportImagePixels(
self.wand,
x,
@ -868,8 +868,8 @@ impl MagickWand {
Err(MagickError("failed to write image blob"))
} else {
let mut bytes = Vec::with_capacity(length as usize);
bytes.resize(length, 0);
unsafe {
bytes.set_len(length as usize);
ptr::copy_nonoverlapping(blob, bytes.as_mut_ptr(), length as usize);
bindings::MagickRelinquishMemory(blob as *mut c_void);
};
@ -890,8 +890,8 @@ impl MagickWand {
bindings::MagickGetImagesBlob(self.wand, &mut length)
};
let mut bytes = Vec::with_capacity(length as usize);
bytes.resize(length, 0);
unsafe {
bytes.set_len(length as usize);
ptr::copy_nonoverlapping(blob, bytes.as_mut_ptr(), length as usize);
bindings::MagickRelinquishMemory(blob as *mut c_void);
};