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

ubuntu 20.10 compiler warnings and 'nat -l' panic #33

Closed
derwana opened this issue Oct 25, 2020 · 3 comments
Closed

ubuntu 20.10 compiler warnings and 'nat -l' panic #33

derwana opened this issue Oct 25, 2020 · 3 comments

Comments

@derwana
Copy link

derwana commented Oct 25, 2020

Built and ran it like supposed in issue #16 on Ubuntu 20.10.

On compiling i got some warnings:

warning: value assigned to `groups_size` is never read
  --> src/main.rs:69:11
   |
69 |   let mut groups_size: i32 = 0;
   |           ^^^^^^^^^^^
   |
   = note: `#[warn(unused_assignments)]` on by default
   = help: maybe it is overwritten before being read?

warning: variable `user_size` is assigned to, but never used
  --> src/main.rs:76:11
   |
76 |   let mut user_size: i32 = 0;
   |           ^^^^^^^^^
   |
   = note: `#[warn(unused_variables)]` on by default
   = note: consider using `_user_size` instead

warning: value assigned to `user_size` is never read
  --> src/main.rs:78:5
   |
78 |     user_size = 0;
   |     ^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `user_size` is never read
  --> src/main.rs:80:5
   |
80 |     user_size = get_user_by_uid(get_current_uid()).unwrap().name().to_str().unwrap().len() as i32 - 4;
   |     ^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: unused variable: `mode_count`
   --> src/main.rs:118:9
    |
118 |     let mode_count = perms(mode as u16).len();
    |         ^^^^^^^^^^ help: consider prefixing with an underscore: `_mode_count`

warning: unused variable: `mode_count`
  --> src/single.rs:14:11
   |
14 |   let mut mode_count = 0;
   |           ^^^^^^^^^^ help: consider prefixing with an underscore: `_mode_count`

warning: variable does not need to be mutable
  --> src/single.rs:14:7
   |
14 |   let mut mode_count = 0;
   |       ----^^^^^^^^^^
   |       |
   |       help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

    Finished dev [unoptimized + debuginfo] target(s) in 1m 02s

On testing ./nat -l thread 'main' panicked with:

thread 'main' panicked at 'attempt to subtract with overflow', src/main.rs:70:6
note: run with 'RUST_BACKTRACE=1' environment variable to display a backtrace
permissions size last modified
@willdoescode
Copy link
Owner

should be fixed in the latest push. Try git pulling and compiling again.

@derwana
Copy link
Author

derwana commented Oct 25, 2020

Can confirm working nat -l but warnings remain.

@willdoescode
Copy link
Owner

willdoescode commented Oct 25, 2020

I removed two of the warnings but the rest of the warnings are supposed to be there, if you follow what the warnings say and remove mut from the variables the code will no longer compile because later in the code I change those variables. For now just ignore the warnings that say to remove mut from the code.

commit that removed two warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants