Skip to content

Commit

Permalink
misc: clippy cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Feb 29, 2024
1 parent 4bd10b1 commit 043cd13
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 74 deletions.
File renamed without changes.
5 changes: 0 additions & 5 deletions src/elastic/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use time::macros::format_description;
pub trait Request {
fn push_filter(&mut self, filter: serde_json::Value);
fn size(&mut self, size: u64);
fn set_filters(&mut self, filters: Vec<serde_json::Value>);
}

impl Request for serde_json::Value {
Expand All @@ -19,10 +18,6 @@ impl Request for serde_json::Value {
fn size(&mut self, size: u64) {
self["size"] = size.into();
}

fn set_filters(&mut self, filters: Vec<serde_json::Value>) {
self["query"]["bool"]["filter"] = filters.into();
}
}

pub fn new_request() -> serde_json::Value {
Expand Down
1 change: 0 additions & 1 deletion src/eve/userfilters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: MIT

use serde::Deserialize;
use serde_yaml;
use serde_yaml::Value as YamlValue;
use std::collections::HashMap;
use tracing::error;
Expand Down
61 changes: 0 additions & 61 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,3 @@ pub(crate) fn file_size(filename: &str) -> anyhow::Result<u64> {
let meta = std::fs::metadata(filename)?;
Ok(meta.len())
}

#[derive(Debug)]
pub struct FsUsage {
pub bytes_free: u64,
pub bytes_used: u64,
pub bytes_total: u64,
pub percent_used: u64,
pub percent_free: u64,
}

#[cfg(target_family = "unix")]
pub mod unix {
use super::FsUsage;
use libc::statvfs;

pub fn _fs_usage(filename: &str) -> anyhow::Result<FsUsage> {
let filename = std::ffi::CString::new(filename)?;
unsafe {
let mut sfs: statvfs = std::mem::zeroed();
if statvfs(filename.as_ptr(), &mut sfs) != 0 {
anyhow::bail!("statfs failed");
}
#[allow(clippy::unnecessary_cast)]
let block_size = sfs.f_bsize as u64;
#[allow(clippy::unnecessary_cast)]
let bytes_total = sfs.f_blocks as u64 * block_size;
#[allow(clippy::unnecessary_cast)]
let bytes_free = sfs.f_bavail as u64 * block_size;
let bytes_used = bytes_total - bytes_free;
let percent_used = bytes_used * 100 / bytes_total;
let percent_free = 100 - percent_used;
Ok(FsUsage {
bytes_free,
bytes_used,
bytes_total,
percent_used,
percent_free,
})
}
}
}

#[cfg(target_family = "unix")]
pub fn _has_fs_usage() -> bool {
true
}

#[cfg(not(target_family = "unix"))]
pub fn _has_fs_usage() -> bool {
false
}

#[cfg(target_family = "unix")]
pub fn _fs_usage(filename: &str) -> anyhow::Result<FsUsage> {
unix::_fs_usage(filename)
}

#[cfg(not(target_family = "unix"))]
pub fn _fs_usage(_filename: &str) -> anyhow::Result<FsUsage> {
unimplemented!()
}
3 changes: 0 additions & 3 deletions src/server/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,6 @@ async fn configure_datastore(config: Config, server_config: &ServerConfig) -> Re
}
}

#[derive(Debug)]
pub enum GenericError {}

#[derive(Debug)]
pub(crate) struct SessionExtractor(pub(crate) Arc<Session>);

Expand Down
6 changes: 2 additions & 4 deletions src/sqlite/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ pub fn init_event_db(db: &mut Connection) -> Result<(), rusqlite::Error> {
if let Err(err) = db.pragma_update(None, "synchronous", "NORMAL") {
error!("Failed to set pragma synchronous = NORMAL: {:?}", err);
}
match db.pragma_query_value(None, "synchronous", |row| {
let val: i32 = row.get(0)?;
Ok(val)
}) {

match get_synchronous(db) {
Ok(mode) => {
if mode != 1 {
warn!("Database not in synchronous mode normal, instead: {}", mode);
Expand Down

0 comments on commit 043cd13

Please sign in to comment.