Skip to content

Commit

Permalink
Fix clippy warnings (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf authored Aug 29, 2022
1 parent 9118a60 commit 080d2fa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 52 deletions.
41 changes: 1 addition & 40 deletions librocksdb-sys/tests/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,49 +221,10 @@ unsafe extern "C" fn CmpName(arg: *mut c_void) -> *const c_char {
cstrp!("foo")
}

// Custom filter policy
// Custom compaction filter

static mut fake_filter_result: c_uchar = 1;

unsafe extern "C" fn FilterDestroy(arg: *mut c_void) {}

unsafe extern "C" fn FilterName(arg: *mut c_void) -> *const c_char {
cstrp!("TestFilter")
}

unsafe extern "C" fn FilterCreate(
arg: *mut c_void,
key_array: *const *const c_char,
key_length_array: *const size_t,
num_keys: c_int,
filter_length: *mut size_t,
) -> *mut c_char {
*filter_length = 4;
let result = malloc(4);
memcpy(result, cstrp!("fake") as *const c_void, 4);
result as *mut c_char
}

unsafe extern "C" fn FilterKeyMatch(
arg: *mut c_void,
key: *const c_char,
length: size_t,
filter: *const c_char,
filter_length: size_t,
) -> c_uchar {
CheckCondition!(filter_length == 4);
CheckCondition!(
memcmp(
filter as *const c_void,
cstrp!("fake") as *const c_void,
filter_length
) == 0
);
fake_filter_result
}

// Custom compaction filter

unsafe extern "C" fn CFilterDestroy(arg: *mut c_void) {}

unsafe extern "C" fn CFilterName(arg: *mut c_void) -> *const c_char {
Expand Down
16 changes: 8 additions & 8 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl Default for CuckooTableOptions {
}

// Verbosity of the LOG.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(i32)]
pub enum LogLevel {
Debug = 0,
Expand Down Expand Up @@ -3271,7 +3271,7 @@ impl Default for WriteOptions {
}
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[repr(i32)]
pub enum ReadTier {
Expand Down Expand Up @@ -3644,7 +3644,7 @@ pub struct PlainTableFactoryOptions {
pub index_sparseness: usize,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum DBCompressionType {
None = ffi::rocksdb_no_compression as isize,
Expand All @@ -3656,15 +3656,15 @@ pub enum DBCompressionType {
Zstd = ffi::rocksdb_zstd_compression as isize,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum DBCompactionStyle {
Level = ffi::rocksdb_level_compaction as isize,
Universal = ffi::rocksdb_universal_compaction as isize,
Fifo = ffi::rocksdb_fifo_compaction as isize,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum DBRecoveryMode {
TolerateCorruptedTailRecords = ffi::rocksdb_tolerate_corrupted_tail_records_recovery as isize,
Expand All @@ -3674,7 +3674,7 @@ pub enum DBRecoveryMode {
}

/// File access pattern once a compaction has started
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[repr(i32)]
pub enum AccessHint {
Expand Down Expand Up @@ -3722,7 +3722,7 @@ impl FifoCompactOptions {
}
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum UniversalCompactionStopStyle {
Similar = ffi::rocksdb_similar_size_compaction_stop_style as isize,
Expand Down Expand Up @@ -3838,7 +3838,7 @@ impl UniversalCompactOptions {
}
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[repr(u8)]
pub enum BottommostLevelCompaction {
Expand Down
2 changes: 1 addition & 1 deletion src/db_pinnable_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unsafe impl<'a> Sync for DBPinnableSlice<'a> {}
impl<'a> AsRef<[u8]> for DBPinnableSlice<'a> {
fn as_ref(&self) -> &[u8] {
// Implement this via Deref so as not to repeat ourselves
&*self
&**self
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub enum ErrorKind {

/// A simple wrapper round a string, used for errors reported from
/// ffi calls.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Error {
message: String,
}
Expand Down
4 changes: 2 additions & 2 deletions src/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use libc::{c_int, c_uchar, c_void};

use crate::{db::DBInner, ffi, ffi_util::from_cstr, Cache, Error, DB};

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(i32)]
pub enum PerfStatsLevel {
/// Unknown settings
Expand All @@ -36,7 +36,7 @@ pub enum PerfStatsLevel {
OutOfBound,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
#[repr(i32)]
pub enum PerfMetric {
Expand Down

0 comments on commit 080d2fa

Please sign in to comment.