Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
Merge #451
Browse files Browse the repository at this point in the history
451: Fix clippy errors r=kpp a=kpcyrd

See #450

Co-authored-by: kpcyrd <git@rxv.cc>
Co-authored-by: Michael Howell <michael@notriddle.com>
  • Loading branch information
3 people authored Jan 1, 2021
2 parents ffd9626 + 7e1defe commit 10faca2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,3 @@ jobs:
steps:
- name: Mark the job as successful
run: exit 0

end-failure:
name: bors build finished
if: "!success()"
runs-on: ubuntu-latest
needs:
- test
- fmt
- clippy
- cross
steps:
- name: Mark the job as a failure
run: exit 1
27 changes: 23 additions & 4 deletions src/crypto/generichash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ impl State {
/// a custom key can be used for the computation of the hash.
/// The size of the key must be in the interval [`KEY_MIN`, `KEY_MAX`].
pub fn new(out_len: usize, key: Option<&[u8]>) -> Result<State, ()> {
if out_len < DIGEST_MIN || out_len > DIGEST_MAX {
if !(DIGEST_MIN..=DIGEST_MAX).contains(&out_len) {
return Err(());
}

if let Some(key) = key {
let len = key.len();
if len < KEY_MIN || len > KEY_MAX {
if !(KEY_MIN..=KEY_MAX).contains(&len) {
return Err(());
}
}
Expand Down Expand Up @@ -194,7 +194,27 @@ mod test {
}

#[test]
fn test_digest_equality() {
fn test_digest_equal() {
let data1 = [1, 2];
let data2 = [1, 2];

let h1 = {
let mut hasher = State::new(32, None).unwrap();
hasher.update(&data1).unwrap();
hasher.finalize().unwrap()
};

let h2 = {
let mut hasher = State::new(32, None).unwrap();
hasher.update(&data2).unwrap();
hasher.finalize().unwrap()
};

assert_eq!(h1, h2);
}

#[test]
fn test_digest_not_equal() {
let data1 = [1, 2];
let data2 = [3, 4];

Expand All @@ -210,7 +230,6 @@ mod test {
hasher.finalize().unwrap()
};

assert_eq!(h1, h1);
assert_ne!(h1, h2);
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#![warn(unused_qualifications)]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(clippy::all)]
// Remove this after https://github.com/sodiumoxide/sodiumoxide/issues/221 is done
#![allow(clippy::result_unit_err)]

extern crate libsodium_sys as ffi;

Expand Down

0 comments on commit 10faca2

Please sign in to comment.