outbrain / fwumious_wabbit

Fwumious Wabbit, fast on-line machine learning toolkit written in Rust
Other
133 stars 19 forks source link

Fix warnings #111

Closed ggaspersic closed 1 year ago

ggaspersic commented 1 year ago

We are left with only 9 warnings on the bin, where 8 of them are

warning: the type `[f32; 131072]` does not permit being left uninitialized
   --> src/block_ffm.rs:286:21
    |
286 |                     MaybeUninit::uninit().assume_init();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                     |
    |                     this code causes undefined behavior when executed
    |                     help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
    |
    = note: floats must be initialized
    = note: `#[warn(invalid_value)]` on by default

& the last one is

warning: value assigned to `buffer` is never read
   --> src/main.rs:113:13
    |
113 |             buffer = match reading_result {
    |             ^^^^^^
    |
    = help: maybe it is overwritten before being read?
    = note: `#[warn(unused_assignments)]` on by default

On the lib creation there are a bit more, but they are not relevant as the highlighted sections of code are marked as unused, while they are used by the bin & not the lib.

SkBlaz commented 1 year ago

@ggaspersic very nice, some context missing, could you please elaborate just so it's clear:

  1. This was clippy + fixes?
  2. Some manual fixes, if yes, which ones?
ggaspersic commented 1 year ago

@SkBlaz these were primarily the diagnostic warnings from the compiler.

The manual change was the removal of the unneeded lifetime signature & testing_set_weights.

The clippy warnings that I addressed were primarily the unnecessary additional usize conversions that we do in the neural blocks. Will add follow up PRs that also addresses clippy warnings