Fix clippy warnings and Cargo.lock
This fixes:
* version mismatches in Cargo.lock
* style issues
* implementations of Into that should be From
* deprecated protobuf APIs
It also adds RUST_BACKTRACE=1 to the kokoro tests.
BUG=None
TEST=./bin/preupload-clippy
Change-Id: I8e9157c903f2080a5fdcc4d3e4ed72fbad41c64f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3024427
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
diff --git a/Cargo.lock b/Cargo.lock
index bb1f45d..f906645 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -92,9 +92,9 @@
[[package]]
name = "autocfg"
-version = "0.1.7"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
+checksum = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
[[package]]
name = "autocfg"
@@ -207,7 +207,7 @@
name = "cros_fuzz"
version = "0.1.0"
dependencies = [
- "rand_core 0.4.2",
+ "rand_core 0.4.0",
]
[[package]]
@@ -404,9 +404,9 @@
[[package]]
name = "futures"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987"
+checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
dependencies = [
"futures-channel",
"futures-core",
@@ -418,9 +418,9 @@
[[package]]
name = "futures-channel"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86"
+checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
dependencies = [
"futures-core",
"futures-sink",
@@ -428,33 +428,33 @@
[[package]]
name = "futures-core"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866"
+checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
[[package]]
name = "futures-io"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff"
+checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
[[package]]
name = "futures-sink"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16"
+checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3"
[[package]]
name = "futures-task"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9"
+checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
[[package]]
name = "futures-util"
-version = "0.3.1"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76"
+checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
dependencies = [
"futures-channel",
"futures-core",
@@ -462,6 +462,7 @@
"futures-sink",
"futures-task",
"memchr",
+ "pin-project-lite",
"pin-utils",
"slab",
]
@@ -481,20 +482,20 @@
[[package]]
name = "getopts"
-version = "0.2.18"
+version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
+checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]]
name = "getrandom"
-version = "0.2.3"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
+checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if 0.1.10",
"libc",
"wasi",
]
@@ -512,6 +513,15 @@
]
[[package]]
+name = "hermit-abi"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "hypervisor"
version = "0.1.0"
dependencies = [
@@ -606,9 +616,9 @@
[[package]]
name = "libc"
-version = "0.2.93"
+version = "0.2.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
+checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
[[package]]
name = "libcras"
@@ -659,11 +669,11 @@
[[package]]
name = "log"
-version = "0.4.5"
+version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
+checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
]
[[package]]
@@ -674,9 +684,9 @@
[[package]]
name = "memchr"
-version = "2.3.0"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
+checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "memoffset"
@@ -733,10 +743,11 @@
[[package]]
name = "num_cpus"
-version = "1.9.0"
+version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238"
+checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
+ "hermit-abi",
"libc",
]
@@ -762,10 +773,16 @@
checksum = "ba7ae1a2180ed02ddfdb5ab70c70d596a26dd642e097bb6fe78b1bde8588ed97"
[[package]]
-name = "pin-utils"
-version = "0.1.0-alpha.4"
+name = "pin-project-lite"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
+checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
@@ -794,42 +811,43 @@
[[package]]
name = "proc-macro2"
-version = "1.0.24"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
dependencies = [
"unicode-xid",
]
[[package]]
name = "protobuf"
-version = "2.8.1"
+version = "2.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20"
+checksum = "db50e77ae196458ccd3dc58a31ea1a90b0698ab1b7928d89f644c25d72070267"
[[package]]
name = "protobuf-codegen"
-version = "2.8.1"
+version = "2.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a"
+checksum = "09321cef9bee9ddd36884f97b7f7cc92a586cdc74205c4b3aeba65b5fc9c6f90"
dependencies = [
"protobuf",
]
[[package]]
name = "protoc"
-version = "2.8.1"
+version = "2.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea"
+checksum = "c367feabb5f78ca3b2ec25e2c4a5f4f0826017d7fb634f52961afd1a6613d1fb"
dependencies = [
"log",
+ "which",
]
[[package]]
name = "protoc-rust"
-version = "2.8.1"
+version = "2.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "234c97039c32bb58a883d0deafa57db37e59428ce536f3bdfe1c46cffec04113"
+checksum = "7bb2c1038f8014a2e42fdffec03ffc03f574a8bf66b0ac32f1b6941681eb1317"
dependencies = [
"protobuf",
"protobuf-codegen",
@@ -858,9 +876,9 @@
[[package]]
name = "quote"
-version = "1.0.2"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
+checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
"proc-macro2",
]
@@ -871,10 +889,10 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
dependencies = [
- "autocfg 0.1.7",
+ "autocfg 0.1.2",
"libc",
"rand_chacha",
- "rand_core 0.4.2",
+ "rand_core 0.4.0",
"rand_hc",
"rand_isaac",
"rand_jitter",
@@ -890,7 +908,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
dependencies = [
- "autocfg 0.1.7",
+ "autocfg 0.1.2",
"rand_core 0.3.1",
]
@@ -900,14 +918,14 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
- "rand_core 0.4.2",
+ "rand_core 0.4.0",
]
[[package]]
name = "rand_core"
-version = "0.4.2"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
+checksum = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
[[package]]
name = "rand_hc"
@@ -933,25 +951,25 @@
[[package]]
name = "rand_jitter"
-version = "0.1.4"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
+checksum = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832"
dependencies = [
"libc",
- "rand_core 0.4.2",
+ "rand_core 0.4.0",
"winapi",
]
[[package]]
name = "rand_os"
-version = "0.1.3"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
+checksum = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d"
dependencies = [
"cloudabi",
"fuchsia-cprng",
"libc",
- "rand_core 0.4.2",
+ "rand_core 0.4.0",
"rdrand",
"winapi",
]
@@ -962,8 +980,8 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.4.2",
+ "autocfg 0.1.2",
+ "rand_core 0.4.0",
]
[[package]]
@@ -1022,18 +1040,18 @@
[[package]]
name = "serde"
-version = "1.0.121"
+version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6159e3c76cab06f6bc466244d43b35e77e9500cd685da87620addadc2a4c40b1"
+checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.121"
+version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3fcab8778dc651bc65cfab2e4eb64996f3c912b74002fb379c94517e1f27c46"
+checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
dependencies = [
"proc-macro2",
"quote",
@@ -1053,9 +1071,9 @@
[[package]]
name = "slab"
-version = "0.4.2"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
+checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527"
[[package]]
name = "smallvec"
@@ -1065,9 +1083,9 @@
[[package]]
name = "syn"
-version = "1.0.58"
+version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5"
+checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
dependencies = [
"proc-macro2",
"quote",
@@ -1137,15 +1155,15 @@
[[package]]
name = "unicode-width"
-version = "0.1.5"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
-version = "0.2.0"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "usb_sys"
@@ -1267,9 +1285,19 @@
[[package]]
name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+
+[[package]]
+name = "which"
+version = "4.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef"
+dependencies = [
+ "libc",
+ "thiserror",
+]
[[package]]
name = "winapi"
diff --git a/base/src/ioctl.rs b/base/src/ioctl.rs
index 307d5d9..d5a91fc 100644
--- a/base/src/ioctl.rs
+++ b/base/src/ioctl.rs
@@ -6,16 +6,22 @@
use std::os::raw::{c_int, c_ulong, c_void};
/// Run an ioctl with no arguments.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl<F: AsRawDescriptor>(descriptor: &F, nr: IoctlNr) -> c_int {
libc::ioctl(descriptor.as_raw_descriptor(), nr, 0)
}
/// Run an ioctl with a single value argument.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl_with_val(descriptor: &dyn AsRawDescriptor, nr: IoctlNr, arg: c_ulong) -> c_int {
libc::ioctl(descriptor.as_raw_descriptor(), nr, arg)
}
/// Run an ioctl with an immutable reference.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl_with_ref<T>(descriptor: &dyn AsRawDescriptor, nr: IoctlNr, arg: &T) -> c_int {
libc::ioctl(
descriptor.as_raw_descriptor(),
@@ -25,6 +31,8 @@
}
/// Run an ioctl with a mutable reference.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl_with_mut_ref<T>(
descriptor: &dyn AsRawDescriptor,
nr: IoctlNr,
@@ -38,6 +46,8 @@
}
/// Run an ioctl with a raw pointer.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl_with_ptr<T>(
descriptor: &dyn AsRawDescriptor,
nr: IoctlNr,
@@ -47,6 +57,8 @@
}
/// Run an ioctl with a mutable raw pointer.
+/// # Safety
+/// The caller is responsible for determining the safety of the particular ioctl.
pub unsafe fn ioctl_with_mut_ptr<T>(
descriptor: &dyn AsRawDescriptor,
nr: IoctlNr,
diff --git a/base/src/mmap.rs b/base/src/mmap.rs
index d2bd4cb..16444fb 100644
--- a/base/src/mmap.rs
+++ b/base/src/mmap.rs
@@ -74,6 +74,7 @@
}
pub trait MemoryMappingBuilderUnix<'a> {
+ #[allow(clippy::wrong_self_convention)]
fn from_descriptor(self, descriptor: &'a dyn AsRawDescriptor) -> MemoryMappingBuilder;
}
@@ -89,6 +90,7 @@
/// Build the memory mapping given the specified descriptor to mapped memory
///
/// Default: Create a new memory mapping.
+ #[allow(clippy::wrong_self_convention)]
fn from_descriptor(mut self, descriptor: &'a dyn AsRawDescriptor) -> MemoryMappingBuilder {
self.descriptor = Some(descriptor);
self
@@ -114,7 +116,7 @@
///
/// Note: this is a forward looking interface to accomodate platforms that
/// require special handling for file backed mappings.
- #[allow(unused_mut)]
+ #[allow(clippy::wrong_self_convention, unused_mut)]
pub fn from_file(mut self, file: &'a File) -> MemoryMappingBuilder {
self.descriptor = Some(file as &dyn AsRawDescriptor);
self
diff --git a/base/src/shm.rs b/base/src/shm.rs
index a445f3d..eb4da79 100644
--- a/base/src/shm.rs
+++ b/base/src/shm.rs
@@ -87,9 +87,9 @@
}
}
-impl Into<SafeDescriptor> for SharedMemory {
- fn into(self) -> SafeDescriptor {
+impl From<SharedMemory> for SafeDescriptor {
+ fn from(sm: SharedMemory) -> SafeDescriptor {
// Safe because we own the SharedMemory at this point.
- unsafe { SafeDescriptor::from_raw_descriptor(self.into_raw_descriptor()) }
+ unsafe { SafeDescriptor::from_raw_descriptor(sm.into_raw_descriptor()) }
}
}
diff --git a/base/src/tube.rs b/base/src/tube.rs
index 675089f..613731b 100644
--- a/base/src/tube.rs
+++ b/base/src/tube.rs
@@ -150,9 +150,9 @@
}
}
-impl Into<Tube> for AsyncTube {
- fn into(self) -> Tube {
- self.inner.into_source()
+impl From<AsyncTube> for Tube {
+ fn from(at: AsyncTube) -> Tube {
+ at.inner.into_source()
}
}
diff --git a/ci/test_runner.py b/ci/test_runner.py
index 1207207..85bdc78 100644
--- a/ci/test_runner.py
+++ b/ci/test_runner.py
@@ -620,6 +620,8 @@
print("--require-all needs to be run with --use-vm or --run-privileged")
exit(1)
+ os.environ["RUST_BACKTRACE"] = "1"
+
execute_tests(
crate_requirements,
feature_requirements,
diff --git a/cros_async/src/queue.rs b/cros_async/src/queue.rs
index 3192703..f95de06 100644
--- a/cros_async/src/queue.rs
+++ b/cros_async/src/queue.rs
@@ -38,6 +38,12 @@
}
}
+impl Default for RunnableQueue {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl<'q> IntoIterator for &'q RunnableQueue {
type Item = Runnable;
type IntoIter = RunnableQueueIter<'q>;
diff --git a/crosvm_plugin/src/lib.rs b/crosvm_plugin/src/lib.rs
index 86827a6..e0fb2f1 100644
--- a/crosvm_plugin/src/lib.rs
+++ b/crosvm_plugin/src/lib.rs
@@ -31,7 +31,7 @@
use libc::{E2BIG, EINVAL, ENOENT, ENOTCONN, EPROTO};
-use protobuf::{parse_from_bytes, Message, ProtobufEnum, RepeatedField};
+use protobuf::{Message, ProtobufEnum, RepeatedField};
use base::ScmSocket;
@@ -308,8 +308,8 @@
.map(|&fd| unsafe { File::from_raw_fd(fd) })
.collect();
- let response: MainResponse =
- parse_from_bytes(&self.response_buffer[..msg_size]).map_err(proto_error_to_int)?;
+ let response: MainResponse = Message::parse_from_bytes(&self.response_buffer[..msg_size])
+ .map_err(proto_error_to_int)?;
if response.errno != 0 {
return Err(response.errno);
}
@@ -1070,7 +1070,7 @@
if bytes == 0 || total_size > self.response_length {
return Err(EINVAL);
}
- let response: VcpuResponse = parse_from_bytes(
+ let response: VcpuResponse = Message::parse_from_bytes(
&self.response_buffer[self.response_base + bytes..self.response_base + total_size],
)
.map_err(proto_error_to_int)?;
diff --git a/disk/src/composite.rs b/disk/src/composite.rs
index 5b88caa..3938d1b 100644
--- a/disk/src/composite.rs
+++ b/disk/src/composite.rs
@@ -185,7 +185,7 @@
return Err(Error::InvalidMagicHeader);
}
let proto: cdisk_spec::CompositeDisk =
- protobuf::parse_from_reader(&mut file).map_err(Error::InvalidProto)?;
+ Message::parse_from_reader(&mut file).map_err(Error::InvalidProto)?;
if proto.get_version() != COMPOSITE_DISK_VERSION {
return Err(Error::UnknownVersion(proto.get_version()));
}
diff --git a/io_uring/src/uring.rs b/io_uring/src/uring.rs
index 724b79e..3a516a5 100644
--- a/io_uring/src/uring.rs
+++ b/io_uring/src/uring.rs
@@ -310,6 +310,7 @@
.add_rw_op(ptr, len, fd, offset, user_data, IORING_OP_READV as u8)
}
+ /// # Safety
/// See 'writev' but accepts an iterator instead of a vector if there isn't already a vector in
/// existence.
pub unsafe fn add_writev_iter<I>(
@@ -368,6 +369,7 @@
Ok(())
}
+ /// # Safety
/// See 'readv' but accepts an iterator instead of a vector if there isn't already a vector in
/// existence.
pub unsafe fn add_readv_iter<I>(
diff --git a/power_monitor/build.rs b/power_monitor/build.rs
index b925c28..174389d 100644
--- a/power_monitor/build.rs
+++ b/power_monitor/build.rs
@@ -31,13 +31,12 @@
let input_files = [power_manager_dir.join("power_supply_properties.proto")];
let include_dirs = [power_manager_dir];
- protoc_rust::run(protoc_rust::Args {
- out_dir: out_dir.as_os_str().to_str().unwrap(),
- input: &paths_to_strs(&input_files),
- includes: &paths_to_strs(&include_dirs),
- customize: Default::default(),
- })
- .expect("protoc");
+ protoc_rust::Codegen::new()
+ .inputs(&paths_to_strs(&input_files))
+ .includes(&paths_to_strs(&include_dirs))
+ .out_dir(out_dir.as_os_str().to_str().unwrap())
+ .run()
+ .expect("protoc");
let mut path_include_mods = String::new();
for input_file in input_files.iter() {
diff --git a/protos/build.rs b/protos/build.rs
index 2e870b4..e28936a 100644
--- a/protos/build.rs
+++ b/protos/build.rs
@@ -92,12 +92,12 @@
fs::create_dir_all(&out_dir)?;
// Invoke protobuf compiler.
- protoc_rust::run(protoc_rust::Args {
- out_dir: &out_dir,
- includes: &[input_dir.as_os_str().to_str().unwrap()],
- input: &[input_path.as_os_str().to_str().unwrap()],
- ..Default::default()
- })?;
+ protoc_rust::Codegen::new()
+ .input(input_path.as_os_str().to_str().unwrap())
+ .include(input_dir.as_os_str().to_str().unwrap())
+ .out_dir(&out_dir)
+ .run()
+ .expect("protoc");
// Write out a `mod` that refers to the generated module.
//
diff --git a/src/plugin/process.rs b/src/plugin/process.rs
index c34b708..833616e 100644
--- a/src/plugin/process.rs
+++ b/src/plugin/process.rs
@@ -521,7 +521,7 @@
return Err(Error::PluginSocketHup);
}
- let request = protobuf::parse_from_bytes::<MainRequest>(&self.request_buffer[..msg_size])
+ let request: MainRequest = Message::parse_from_bytes(&self.request_buffer[..msg_size])
.map_err(Error::DecodeRequest)?;
/// Use this to make it easier to stuff various kinds of File-like objects into the
diff --git a/src/plugin/vcpu.rs b/src/plugin/vcpu.rs
index d874f64..c5c93f7 100644
--- a/src/plugin/vcpu.rs
+++ b/src/plugin/vcpu.rs
@@ -13,7 +13,7 @@
use libc::{EINVAL, ENOENT, ENOTTY, EPERM, EPIPE, EPROTO};
-use protobuf::Message;
+use protobuf::{CodedOutputStream, Message};
use assertions::const_assert;
use base::{error, LayoutAllocation};
@@ -23,7 +23,6 @@
kvm_debugregs, kvm_enable_cap, kvm_fpu, kvm_lapic_state, kvm_mp_state, kvm_msr_entry, kvm_msrs,
kvm_regs, kvm_sregs, kvm_vcpu_events, kvm_xcrs, KVM_CPUID_FLAG_SIGNIFCANT_INDEX,
};
-use protobuf::CodedOutputStream;
use protos::plugin::*;
use sync::Mutex;
@@ -592,9 +591,8 @@
let mut read_pipe = &self.read_pipe;
let msg_size = read_pipe.read(&mut request_buffer).map_err(io_to_sys_err)?;
- let mut request =
- protobuf::parse_from_bytes::<VcpuRequest>(&request_buffer[..msg_size])
- .map_err(proto_to_sys_err)?;
+ let mut request: VcpuRequest =
+ Message::parse_from_bytes(&request_buffer[..msg_size]).map_err(proto_to_sys_err)?;
let res = if request.has_wait() {
match wait_reason {
diff --git a/sys_util/src/sched.rs b/sys_util/src/sched.rs
index d9972c6..2a44ab8 100644
--- a/sys_util/src/sched.rs
+++ b/sys_util/src/sched.rs
@@ -72,7 +72,7 @@
const PR_SCHED_CORE: i32 = 62;
const PR_SCHED_CORE_CREATE: i32 = 1;
- #[allow(non_camel_case_types, dead_code)]
+ #[allow(clippy::upper_case_acronyms, non_camel_case_types, dead_code)]
/// Specifies the scope of the pid parameter of `PR_SCHED_CORE`.
enum pid_type {
/// `PID` refers to threads.