Skip to content

Commit

Permalink
fix clippy warning
Browse files Browse the repository at this point in the history
Signed-off-by: MorningTZH <[email protected]>
  • Loading branch information
morningtzh committed Jan 9, 2025
1 parent 27e131a commit aa882d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
13 changes: 7 additions & 6 deletions runc/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,19 @@ impl Sandboxer for RuncSandboxer {
let mut sandbox = sandbox.lock().await;
let mut sandbox_parent = self.sandbox_parent.lock().await;
let sandbox_pid = sandbox_parent.fork_sandbox_process(id, &sandbox.data.netns)?;
sandbox.prepare_sandbox_ns(sandbox_pid).await.map_err(|e| {
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
e
})?;
sandbox
.prepare_sandbox_ns(sandbox_pid)
.await
.inspect_err(|_| {
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
})?;

sandbox
.data
.task_address
.clone_from(&format!("ttrpc+{}", self.task_address));
sandbox.dump().await.map_err(|e| {
sandbox.dump().await.inspect_err(|_| {
kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default();
e
})?;
Ok(())
}
Expand Down
22 changes: 22 additions & 0 deletions vmm/common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use std::fs;

use ttrpc_codegen::{Codegen, Customize, ProtobufCustomize};

fn main() {
Expand Down Expand Up @@ -45,4 +47,24 @@ fn main() {
)
.run()
.expect("Gen protos code failed");

// Protobuf-rust 3.5.1 no longer generates the `#![allow(box_pointers)]` lint.
// However, ttrpc-rust has not yet upgraded to protobuf-rust 3.5.1.
// As a temporary measure, we are modifying the files to suppress the warning.
remove_box_pointers("src/api").expect("Remove api box_pointer failed");
}

fn remove_box_pointers(dir: &str) -> std::io::Result<()> {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();

if path.is_file() {
let content = fs::read_to_string(&path)?;
let new_content = content.replace("#![allow(box_pointers)]", "");

fs::write(path, new_content)?;
}
}
Ok(())
}

0 comments on commit aa882d1

Please sign in to comment.