From 9f49fe1d5d30eecd27321138bbfecbb2883de203 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 30 Jan 2019 18:25:37 +0100 Subject: [PATCH] avoid compiler warnings --- src/api/schema.rs | 1 - src/api2.rs | 47 ++------------------------- src/api2/access.rs | 2 +- src/api2/admin/datastore.rs | 2 +- src/api2/node/dns.rs | 3 +- src/api2/node/network.rs | 2 +- src/api2/node/services.rs | 16 ++++----- src/api2/node/syslog.rs | 1 - src/auth_helpers.rs | 2 -- src/backup/archive_index.rs | 10 +++--- src/backup/chunker.rs | 12 ++++--- src/backup/datastore.rs | 2 -- src/backup/image_index.rs | 10 +++--- src/bin/test_chunk_speed.rs | 4 +-- src/catar/encoder.rs | 52 +++++++++++++++--------------- src/client/http_client.rs | 5 --- src/tools/ticket.rs | 4 --- src/tools/wrapped_reader_stream.rs | 4 +-- 18 files changed, 60 insertions(+), 119 deletions(-) diff --git a/src/api/schema.rs b/src/api/schema.rs index bf0629d9..00cacade 100644 --- a/src/api/schema.rs +++ b/src/api/schema.rs @@ -2,7 +2,6 @@ use failure::*; use std::collections::HashMap; use serde_json::{json, Value}; use url::form_urlencoded; -use lazy_static::lazy_static; use regex::Regex; use std::fmt; use std::sync::Arc; diff --git a/src/api2.rs b/src/api2.rs index 42a55989..5cd2bce6 100644 --- a/src/api2.rs +++ b/src/api2.rs @@ -1,8 +1,8 @@ -use failure::*; +//use failure::*; use crate::api::schema::*; use crate::api::router::*; -use serde_json::{json, Value}; +use serde_json::{json}; use std::sync::Arc; pub mod config; @@ -29,54 +29,11 @@ lazy_static! { } - - -fn test_sync_api_handler( - param: Value, - _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, -) -> Result { - println!("This is a test {}", param); - - // let force: Option = Some(false); - - //if let Some(force) = param.force { - //} - - let _force = param["force"].as_bool() - .ok_or_else(|| format_err!("missing parameter 'force'"))?; - - if let Some(_force) = param["force"].as_bool() { - } - - Ok(json!(null)) -} - pub fn router() -> Router { - let route4 = Router::new() - .get(ApiMethod::new( - |param, _info, _rpcenv| { - println!("This is a clousure handler: {}", param); - - Ok(json!(null)) - }, - ObjectSchema::new("Another Endpoint.")) - .returns(Schema::Null)); - - - let nodeinfo = Router::new() - .get(ApiMethod::new( - test_sync_api_handler, - ObjectSchema::new("This is a simple test.") - .optional("force", BooleanSchema::new("Test for boolean options"))) - ) - .subdir("subdir3", route4); - let nodes = Router::new() .subdir("localhost", node::router()); - let route = Router::new() .get(ApiMethod::new( |_,_,_| Ok(json!([ diff --git a/src/api2/access.rs b/src/api2/access.rs index 9c65d221..390e54cf 100644 --- a/src/api2/access.rs +++ b/src/api2/access.rs @@ -20,7 +20,7 @@ fn authenticate_user(username: &str, password: &str) -> Result<(), Error> { fn create_ticket( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let username = tools::required_string_param(¶m, "username")?; diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 503733e5..1966accd 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -68,7 +68,7 @@ fn get_backup_list( _rpcenv: &mut RpcEnvironment, ) -> Result { - let config = datastore::config()?; + //let config = datastore::config()?; let store = param["store"].as_str().unwrap(); diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs index 992567b2..5acec54a 100644 --- a/src/api2/node/dns.rs +++ b/src/api2/node/dns.rs @@ -8,7 +8,6 @@ use crate::api2::*; use lazy_static::lazy_static; -use std::io::{BufRead, BufReader}; use std::sync::{Arc, Mutex}; use openssl::sha; use regex::Regex; @@ -61,7 +60,7 @@ fn update_dns( static ref MUTEX: Arc> = Arc::new(Mutex::new(0)); } - let guard = MUTEX.lock(); + let _guard = MUTEX.lock(); let search = tools::required_string_param(¶m, "search")?; diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs index f9f22595..3f22fe8d 100644 --- a/src/api2/node/network.rs +++ b/src/api2/node/network.rs @@ -1,6 +1,6 @@ use failure::*; -use crate::tools; +//use crate::tools; use crate::api::schema::*; use crate::api::router::*; use serde_json::{json, Value}; diff --git a/src/api2/node/services.rs b/src/api2/node/services.rs index 743b6961..a648f4fb 100644 --- a/src/api2/node/services.rs +++ b/src/api2/node/services.rs @@ -6,8 +6,6 @@ use crate::api::router::*; use serde_json::{json, Value}; use std::sync::Arc; -use lazy_static::lazy_static; -use crate::tools::common_regex; use std::process::{Command, Stdio}; static SERVICE_NAME_LIST: [&str; 6] = [ @@ -91,9 +89,9 @@ fn json_service_state(service: &str, status: Value) -> Value { fn list_services( - param: Value, + _param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let mut list = vec![]; @@ -116,7 +114,7 @@ fn list_services( fn get_service_state( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -161,7 +159,7 @@ fn run_service_command(service: &str, cmd: &str) -> Result { fn start_service( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -174,7 +172,7 @@ fn start_service( fn stop_service( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -187,7 +185,7 @@ fn stop_service( fn restart_service( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -200,7 +198,7 @@ fn restart_service( fn reload_service( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + _rpcenv: &mut RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; diff --git a/src/api2/node/syslog.rs b/src/api2/node/syslog.rs index 56051c3c..1391686f 100644 --- a/src/api2/node/syslog.rs +++ b/src/api2/node/syslog.rs @@ -1,6 +1,5 @@ use failure::*; -use crate::tools; use crate::api::schema::*; use crate::api::router::*; use serde_json::{json, Value}; diff --git a/src/auth_helpers.rs b/src/auth_helpers.rs index a2657a47..7c06b988 100644 --- a/src/auth_helpers.rs +++ b/src/auth_helpers.rs @@ -17,8 +17,6 @@ pub fn assemble_csrf_prevention_token( let epoch = std::time::SystemTime::now().duration_since( std::time::SystemTime::UNIX_EPOCH).unwrap().as_secs(); - let timestamp = format!("{:08X}", epoch); - let mut hasher = sha::Sha256::new(); let data = format!("{:08X}:{}:", epoch, username); hasher.update(data.as_bytes()); diff --git a/src/backup/archive_index.rs b/src/backup/archive_index.rs index 8252559a..e72580de 100644 --- a/src/backup/archive_index.rs +++ b/src/backup/archive_index.rs @@ -25,12 +25,12 @@ pub struct ArchiveIndexHeader { pub struct ArchiveIndexReader { store: Arc, _file: File, - size: usize, + pub size: usize, filename: PathBuf, index: *const u8, index_entries: usize, - uuid: [u8; 16], - ctime: u64, + pub uuid: [u8; 16], + pub ctime: u64, } // fixme: ???!!! @@ -324,8 +324,8 @@ pub struct ArchiveIndexWriter { closed: bool, filename: PathBuf, tmp_filename: PathBuf, - uuid: [u8; 16], - ctime: u64, + pub uuid: [u8; 16], + pub ctime: u64, chunk_offset: usize, last_chunk: usize, diff --git a/src/backup/chunker.rs b/src/backup/chunker.rs index 2ac053c3..1d03786d 100644 --- a/src/backup/chunker.rs +++ b/src/backup/chunker.rs @@ -17,9 +17,9 @@ pub struct Chunker { chunk_size_min: usize, chunk_size_max: usize, - chunk_size_avg: usize, + _chunk_size_avg: usize, - discriminator: u32, + _discriminator: u32, break_test_value: u32, @@ -123,8 +123,8 @@ impl Chunker { chunk_size: 0, chunk_size_min: chunk_size_avg>>2, chunk_size_max: chunk_size_avg<<2, - chunk_size_avg: chunk_size_avg, - discriminator: discriminator, + _chunk_size_avg: chunk_size_avg, + _discriminator: discriminator, break_test_value: break_test_value, window: [0u8; CA_CHUNKER_WINDOW_SIZE], } @@ -199,6 +199,7 @@ impl Chunker { } // This is the original implementation from casync + /* #[inline(always)] fn shall_break_orig(&self) -> bool { @@ -208,7 +209,8 @@ impl Chunker { (self.h % self.discriminator) == (self.discriminator - 1) } - + */ + fn start(&mut self) { let window_len = self.window.len(); diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index d2ef1e3d..df5686fe 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -7,8 +7,6 @@ use std::collections::HashMap; use lazy_static::lazy_static; use std::sync::{Mutex, Arc}; -use std::os::unix::io::AsRawFd; - use crate::tools; use crate::config::datastore; use super::chunk_store::*; diff --git a/src/backup/image_index.rs b/src/backup/image_index.rs index 4d882890..d15cb06f 100644 --- a/src/backup/image_index.rs +++ b/src/backup/image_index.rs @@ -27,10 +27,10 @@ pub struct ImageIndexReader { store: Arc, filename: PathBuf, chunk_size: usize, - size: usize, + pub size: usize, index: *mut u8, - uuid: [u8; 16], - ctime: u64, + pub uuid: [u8; 16], + pub ctime: u64, } impl Drop for ImageIndexReader { @@ -160,8 +160,8 @@ pub struct ImageIndexWriter { duplicate_chunks: usize, size: usize, index: *mut u8, - uuid: [u8; 16], - ctime: u64, + pub uuid: [u8; 16], + pub ctime: u64, } impl Drop for ImageIndexWriter { diff --git a/src/bin/test_chunk_speed.rs b/src/bin/test_chunk_speed.rs index b2a7efeb..7000a498 100644 --- a/src/bin/test_chunk_speed.rs +++ b/src/bin/test_chunk_speed.rs @@ -23,14 +23,14 @@ fn main() { for _i in 0..count { let mut pos = 0; - let mut last = 0; + let mut _last = 0; while pos < buffer.len() { let k = chunker.scan(&buffer[pos..]); if k == 0 { //println!("LAST {}", pos); break; } else { - last = pos; + _last = pos; pos += k; chunk_count += 1; //println!("CHUNK {} {}", pos, pos-last); diff --git a/src/catar/encoder.rs b/src/catar/encoder.rs index 940f5bd8..93d8efd3 100644 --- a/src/catar/encoder.rs +++ b/src/catar/encoder.rs @@ -32,7 +32,7 @@ pub struct CaTarEncoder<'a, W: Write> { current_path: PathBuf, // used for error reporting writer: &'a mut W, writer_pos: usize, - size: usize, + _size: usize, file_copy_buffer: Vec, devices: Option>, } @@ -55,7 +55,7 @@ impl <'a, W: Write> CaTarEncoder<'a, W> { current_path: path, writer: writer, writer_pos: 0, - size: 0, + _size: 0, file_copy_buffer, devices: None, }; @@ -553,36 +553,36 @@ nix::ioctl_read!(read_fat_attr_fd, b'r', 0x10, u32); // from /usr/include/linux/magic.h // and from casync util.h -const BINFMTFS_MAGIC: i64 = 0x42494e4d; -const CGROUP2_SUPER_MAGIC: i64 = 0x63677270; -const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb; -const CONFIGFS_MAGIC: i64 = 0x62656570; -const DEBUGFS_MAGIC: i64 = 0x64626720; -const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1; -const EFIVARFS_MAGIC: i64 = 0xde5e81e4; -const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543; -const HUGETLBFS_MAGIC: i64 = 0x958458f6; -const MQUEUE_MAGIC: i64 = 0x19800202; -const NFSD_MAGIC: i64 = 0x6e667364; -const PROC_SUPER_MAGIC: i64 = 0x00009fa0; -const PSTOREFS_MAGIC: i64 = 0x6165676C; -const RPCAUTH_GSSMAGIC: i64 = 0x67596969; -const SECURITYFS_MAGIC: i64 = 0x73636673; -const SELINUX_MAGIC: i64 = 0xf97cff8c; -const SMACK_MAGIC: i64 = 0x43415d53; -const RAMFS_MAGIC: i64 = 0x858458f6; -const TMPFS_MAGIC: i64 = 0x01021994; -const SYSFS_MAGIC: i64 = 0x62656572; -const MSDOS_SUPER_MAGIC: i64 = 0x00004d44; -const FUSE_SUPER_MAGIC: i64 = 0x65735546; +pub const BINFMTFS_MAGIC: i64 = 0x42494e4d; +pub const CGROUP2_SUPER_MAGIC: i64 = 0x63677270; +pub const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb; +pub const CONFIGFS_MAGIC: i64 = 0x62656570; +pub const DEBUGFS_MAGIC: i64 = 0x64626720; +pub const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1; +pub const EFIVARFS_MAGIC: i64 = 0xde5e81e4; +pub const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543; +pub const HUGETLBFS_MAGIC: i64 = 0x958458f6; +pub const MQUEUE_MAGIC: i64 = 0x19800202; +pub const NFSD_MAGIC: i64 = 0x6e667364; +pub const PROC_SUPER_MAGIC: i64 = 0x00009fa0; +pub const PSTOREFS_MAGIC: i64 = 0x6165676C; +pub const RPCAUTH_GSSMAGIC: i64 = 0x67596969; +pub const SECURITYFS_MAGIC: i64 = 0x73636673; +pub const SELINUX_MAGIC: i64 = 0xf97cff8c; +pub const SMACK_MAGIC: i64 = 0x43415d53; +pub const RAMFS_MAGIC: i64 = 0x858458f6; +pub const TMPFS_MAGIC: i64 = 0x01021994; +pub const SYSFS_MAGIC: i64 = 0x62656572; +pub const MSDOS_SUPER_MAGIC: i64 = 0x00004d44; +pub const FUSE_SUPER_MAGIC: i64 = 0x65735546; #[inline(always)] -fn is_temporary_file_system(magic: i64) -> bool { +pub fn is_temporary_file_system(magic: i64) -> bool { magic == RAMFS_MAGIC || magic == TMPFS_MAGIC } -fn is_virtual_file_system(magic: i64) -> bool { +pub fn is_virtual_file_system(magic: i64) -> bool { match magic { BINFMTFS_MAGIC | diff --git a/src/client/http_client.rs b/src/client/http_client.rs index c8769c92..22f1857b 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -78,13 +78,8 @@ impl HttpClient { pub fn upload(&self, content_type: &str, body: Body, path: &str) -> Result { - let client = Client::new(); - let url: Uri = format!("http://{}:8007/{}", self.server, path).parse()?; - use http::Request; - use futures::stream::Stream; - let request = Request::builder() .method("POST") .uri(url) diff --git a/src/tools/ticket.rs b/src/tools/ticket.rs index 1443e791..1c48a4c8 100644 --- a/src/tools/ticket.rs +++ b/src/tools/ticket.rs @@ -1,12 +1,8 @@ //! Generate and verify Authentification tickets -use crate::tools; - use failure::*; -use std::path::PathBuf; use base64; -use openssl::rsa::{Rsa}; use openssl::pkey::{PKey, Public, Private}; use openssl::sign::{Signer, Verifier}; use openssl::hash::MessageDigest; diff --git a/src/tools/wrapped_reader_stream.rs b/src/tools/wrapped_reader_stream.rs index 77611612..06b3929e 100644 --- a/src/tools/wrapped_reader_stream.rs +++ b/src/tools/wrapped_reader_stream.rs @@ -1,4 +1,4 @@ -use failure::*; +//use failure::*; use tokio_threadpool; use std::io::Read; use futures::Async; @@ -40,7 +40,7 @@ impl Stream for WrappedReaderStream { }, Ok(Async::Ready(Err(err))) => Err(err), Ok(Async::NotReady) => Ok(Async::NotReady), - Err(err) => Err(blocking_err()), + Err(_) => Err(blocking_err()), } } }