Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-agent: Many warnings during compilation #750

Closed
c3d opened this issue Sep 17, 2020 · 4 comments · Fixed by #794 or #795
Closed

rust-agent: Many warnings during compilation #750

c3d opened this issue Sep 17, 2020 · 4 comments · Fixed by #794 or #795
Assignees
Labels
bug Incorrect behaviour needs-review Needs to be assessed by the team.

Comments

@c3d
Copy link
Member

c3d commented Sep 17, 2020

Description of problem

While compiling the rust agent, many warnings pop up. These warnings get in the way of quickly getting to actual compilation errors when you have any.

Expected result

No warnings.

Actual result

(restricted to warnings showing up in our source):

warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/oci/src/serialize.rs:34:35
   |
34 |             Error::Io(ref e) => e.description(),
   |                                   ^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/oci/src/serialize.rs:35:37
   |
35 |             Error::Json(ref e) => e.description(),
   |                                     ^^^^^^^^^^^

warning: 2 warnings emitted

   Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
warning: associated function is never used: `set_level`
   --> /home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging/src/lib.rs:186:8
    |
186 |     fn set_level(&self, level: slog::Level) {
    |        ^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

     Running `rustc --crate-name rustjail --edition=2018 /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=31c27457d38c0752 -C extra-filename=-31c27457d38c0752 --out-dir /home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps -C incremental=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/incremental -L dependency=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps --extern anyhow=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libanyhow-ab4c6bcf6d16a025.rmeta --extern caps=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libcaps-78ae8450335aa681.rmeta --extern dirs=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libdirs-fdd9aac88451d525.rmeta --extern lazy_static=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liblazy_static-5146de7e1f59d989.rmeta --extern libc=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liblibc-9e9801c44bd85ecd.rmeta --extern nix=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libnix-8afa0965a461e128.rmeta --extern oci=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liboci-e0e70f2b9b41f350.rmeta --extern path_absolutize=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libpath_absolutize-9c9e2e82fc0b0302.rmeta --extern prctl=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libprctl-4d3a7b71ce5c9f8b.rmeta --extern protobuf=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libprotobuf-d347a5b2385f2760.rmeta --extern protocols=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libprotocols-2ab1bfd4da2d338b.rmeta --extern regex=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libregex-5016e06096453526.rmeta --extern scan_fmt=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libscan_fmt-f532b5b703be89dd.rmeta --extern scopeguard=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libscopeguard-d1df215033422841.rmeta --extern serde=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libserde-307865b050215c25.rmeta --extern serde_derive=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libserde_derive-b20663dfbc8dc569.so --extern serde_json=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libserde_json-c973bb472f334106.rmeta --extern slog=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libslog-114df4cb391d5cdd.rmeta --extern slog_scope=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libslog_scope-8295617ee90f7d77.rmeta`
warning: unused `#[macro_use]` import
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:15:1
   |
15 | #[macro_use]
   | ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused macro definition
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:38:1
   |
38 | / macro_rules! sl {
39 | |     () => {
40 | |         slog_scope::logger().new(o!("subsystem" => "rustjail"))
41 | |     };
42 | | }
   | |_^
   |
   = note: `#[warn(unused_macros)]` on by default

warning: unused import: `debug`
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:57:12
   |
57 | use slog::{debug, info, o, Logger};
   |            ^^^^^

warning: unused imports: `AddressFamily`, `SockFlag`, `SockType`, `self`
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/process.rs:18:24
   |
18 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
   |                        ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^

warning: unused import: `nix::Error`
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/process.rs:23:5
   |
23 | use nix::Error;
   |     ^^^^^^^^^^

warning: unused import: `protobuf::RepeatedField`
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/validator.rs:11:5
   |
11 | use protobuf::RepeatedField;
   |     ^^^^^^^^^^^^^^^^^^^^^^^

warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
    --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:1598:31
     |
1598 | ...                   e.description(),
     |                         ^^^^^^^^^^^
     |
     = note: `#[warn(deprecated)]` on by default

warning: unused variable: `e`
    --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/cgroups/fs/mod.rs:1310:21
     |
1310 |                 Err(e) => {
     |                     ^ help: if this is intentional, prefix it with an underscore: `_e`
     |
     = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `logger`
    --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:1049:22
     |
1049 | fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
     |                      ^^^^^^ help: if this is intentional, prefix it with an underscore: `_logger`

warning: unused variable: `child`
    --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:1128:5
     |
1128 |     child: &mut Child,
     |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_child`

warning: value assigned to `child_stdin` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:807:13
    |
807 |         let mut child_stdin = std::process::Stdio::null();
    |             ^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_assignments)]` on by default
    = help: maybe it is overwritten before being read?

warning: value assigned to `child_stdout` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:808:13
    |
808 |         let mut child_stdout = std::process::Stdio::null();
    |             ^^^^^^^^^^^^^^^^
    |
    = help: maybe it is overwritten before being read?

warning: value assigned to `child_stderr` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:809:13
    |
809 |         let mut child_stderr = std::process::Stdio::null();
    |             ^^^^^^^^^^^^^^^^
    |
    = help: maybe it is overwritten before being read?

warning: value assigned to `stdin` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:810:13
    |
810 |         let mut stdin = -1;
    |             ^^^^^^^^^
    |
    = help: maybe it is overwritten before being read?

warning: value assigned to `stdout` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:811:13
    |
811 |         let mut stdout = -1;
    |             ^^^^^^^^^^
    |
    = help: maybe it is overwritten before being read?

warning: value assigned to `stderr` is never read
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:812:13
    |
812 |         let mut stderr = -1;
    |             ^^^^^^^^^^
    |
    = help: maybe it is overwritten before being read?

warning: variable does not need to be mutable
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:369:9
    |
369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
    |         ----^^^^^^^^^^^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: the type `oci::User` does not permit zero-initialization
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:99:18
   |
99 |         unsafe { MaybeUninit::zeroed().assume_init() }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                  |
   |                  this code causes undefined behavior when executed
   |                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
   |
   = note: `#[warn(invalid_value)]` on by default
note: `std::ptr::Unique<u32>` must be non-null (in this struct field)

warning: the type `protocols::oci::Process` does not permit zero-initialization
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:146:14
    |
146 |     unsafe { MaybeUninit::zeroed().assume_init() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              this code causes undefined behavior when executed
    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
note: `std::ptr::Unique<std::string::String>` must be non-null (in this struct field)

warning: the type `protocols::oci::Root` does not permit zero-initialization
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:157:14
    |
157 |     unsafe { MaybeUninit::zeroed().assume_init() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              this code causes undefined behavior when executed
    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
note: `std::ptr::Unique<u8>` must be non-null (in this struct field)

warning: the type `protocols::oci::Mount` does not permit zero-initialization
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:170:14
    |
170 |     unsafe { MaybeUninit::zeroed().assume_init() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              this code causes undefined behavior when executed
    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
note: `std::ptr::Unique<u8>` must be non-null (in this struct field)

warning: the type `protocols::oci::Hooks` does not permit zero-initialization
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:204:14
    |
204 |     unsafe { MaybeUninit::zeroed().assume_init() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              this code causes undefined behavior when executed
    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
note: `std::ptr::Unique<protocols::oci::Hook>` must be non-null (in this struct field)

warning: the type `protocols::oci::Spec` does not permit zero-initialization
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/lib.rs:574:14
    |
574 |     unsafe { MaybeUninit::zeroed().assume_init() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              this code causes undefined behavior when executed
    |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
note: `std::ptr::Unique<u8>` must be non-null (in this struct field)

warning: unused `std::result::Result` that must be used
  --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
   |
26 |         write_count(lfd, log_str.as_bytes(), log_str.len());
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | 
  ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/capabilities.rs:88:13
   |
88 |             log_child!(cfd_log, "{} is not a cap", cap);
   |             -------------------------------------------- in this macro invocation
   |
   = note: `#[warn(unused_must_use)]` on by default
   = note: this `Result` may be an `Err` variant, which should be handled
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/capabilities.rs:134:9
    |
134 |         log_child!(cfd_log, "failed to set ambient capability");
    |         -------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:339:13
    |
339 |             log_child!(cfd_log, "child exit: {:?}", e);
    |             ------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:340:13
    |
340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:359:5
    |
359 |     log_child!(cfd_log, "child process start run");
    |     ----------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:364:5
    |
364 |     log_child!(cfd_log, "notify parent to send oci process");
    |     --------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:370:5
    |
370 |     log_child!(cfd_log, "notify parent to send cgroup manager");
    |     ------------------------------------------------------------ in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |           write_count(lfd, log_str.as_bytes(), log_str.len());
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:411:21
    |
411 | /                     log_child!(
412 | |                         cfd_log,
413 | |                         "cannot open type: {} path: {}",
414 | |                         ns.r#type.clone(),
415 | |                         ns.path.clone()
416 | |                     );
    | |______________________- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:417:21
    |
417 |                     log_child!(cfd_log, "error is : {}", e.as_errno().unwrap().desc());
    |                     ------------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:433:9
    |
433 |         log_child!(cfd_log, "write oom score {}", p.oom_score_adj.unwrap());
    |         -------------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:442:9
    |
442 |         log_child!(cfd_log, "set resource limit: {:?}", rl);
    |         ---------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:447:9
    |
447 |         log_child!(cfd_log, "enter new user namespace");
    |         ------------------------------------------------ in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:451:5
    |
451 |     log_child!(cfd_log, "notify parent unshare user ns completed");
    |     --------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:455:5
    |
455 |     log_child!(cfd_log, "wait parent to setup user id mapping");
    |     ------------------------------------------------------------ in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:459:9
    |
459 |         log_child!(cfd_log, "setup user id");
    |         ------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:471:9
    |
471 |         log_child!(cfd_log, "join namespace {:?}", s);
    |         ---------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:475:21
    |
475 |                     write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:479:17
    |
479 |                 write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:502:5
    |
502 |     log_child!(cfd_log, "setup rootfs {}", rootfs);
    |     ----------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:554:13
    |
554 | /             write_sync(
555 | |                 cwfd,
556 | |                 SYNC_FAILED,
557 | |                 format!("setgroups failed: {:?}", e).as_str(),
558 | |             );
    | |______________^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:613:5
    |
613 |     log_child!(cfd_log, "process command: {:?}", &args);
    |     ---------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:625:5
    |
625 |     log_child!(cfd_log, "ready to run exec");
    |     ----------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:626:5
    |
626 |     unistd::close(cfd_log);
    |     ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:627:5
    |
627 |     unistd::close(crfd);
    |     ^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:628:5
    |
628 |     unistd::close(cwfd);
    |     ^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:648:5
    |
648 |     do_exec(&args);
    |     ^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:770:9
    |
770 |         fcntl::fcntl(pfd_log, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:799:9
    |
799 |         fcntl::fcntl(prfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:800:9
    |
800 |         fcntl::fcntl(pwfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:803:13
    |
803 |             unistd::close(prfd);
    |             ^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:804:13
    |
804 |             unistd::close(pwfd);
    |             ^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:817:13
    |
817 |             fcntl::fcntl(pseduo.master, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:818:13
    |
818 |             fcntl::fcntl(pseduo.slave, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:845:13
    |
845 |             sched::setns(old_pid_ns, CloneFlags::CLONE_NEWPID);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:846:13
    |
846 |             unistd::close(old_pid_ns);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:888:13
    |
888 |             unistd::close(fifofd);
    |             ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:907:17
    |
907 |                 signal::kill(Pid::from_raw(p.pid), Some(Signal::SIGKILL));
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:920:17
    |
920 |                 signal::kill(Pid::from_raw(child.id() as i32), Some(Signal::SIGKILL));
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:934:9
    |
934 |         log_handler.join();
    |         ^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:207:9
    |
207 |         log_child!(cfd_log, "mount cgroup subsystem {}", key);
    |         ------------------------------------------------------ in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:234:9
    |
234 |         log_child!(cfd_log, "mount destination: {}", destination.as_str());
    |         ------------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |           write_count(lfd, log_str.as_bytes(), log_str.len());
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:253:21
    |
253 | /                     log_child!(
254 | |                         cfd_log,
255 | |                         "symlink: {} {} err: {}",
256 | |                         key,
257 | |                         destination.as_str(),
258 | |                         e.to_string()
259 | |                     );
    | |______________________- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |           write_count(lfd, log_str.as_bytes(), log_str.len());
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:517:17
    |
517 | /                 log_child!(
518 | |                     cfd_log,
519 | |                     "creat dir {}: {}",
520 | |                     dir.to_str().unwrap(),
521 | |                     e.to_string()
522 | |                 );
    | |__________________- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |           write_count(lfd, log_str.as_bytes(), log_str.len());
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:550:13
    |
550 | /             log_child!(
551 | |                 cfd_log,
552 | |                 "{}: {}",
553 | |                 dest.as_str(),
554 | |                 e.as_errno().unwrap().desc()
555 | |             );
    | |______________- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:568:13
    |
568 |             log_child!(cfd_log, "mount error: {}", e.as_errno().unwrap().desc());
    |             --------------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |           write_count(lfd, log_str.as_bytes(), log_str.len());
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:591:17
    |
591 | /                 log_child!(
592 | |                     cfd_log,
593 | |                     "remout {}: {}",
594 | |                     dest.as_str(),
595 | |                     e.as_errno().unwrap().desc()
596 | |                 );
    | |__________________- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused `std::result::Result` that must be used
   --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/sync.rs:26:9
    |
26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/mount.rs:701:5
    |
701 |     log_child!(cfd_log, "old cwd: {}", olddir.to_str().unwrap());
    |     ------------------------------------------------------------- in this macro invocation
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 70 warnings emitted

   Compiling kata-agent-ctl v0.0.1 (/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl)
     Running `rustc --crate-name kata_agent_ctl --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=876607a0c8d345a0 -C extra-filename=-876607a0c8d345a0 --out-dir /home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps -C incremental=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/incremental -L dependency=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps --extern anyhow=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libanyhow-ab4c6bcf6d16a025.rlib --extern clap=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libclap-7e74b01af05d8962.rlib --extern humantime=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libhumantime-65a8adbf333f2b0c.rlib --extern lazy_static=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liblazy_static-5146de7e1f59d989.rlib --extern libc=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liblibc-9e9801c44bd85ecd.rlib --extern logging=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liblogging-30bc1b183249feff.rlib --extern nix=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libnix-8afa0965a461e128.rlib --extern oci=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/liboci-e0e70f2b9b41f350.rlib --extern protobuf=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libprotobuf-d347a5b2385f2760.rlib --extern protocols=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libprotocols-2ab1bfd4da2d338b.rlib --extern rand=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/librand-b6c7e7af5b7e5c11.rlib --extern rustjail=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/librustjail-31c27457d38c0752.rlib --extern serde=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libserde-307865b050215c25.rlib --extern serde_json=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libserde_json-c973bb472f334106.rlib --extern slog=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libslog-114df4cb391d5cdd.rlib --extern slog_scope=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libslog_scope-8295617ee90f7d77.rlib --extern ttrpc=/home/ddd/go/src/github.com/kata-containers-2.0/tools/agent-ctl/target/debug/deps/libttrpc-9ab471c35f1fe01a.rlib`
warning: unused import: `POSIXRlimit as grpcPOSIXRlimit`
  --> src/utils.rs:11:5
   |
11 |     POSIXRlimit as grpcPOSIXRlimit, Process as grpcProcess, Root as grpcRoot, Spec as grpcSpec,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted
@c3d c3d added bug Incorrect behaviour needs-review Needs to be assessed by the team. labels Sep 17, 2020
@jodh-intel jodh-intel added this to To do in Issue backlog Sep 17, 2020
@fidencio
Copy link
Member

@c3d, take a look at: #410 and #409

c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
Fixes the following warning:

   Compiling logging v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging)
   warning: associated function is never used: `set_level`
      --> /home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging/src/lib.rs:186:8
       |
   186 |     fn set_level(&self, level: slog::Level) {
       |        ^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warnings:
   Compiling oci v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/oci)
   warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
     --> oci/src/serialize.rs:34:35
      |
   34 |             Error::Io(ref e) => e.description(),
      |                                   ^^^^^^^^^^^
      |
      = note: `#[warn(deprecated)]` on by default

   warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
     --> oci/src/serialize.rs:35:37
      |
   35 |             Error::Json(ref e) => e.description(),
      |                                     ^^^^^^^^^^^

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warnings:

   Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
   warning: unused `#[macro_use]` import
     --> rustjail/src/lib.rs:15:1
      |
   15 | #[macro_use]
      | ^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default

   warning: unused macro definition
     --> rustjail/src/lib.rs:38:1
      |
   38 | / macro_rules! sl {
   39 | |     () => {
   40 | |         slog_scope::logger().new(o!("subsystem" => "rustjail"))
   41 | |     };
   42 | | }
      | |_^
      |
      = note: `#[warn(unused_macros)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warnings:

    Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
    warning: unused import: `debug`
      --> rustjail/src/container.rs:57:12
       |
    57 | use slog::{debug, info, o, Logger};
       |            ^^^^^

    warning: unused imports: `AddressFamily`, `SockFlag`, `SockType`, `self`
      --> rustjail/src/process.rs:18:24
       |
    18 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
       |                        ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^

    warning: unused import: `nix::Error`
      --> rustjail/src/process.rs:23:5
       |
    23 | use nix::Error;
       |     ^^^^^^^^^^

    warning: unused import: `protobuf::RepeatedField`
      --> rustjail/src/validator.rs:11:5
       |
    11 | use protobuf::RepeatedField;
       |     ^^^^^^^^^^^^^^^^^^^^^^^

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following:

    warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
        --> rustjail/src/container.rs:1598:31
         |
    1598 | ...                   e.description(),
         |                         ^^^^^^^^^^^
         |
         = note: `#[warn(deprecated)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresss the following warning:
warning: unused variable: `e`
    --> rustjail/src/cgroups/fs/mod.rs:1310:21
     |
1310 |                 Err(e) => {
     |                     ^ help: if this is intentional, prefix it with an underscore: `_e`
     |
     = note: `#[warn(unused_variables)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warning:

    warning: unused variable: `logger`
        --> rustjail/src/container.rs:1049:22
         |
    1049 | fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
         |                      ^^^^^^ help: if this is intentional, prefix it with an underscore: `_logger`

Also fixed a minor typo in the error message.

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warning:

    warning: unused variable: `child`
        --> rustjail/src/container.rs:1128:5
         |
    1128 |     child: &mut Child,
         |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_child`

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
Addresses the following warnings:

    warning: value assigned to `child_stdin` is never read
       --> rustjail/src/container.rs:807:13
        |
    807 |         let mut child_stdin = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_assignments)]` on by default
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stdout` is never read
       --> rustjail/src/container.rs:808:13
        |
    808 |         let mut child_stdout = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stderr` is never read
       --> rustjail/src/container.rs:809:13
        |
    809 |         let mut child_stderr = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdin` is never read
       --> rustjail/src/container.rs:810:13
        |
    810 |         let mut stdin = -1;
        |             ^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdout` is never read
       --> rustjail/src/container.rs:811:13
        |
    811 |         let mut stdout = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stderr` is never read
       --> rustjail/src/container.rs:812:13
        |
    812 |         let mut stderr = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
Addresses the following warning:
    warning: variable does not need to be mutable
       --> rustjail/src/container.rs:369:9
        |
    369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
        |         ----^^^^^^^^^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warning:
    warning: the type `oci::User` does not permit zero-initialization
      --> rustjail/src/lib.rs:99:18
       |
    99 |         unsafe { MaybeUninit::zeroed().assume_init() }
       |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |                  |
       |                  this code causes undefined behavior when executed
       |                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
       |
       = note: `#[warn(invalid_value)]` on by default
    note: `std::ptr::Unique<u32>` must be non-null (in this struct field)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warning:
    warning: the type `protocols::oci::Process` does not permit zero-initialization
       --> rustjail/src/lib.rs:146:14
        |
    146 |     unsafe { MaybeUninit::zeroed().assume_init() }
        |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |              |
        |              this code causes undefined behavior when executed
        |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
        |
    note: `std::ptr::Unique<std::string::String>` must be non-null (in this struct field)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
When we are writing to the log and there is an error doing so, there
is not much we can do. Chances are that a panic would make things
worse. So let it go through.

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/sync.rs:26:9
        |
    26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
       ::: rustjail/src/container.rs:339:13
        |
    339 |             log_child!(cfd_log, "child exit: {:?}", e);
        |             ------------------------------------------- in this macro invocation
        |
        = note: this `Result` may be an `Err` variant, which should be handled
        = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
Not sure exactly what the right strategy is in this case.
Returning a different error value might be a good indication.

This addresses the following warning:

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 17, 2020
This addresses the following warning:

warning: unused `std::result::Result` that must be used
   --> rustjail/src/container.rs:340:13
    |
340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
@c3d
Copy link
Member Author

c3d commented Sep 18, 2020

@sameo This looks like a duplicate of #409. I had already started some commits, see commits above, and many look similar.

I rebased your branch, I'll put a comment in #409

c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following warnings (and similar ones)::

    Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
    warning: unused import: `debug`
      --> rustjail/src/container.rs:57:12
       |
    57 | use slog::{debug, info, o, Logger};
       |            ^^^^^

    warning: unused imports: `AddressFamily`, `SockFlag`, `SockType`, `self`
      --> rustjail/src/process.rs:18:24
       |
    18 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
       |                        ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^

    warning: unused import: `nix::Error`
      --> rustjail/src/process.rs:23:5
       |
    23 | use nix::Error;
       |     ^^^^^^^^^^

    warning: unused import: `protobuf::RepeatedField`
      --> rustjail/src/validator.rs:11:5
       |
    11 | use protobuf::RepeatedField;
       |     ^^^^^^^^^^^^^^^^^^^^^^^

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following:

    warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
        --> rustjail/src/container.rs:1598:31
         |
    1598 | ...                   e.description(),
         |                         ^^^^^^^^^^^
         |
         = note: `#[warn(deprecated)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresss the following warning:
warning: unused variable: `e`
    --> rustjail/src/cgroups/fs/mod.rs:1310:21
     |
1310 |                 Err(e) => {
     |                     ^ help: if this is intentional, prefix it with an underscore: `_e`
     |
     = note: `#[warn(unused_variables)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following warning:

    warning: unused variable: `logger`
        --> rustjail/src/container.rs:1049:22
         |
    1049 | fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
         |                      ^^^^^^ help: if this is intentional, prefix it with an underscore: `_logger`

Also fixed a minor typo in the error message.

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following warning:

    warning: unused variable: `child`
        --> rustjail/src/container.rs:1128:5
         |
    1128 |     child: &mut Child,
         |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_child`

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
Addresses the following warnings:

    warning: value assigned to `child_stdin` is never read
       --> rustjail/src/container.rs:807:13
        |
    807 |         let mut child_stdin = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_assignments)]` on by default
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stdout` is never read
       --> rustjail/src/container.rs:808:13
        |
    808 |         let mut child_stdout = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stderr` is never read
       --> rustjail/src/container.rs:809:13
        |
    809 |         let mut child_stderr = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdin` is never read
       --> rustjail/src/container.rs:810:13
        |
    810 |         let mut stdin = -1;
        |             ^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdout` is never read
       --> rustjail/src/container.rs:811:13
        |
    811 |         let mut stdout = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stderr` is never read
       --> rustjail/src/container.rs:812:13
        |
    812 |         let mut stderr = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
Addresses the following warning (and a few similar ones):
    warning: variable does not need to be mutable
       --> rustjail/src/container.rs:369:9
        |
    369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
        |         ----^^^^^^^^^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following warning:
    warning: the type `oci::User` does not permit zero-initialization
      --> rustjail/src/lib.rs:99:18
       |
    99 |         unsafe { MaybeUninit::zeroed().assume_init() }
       |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |                  |
       |                  this code causes undefined behavior when executed
       |                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
       |
       = note: `#[warn(invalid_value)]` on by default
    note: `std::ptr::Unique<u32>` must be non-null (in this struct field)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
This addresses the following warning:
    warning: the type `protocols::oci::Process` does not permit zero-initialization
       --> rustjail/src/lib.rs:146:14
        |
    146 |     unsafe { MaybeUninit::zeroed().assume_init() }
        |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |              |
        |              this code causes undefined behavior when executed
        |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
        |
    note: `std::ptr::Unique<std::string::String>` must be non-null (in this struct field)

The functions are not actually used anywhere.

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Sep 24, 2020
When we are writing to the log and there is an error doing so, there
is not much we can do. Chances are that a panic would make things
worse. So let it go through.

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/sync.rs:26:9
        |
    26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
       ::: rustjail/src/container.rs:339:13
        |
    339 |             log_child!(cfd_log, "child exit: {:?}", e);
        |             ------------------------------------------- in this macro invocation
        |
        = note: this `Result` may be an `Err` variant, which should be handled
        = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
The code used `match` as a switch with variable patterns `ev_fd` and
`cf_fd`, but the way Rust interprets the code is that the first
pattern matches all values. The code does not perform as expected.

This addresses the following warning:

   warning: unreachable pattern
      --> rustjail/src/cgroups/notifier.rs:114:21
       |
   107 |                     ev_fd => {
       |                     ----- matches any value
   ...
   114 |                     cg_fd => {
       |                     ^^^^^ unreachable pattern
       |
       = note: `#[warn(unreachable_patterns)]` on by default

Fixes: #750
Fixes: #793

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
This addresses the following warnings:

   Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
   warning: unused `#[macro_use]` import
     --> rustjail/src/lib.rs:15:1
      |
   15 | #[macro_use]
      | ^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default

   warning: unused macro definition
     --> rustjail/src/lib.rs:38:1
      |
   38 | / macro_rules! sl {
   39 | |     () => {
   40 | |         slog_scope::logger().new(o!("subsystem" => "rustjail"))
   41 | |     };
   42 | | }
      | |_^
      |
      = note: `#[warn(unused_macros)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
This addresses the following warning:

    warning: unnecessary braces around assigned value
        --> src/rpc.rs:1411:26
         |
    1411 |     detail.init_daemon = { unistd::getpid() == Pid::from_raw(1) };
         |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces
         |
         = note: `#[warn(unused_braces)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Fixes the following warning:

   Compiling logging v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging)
   warning: associated function is never used: `set_level`
      --> /home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging/src/lib.rs:186:8
       |
   186 |     fn set_level(&self, level: slog::Level) {
       |        ^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Remove variables that are simply not used.
Rename as _ variables where only initialization matters.

This addresses the following warnings:

    warning: unused variable: `writer`
       --> src/main.rs:130:9
        |
    130 |     let writer = unsafe { File::from_raw_fd(wfd) };
        |         ^^^^^^ help: if this is intentional, prefix it with an underscore: `_writer`
        |
        = note: `#[warn(unused_variables)]` on by default

    warning: unused variable: `ctx`
       --> src/rpc.rs:782:9
        |
    782 |         ctx: &ttrpc::TtrpcContext,
        |         ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`

    warning: unused variable: `ctx`
       --> src/rpc.rs:808:9
        |
    808 |         ctx: &ttrpc::TtrpcContext,
        |         ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`

    warning: unused variable: `dns_list`
        --> src/rpc.rs:1152:16
         |
    1152 |             Ok(dns_list) => {
         |                ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_dns_list`

    warning: value assigned to `child_stdin` is never read
       --> rustjail/src/container.rs:807:13
        |
    807 |         let mut child_stdin = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_assignments)]` on by default
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stdout` is never read
       --> rustjail/src/container.rs:808:13
        |
    808 |         let mut child_stdout = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stderr` is never read
       --> rustjail/src/container.rs:809:13
        |
    809 |         let mut child_stderr = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdin` is never read
       --> rustjail/src/container.rs:810:13
        |
    810 |         let mut stdin = -1;
        |             ^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdout` is never read
       --> rustjail/src/container.rs:811:13
        |
    811 |         let mut stdout = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stderr` is never read
       --> rustjail/src/container.rs:812:13
        |
    812 |         let mut stderr = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Parameters that are never used were removed.
Parameters that are unused, but necessary because of some common
interface were renamed with a _ prefix.
In one case, consume the parameter by adding an info! call, and fix a
minor typo in a message in the same function.

This addresses the following warning:

    warning: unused variable: `child`
        --> rustjail/src/container.rs:1128:5
         |
    1128 |     child: &mut Child,
         |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_child`

    warning: unused variable: `logger`
        --> rustjail/src/container.rs:1049:22
         |
    1049 | fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
         |                      ^^^^^^ help: if this is intentional, prefix it with an underscore: `_logger`

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
This addresses the following:

    warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
        --> rustjail/src/container.rs:1598:31
         |
    1598 | ...                   e.description(),
         |                         ^^^^^^^^^^^
         |
         = note: `#[warn(deprecated)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Addresses the following warning (and a few similar ones):
    warning: variable does not need to be mutable
       --> rustjail/src/container.rs:369:9
        |
    369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
        |         ----^^^^^^^^^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Some functions have undefined behavior and are not actually used.

This addresses the following warning:
    warning: the type `oci::User` does not permit zero-initialization
      --> rustjail/src/lib.rs:99:18
       |
    99 |         unsafe { MaybeUninit::zeroed().assume_init() }
       |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |                  |
       |                  this code causes undefined behavior when executed
       |                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
       |
       = note: `#[warn(invalid_value)]` on by default
    note: `std::ptr::Unique<u32>` must be non-null (in this struct field)

    warning: the type `protocols::oci::Process` does not permit zero-initialization
       --> rustjail/src/lib.rs:146:14
        |
    146 |     unsafe { MaybeUninit::zeroed().assume_init() }
        |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |              |
        |              this code causes undefined behavior when executed
        |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
        |
    note: `std::ptr::Unique<std::string::String>` must be non-null (in this struct field)

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
When we are writing to the logs and there is an error doing so, there
is not much we can do. Chances are that a panic would make things
worse. So let it go through.

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/sync.rs:26:9
        |
    26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
       ::: rustjail/src/container.rs:339:13
        |
    339 |             log_child!(cfd_log, "child exit: {:?}", e);
        |             ------------------------------------------- in this macro invocation
        |
        = note: this `Result` may be an `Err` variant, which should be handled
        = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Various recently added error-causing calls

This addresses the following warning:

    warning: unused `std::result::Result` that must be used
      --> rustjail/src/cgroups/fs/mod.rs:93:9
       |
    93 |         cg.add_task(CgroupPid::from(pid as u64));
       |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(unused_must_use)]` on by default
       = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:196:17
        |
    196 |                 freezer_controller.thaw();
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:199:17
        |
    199 |                 freezer_controller.freeze();
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:365:9
        |
    365 |         cpuset_controller.set_cpus(&cpu.cpus);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:369:9
        |
    369 |         cpuset_controller.set_mems(&cpu.mems);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:381:13
        |
    381 |             cpu_controller.set_shares(shares);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:385:5
        |
    385 |     cpu_controller.set_cfs_quota_and_period(cpu.quota, cpu.period);
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/cgroups/fs/mod.rs:1061:13
         |
    1061 |             cpuset_controller.set_cpus(cpuset_cpus);
         |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: this `Result` may be an `Err` variant, which should be handled

The specific case of cpu_controller.set_cfs_quota_and_period is
addressed in a way that changes the logic following a suggestion by
Liu Bin, who had just added the code.

Fixes: #750

Suggested-by: Liu Bin <bin@hyper.sh>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
This addresses the following warnings (and similar ones)::

    Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
    warning: unused import: `debug`
      --> rustjail/src/container.rs:57:12
       |
    57 | use slog::{debug, info, o, Logger};
       |            ^^^^^

    warning: unused imports: `AddressFamily`, `SockFlag`, `SockType`, `self`
      --> rustjail/src/process.rs:18:24
       |
    18 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
       |                        ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^

    warning: unused import: `nix::Error`
      --> rustjail/src/process.rs:23:5
       |
    23 | use nix::Error;
       |     ^^^^^^^^^^

    warning: unused import: `protobuf::RepeatedField`
      --> rustjail/src/validator.rs:11:5
       |
    11 | use protobuf::RepeatedField;
       |     ^^^^^^^^^^^^^^^^^^^^^^^

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
In a number of cases, we have functions that return a Result<...>
and where the possible error case is simply ignored. This is a bit
unhealthy.

Add a `check!` macro that allows us to not ignore error values
that we want to log, while not interrupting the flow by returning
them. This is useful for low-level functions such as `signal::kill` or
`unistd::close` where an error is probably significant, but should not
necessarily interrupt the flow of the program (i.e. using `call()?` is
not the right answer.

The check! macro is then used on low-level calls. This addresses the
following warnings from #750:

This addresses the following warning:

    warning: unused `std::result::Result` that must be used
       --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:903:17
        |
    903 |                 signal::kill(Pid::from_raw(p.pid), Some(Signal::SIGKILL));
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:916:17
        |
    916 |                 signal::kill(Pid::from_raw(child.id() as i32), Some(Signal::SIGKILL));
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:554:13
        |
    554 | /             write_sync(
    555 | |                 cwfd,
    556 | |                 SYNC_FAILED,
    557 | |                 format!("setgroups failed: {:?}", e).as_str(),
    558 | |             );
        | |______________^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:554:13
        |
    554 | /             write_sync(
    555 | |                 cwfd,
    556 | |                 SYNC_FAILED,
    557 | |                 format!("setgroups failed: {:?}", e).as_str(),
    558 | |             );
        | |______________^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:626:5
        |
    626 |     unistd::close(cfd_log);
        |     ^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:627:5
        |
    627 |     unistd::close(crfd);
        |     ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:628:5
        |
    628 |     unistd::close(cwfd);
        |     ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:770:9
        |
    770 |         fcntl::fcntl(pfd_log, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:799:9
        |
    799 |         fcntl::fcntl(prfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:800:9
        |
    800 |         fcntl::fcntl(pwfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:803:13
        |
    803 |             unistd::close(prfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:930:9
        |
    930 |         log_handler.join();
        |         ^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:803:13
        |
    803 |             unistd::close(prfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:804:13
        |
    804 |             unistd::close(pwfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:842:13
        |
    842 |             sched::setns(old_pid_ns, CloneFlags::CLONE_NEWPID);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:843:13
        |
    843 |             unistd::close(old_pid_ns);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

Fixes: #844
Fixes: #750

Suggested-by: Tim Zhang <tim@hyper.sh>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Assign unused results to _ in order to silence warnings.

This addresses the following warnings:

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/mount.rs:1182:16
         |
    1182 |         defer!(unistd::chdir(&olddir););
         |                ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `#[warn(unused_must_use)]` on by default
         = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/mount.rs:1183:9
         |
    1183 |         unistd::chdir(tempdir.path());
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: this `Result` may be an `Err` variant, which should be handled

While in regular code, we want to log possible errors, in test code
it's OK to simply ignore the returned value.

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit that referenced this issue Apr 12, 2021
Avoid the accumulation of warnings we had, as reported in #750.

Fixes: #750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
The code used `match` as a switch with variable patterns `ev_fd` and
`cf_fd`, but the way Rust interprets the code is that the first
pattern matches all values. The code does not perform as expected.

This addresses the following warning:

   warning: unreachable pattern
      --> rustjail/src/cgroups/notifier.rs:114:21
       |
   107 |                     ev_fd => {
       |                     ----- matches any value
   ...
   114 |                     cg_fd => {
       |                     ^^^^^ unreachable pattern
       |
       = note: `#[warn(unreachable_patterns)]` on by default

Fixes: kata-containers#750
Fixes: kata-containers#793

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
This addresses the following warnings:

   Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
   warning: unused `#[macro_use]` import
     --> rustjail/src/lib.rs:15:1
      |
   15 | #[macro_use]
      | ^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` on by default

   warning: unused macro definition
     --> rustjail/src/lib.rs:38:1
      |
   38 | / macro_rules! sl {
   39 | |     () => {
   40 | |         slog_scope::logger().new(o!("subsystem" => "rustjail"))
   41 | |     };
   42 | | }
      | |_^
      |
      = note: `#[warn(unused_macros)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
This addresses the following warning:

    warning: unnecessary braces around assigned value
        --> src/rpc.rs:1411:26
         |
    1411 |     detail.init_daemon = { unistd::getpid() == Pid::from_raw(1) };
         |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces
         |
         = note: `#[warn(unused_braces)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Fixes the following warning:

   Compiling logging v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging)
   warning: associated function is never used: `set_level`
      --> /home/ddd/go/src/github.com/kata-containers-2.0/pkg/logging/src/lib.rs:186:8
       |
   186 |     fn set_level(&self, level: slog::Level) {
       |        ^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Remove variables that are simply not used.
Rename as _ variables where only initialization matters.

This addresses the following warnings:

    warning: unused variable: `writer`
       --> src/main.rs:130:9
        |
    130 |     let writer = unsafe { File::from_raw_fd(wfd) };
        |         ^^^^^^ help: if this is intentional, prefix it with an underscore: `_writer`
        |
        = note: `#[warn(unused_variables)]` on by default

    warning: unused variable: `ctx`
       --> src/rpc.rs:782:9
        |
    782 |         ctx: &ttrpc::TtrpcContext,
        |         ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`

    warning: unused variable: `ctx`
       --> src/rpc.rs:808:9
        |
    808 |         ctx: &ttrpc::TtrpcContext,
        |         ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`

    warning: unused variable: `dns_list`
        --> src/rpc.rs:1152:16
         |
    1152 |             Ok(dns_list) => {
         |                ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_dns_list`

    warning: value assigned to `child_stdin` is never read
       --> rustjail/src/container.rs:807:13
        |
    807 |         let mut child_stdin = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_assignments)]` on by default
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stdout` is never read
       --> rustjail/src/container.rs:808:13
        |
    808 |         let mut child_stdout = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `child_stderr` is never read
       --> rustjail/src/container.rs:809:13
        |
    809 |         let mut child_stderr = std::process::Stdio::null();
        |             ^^^^^^^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdin` is never read
       --> rustjail/src/container.rs:810:13
        |
    810 |         let mut stdin = -1;
        |             ^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stdout` is never read
       --> rustjail/src/container.rs:811:13
        |
    811 |         let mut stdout = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

    warning: value assigned to `stderr` is never read
       --> rustjail/src/container.rs:812:13
        |
    812 |         let mut stderr = -1;
        |             ^^^^^^^^^^
        |
        = help: maybe it is overwritten before being read?

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Parameters that are never used were removed.
Parameters that are unused, but necessary because of some common
interface were renamed with a _ prefix.
In one case, consume the parameter by adding an info! call, and fix a
minor typo in a message in the same function.

This addresses the following warning:

    warning: unused variable: `child`
        --> rustjail/src/container.rs:1128:5
         |
    1128 |     child: &mut Child,
         |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_child`

    warning: unused variable: `logger`
        --> rustjail/src/container.rs:1049:22
         |
    1049 | fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
         |                      ^^^^^^ help: if this is intentional, prefix it with an underscore: `_logger`

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
This addresses the following:

    warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
        --> rustjail/src/container.rs:1598:31
         |
    1598 | ...                   e.description(),
         |                         ^^^^^^^^^^^
         |
         = note: `#[warn(deprecated)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Addresses the following warning (and a few similar ones):
    warning: variable does not need to be mutable
       --> rustjail/src/container.rs:369:9
        |
    369 |     let mut oci_process: oci::Process = serde_json::from_str(process_str)?;
        |         ----^^^^^^^^^^^
        |         |
        |         help: remove this `mut`
        |
        = note: `#[warn(unused_mut)]` on by default

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Some functions have undefined behavior and are not actually used.

This addresses the following warning:
    warning: the type `oci::User` does not permit zero-initialization
      --> rustjail/src/lib.rs:99:18
       |
    99 |         unsafe { MaybeUninit::zeroed().assume_init() }
       |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |                  |
       |                  this code causes undefined behavior when executed
       |                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
       |
       = note: `#[warn(invalid_value)]` on by default
    note: `std::ptr::Unique<u32>` must be non-null (in this struct field)

    warning: the type `protocols::oci::Process` does not permit zero-initialization
       --> rustjail/src/lib.rs:146:14
        |
    146 |     unsafe { MaybeUninit::zeroed().assume_init() }
        |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |              |
        |              this code causes undefined behavior when executed
        |              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
        |
    note: `std::ptr::Unique<std::string::String>` must be non-null (in this struct field)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
When we are writing to the logs and there is an error doing so, there
is not much we can do. Chances are that a panic would make things
worse. So let it go through.

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/sync.rs:26:9
        |
    26  |         write_count(lfd, log_str.as_bytes(), log_str.len());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
       ::: rustjail/src/container.rs:339:13
        |
    339 |             log_child!(cfd_log, "child exit: {:?}", e);
        |             ------------------------------------------- in this macro invocation
        |
        = note: this `Result` may be an `Err` variant, which should be handled
        = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Various recently added error-causing calls

This addresses the following warning:

    warning: unused `std::result::Result` that must be used
      --> rustjail/src/cgroups/fs/mod.rs:93:9
       |
    93 |         cg.add_task(CgroupPid::from(pid as u64));
       |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(unused_must_use)]` on by default
       = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:196:17
        |
    196 |                 freezer_controller.thaw();
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:199:17
        |
    199 |                 freezer_controller.freeze();
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:365:9
        |
    365 |         cpuset_controller.set_cpus(&cpu.cpus);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:369:9
        |
    369 |         cpuset_controller.set_mems(&cpu.mems);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:381:13
        |
    381 |             cpu_controller.set_shares(shares);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/cgroups/fs/mod.rs:385:5
        |
    385 |     cpu_controller.set_cfs_quota_and_period(cpu.quota, cpu.period);
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/cgroups/fs/mod.rs:1061:13
         |
    1061 |             cpuset_controller.set_cpus(cpuset_cpus);
         |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: this `Result` may be an `Err` variant, which should be handled

The specific case of cpu_controller.set_cfs_quota_and_period is
addressed in a way that changes the logic following a suggestion by
Liu Bin, who had just added the code.

Fixes: kata-containers#750

Suggested-by: Liu Bin <bin@hyper.sh>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
This addresses the following warnings (and similar ones)::

    Compiling rustjail v0.1.0 (/home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail)
    warning: unused import: `debug`
      --> rustjail/src/container.rs:57:12
       |
    57 | use slog::{debug, info, o, Logger};
       |            ^^^^^

    warning: unused imports: `AddressFamily`, `SockFlag`, `SockType`, `self`
      --> rustjail/src/process.rs:18:24
       |
    18 | use nix::sys::socket::{self, AddressFamily, SockFlag, SockType};
       |                        ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^  ^^^^^^^^

    warning: unused import: `nix::Error`
      --> rustjail/src/process.rs:23:5
       |
    23 | use nix::Error;
       |     ^^^^^^^^^^

    warning: unused import: `protobuf::RepeatedField`
      --> rustjail/src/validator.rs:11:5
       |
    11 | use protobuf::RepeatedField;
       |     ^^^^^^^^^^^^^^^^^^^^^^^

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
In a number of cases, we have functions that return a Result<...>
and where the possible error case is simply ignored. This is a bit
unhealthy.

Add a `check!` macro that allows us to not ignore error values
that we want to log, while not interrupting the flow by returning
them. This is useful for low-level functions such as `signal::kill` or
`unistd::close` where an error is probably significant, but should not
necessarily interrupt the flow of the program (i.e. using `call()?` is
not the right answer.

The check! macro is then used on low-level calls. This addresses the
following warnings from kata-containers#750:

This addresses the following warning:

    warning: unused `std::result::Result` that must be used
       --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:903:17
        |
    903 |                 signal::kill(Pid::from_raw(p.pid), Some(Signal::SIGKILL));
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> /home/ddd/go/src/github.com/kata-containers-2.0/src/agent/rustjail/src/container.rs:916:17
        |
    916 |                 signal::kill(Pid::from_raw(child.id() as i32), Some(Signal::SIGKILL));
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:554:13
        |
    554 | /             write_sync(
    555 | |                 cwfd,
    556 | |                 SYNC_FAILED,
    557 | |                 format!("setgroups failed: {:?}", e).as_str(),
    558 | |             );
        | |______________^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:340:13
        |
    340 |             write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:554:13
        |
    554 | /             write_sync(
    555 | |                 cwfd,
    556 | |                 SYNC_FAILED,
    557 | |                 format!("setgroups failed: {:?}", e).as_str(),
    558 | |             );
        | |______________^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:626:5
        |
    626 |     unistd::close(cfd_log);
        |     ^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:627:5
        |
    627 |     unistd::close(crfd);
        |     ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:628:5
        |
    628 |     unistd::close(cwfd);
        |     ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:770:9
        |
    770 |         fcntl::fcntl(pfd_log, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:799:9
        |
    799 |         fcntl::fcntl(prfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:800:9
        |
    800 |         fcntl::fcntl(pwfd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:803:13
        |
    803 |             unistd::close(prfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:930:9
        |
    930 |         log_handler.join();
        |         ^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:803:13
        |
    803 |             unistd::close(prfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(unused_must_use)]` on by default
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:804:13
        |
    804 |             unistd::close(pwfd);
        |             ^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:842:13
        |
    842 |             sched::setns(old_pid_ns, CloneFlags::CLONE_NEWPID);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
       --> rustjail/src/container.rs:843:13
        |
    843 |             unistd::close(old_pid_ns);
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: this `Result` may be an `Err` variant, which should be handled

Fixes: kata-containers#844
Fixes: kata-containers#750

Suggested-by: Tim Zhang <tim@hyper.sh>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Assign unused results to _ in order to silence warnings.

This addresses the following warnings:

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/mount.rs:1182:16
         |
    1182 |         defer!(unistd::chdir(&olddir););
         |                ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `#[warn(unused_must_use)]` on by default
         = note: this `Result` may be an `Err` variant, which should be handled

    warning: unused `std::result::Result` that must be used
        --> rustjail/src/mount.rs:1183:9
         |
    1183 |         unistd::chdir(tempdir.path());
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: this `Result` may be an `Err` variant, which should be handled

While in regular code, we want to log possible errors, in test code
it's OK to simply ignore the returned value.

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
c3d added a commit to c3d/kata-containers that referenced this issue Apr 12, 2021
Avoid the accumulation of warnings we had, as reported in kata-containers#750.

Fixes: kata-containers#750

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behaviour needs-review Needs to be assessed by the team.
Projects
Issue backlog
  
In progress
2 participants