willdoescode / nat

`ls` alternative with useful info and a splash of color 🎨

Home Page:https://git.io/natls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ubuntu 20.10 compiler warnings and 'nat -l' panic

derwana opened this issue · comments

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
commented

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

Can confirm working nat -l but warnings remain.

commented

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