Skip to content

Commit 60b4e6a

Browse files
committed
fix clippy warning
Signed-off-by: MorningTZH <morningtzh@yeah.net> (cherry picked from commit aa882d1)
1 parent 4365a1e commit 60b4e6a

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

runc/src/sandbox.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,19 @@ impl Sandboxer for RuncSandboxer {
165165
let mut sandbox = sandbox.lock().await;
166166
let mut sandbox_parent = self.sandbox_parent.lock().await;
167167
let sandbox_pid = sandbox_parent.fork_sandbox_process(id, &sandbox.data.netns)?;
168-
sandbox.prepare_sandbox_ns(sandbox_pid).await.map_err(|e| {
169-
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
170-
e
171-
})?;
168+
sandbox
169+
.prepare_sandbox_ns(sandbox_pid)
170+
.await
171+
.inspect_err(|_| {
172+
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
173+
})?;
172174

173175
sandbox
174176
.data
175177
.task_address
176178
.clone_from(&format!("ttrpc+{}", self.task_address));
177-
sandbox.dump().await.map_err(|e| {
179+
sandbox.dump().await.inspect_err(|_| {
178180
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
179-
e
180181
})?;
181182
Ok(())
182183
}

vmm/common/build.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
use std::fs;
18+
1719
use ttrpc_codegen::{Codegen, Customize, ProtobufCustomize};
1820

1921
fn main() {
@@ -45,4 +47,24 @@ fn main() {
4547
)
4648
.run()
4749
.expect("Gen protos code failed");
50+
51+
// Protobuf-rust 3.5.1 no longer generates the `#![allow(box_pointers)]` lint.
52+
// However, ttrpc-rust has not yet upgraded to protobuf-rust 3.5.1.
53+
// As a temporary measure, we are modifying the files to suppress the warning.
54+
remove_box_pointers("src/api").expect("Remove api box_pointer failed");
55+
}
56+
57+
fn remove_box_pointers(dir: &str) -> std::io::Result<()> {
58+
for entry in fs::read_dir(dir)? {
59+
let entry = entry?;
60+
let path = entry.path();
61+
62+
if path.is_file() {
63+
let content = fs::read_to_string(&path)?;
64+
let new_content = content.replace("#![allow(box_pointers)]", "");
65+
66+
fs::write(path, new_content)?;
67+
}
68+
}
69+
Ok(())
4870
}

0 commit comments

Comments
 (0)