Skip to content

Commit 5a3ced8

Browse files
authored
Fix clippy warnings (tikv#627)
1 parent 3a46074 commit 5a3ced8

File tree

7 files changed

+79
-77
lines changed

7 files changed

+79
-77
lines changed

librocksdb-sys/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn internal() {
3737

3838
rocksdb_options_increase_parallelism(opts, 0);
3939
rocksdb_options_optimize_level_style_compaction(opts, 0);
40-
rocksdb_options_set_create_if_missing(opts, true as c_uchar);
40+
rocksdb_options_set_create_if_missing(opts, u8::from(true));
4141

4242
let rustpath = "_rust_rocksdb_internaltest";
4343
let cpath = CString::new(rustpath).unwrap();

src/backup.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use crate::{ffi, Error, DB};
1717

18-
use libc::{c_int, c_uchar};
1918
use std::ffi::CString;
2019
use std::path::Path;
2120

@@ -93,7 +92,7 @@ impl BackupEngine {
9392
ffi_try!(ffi::rocksdb_backup_engine_create_new_backup_flush(
9493
self.inner,
9594
db.inner,
96-
flush_before_backup as c_uchar,
95+
u8::from(flush_before_backup),
9796
));
9897
Ok(())
9998
}
@@ -268,7 +267,7 @@ impl BackupEngineOptions {
268267
impl RestoreOptions {
269268
pub fn set_keep_log_files(&mut self, keep_log_files: bool) {
270269
unsafe {
271-
ffi::rocksdb_restore_options_set_keep_log_files(self.inner, keep_log_files as c_int);
270+
ffi::rocksdb_restore_options_set_keep_log_files(self.inner, i32::from(keep_log_files));
272271
}
273272
}
274273
}

src/db.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
WriteBatch, WriteOptions, DEFAULT_COLUMN_FAMILY_NAME,
2727
};
2828

29-
use libc::{self, c_char, c_int, c_uchar, c_void, size_t};
29+
use libc::{self, c_char, c_int, c_void, size_t};
3030
use std::collections::BTreeMap;
3131
use std::ffi::{CStr, CString};
3232
use std::fmt;
@@ -331,7 +331,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
331331

332332
/// Opens the database with a Time to Live compaction filter and column family names.
333333
///
334-
/// Column families opened using this function will be created with default `Options`.
334+
/// Column families opened using this function will be created with default `Options`.
335335
pub fn open_cf_with_ttl<P, I, N>(
336336
opts: &Options,
337337
path: P,
@@ -614,7 +614,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
614614
} => ffi_try!(ffi::rocksdb_open_for_read_only(
615615
opts.inner,
616616
cpath.as_ptr() as *const _,
617-
error_if_log_file_exist as c_uchar,
617+
u8::from(error_if_log_file_exist),
618618
)),
619619
AccessType::ReadWrite => {
620620
ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr() as *const _))
@@ -636,13 +636,14 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
636636
Ok(db)
637637
}
638638

639+
#[allow(clippy::pedantic)]
639640
fn open_cf_raw(
640641
opts: &Options,
641642
cpath: &CString,
642643
cfs_v: &[ColumnFamilyDescriptor],
643644
cfnames: &[*const c_char],
644645
cfopts: &[*const ffi::rocksdb_options_t],
645-
cfhandles: &mut Vec<*mut ffi::rocksdb_column_family_handle_t>,
646+
cfhandles: &mut [*mut ffi::rocksdb_column_family_handle_t],
646647
access_type: &AccessType,
647648
) -> Result<*mut ffi::rocksdb_t, Error> {
648649
let db = unsafe {
@@ -656,7 +657,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
656657
cfnames.as_ptr(),
657658
cfopts.as_ptr(),
658659
cfhandles.as_mut_ptr(),
659-
error_if_log_file_exist as c_uchar,
660+
u8::from(error_if_log_file_exist),
660661
)),
661662
AccessType::ReadWrite => ffi_try!(ffi::rocksdb_open_column_families(
662663
opts.inner,
@@ -737,7 +738,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
737738
/// the data to disk.
738739
pub fn flush_wal(&self, sync: bool) -> Result<(), Error> {
739740
unsafe {
740-
ffi_try!(ffi::rocksdb_flush_wal(self.inner, sync as u8));
741+
ffi_try!(ffi::rocksdb_flush_wal(self.inner, u8::from(sync)));
741742
}
742743
Ok(())
743744
}
@@ -1891,7 +1892,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
18911892
/// Request stopping background work, if wait is true wait until it's done.
18921893
pub fn cancel_all_background_work(&self, wait: bool) {
18931894
unsafe {
1894-
ffi::rocksdb_cancel_all_background_work(self.inner, wait as u8);
1895+
ffi::rocksdb_cancel_all_background_work(self.inner, u8::from(wait));
18951896
}
18961897
}
18971898

0 commit comments

Comments
 (0)