Skip to content

Commit

Permalink
Merge pull request #555 from JakeRoggenbuck/add-forbid-unsafe_code-st…
Browse files Browse the repository at this point in the history
…atic-check-attr
  • Loading branch information
JakeRoggenbuck authored Apr 19, 2024
2 parents cd84ee0 + e1c20a0 commit 7a37686
Show file tree
Hide file tree
Showing 28 changed files with 213 additions and 303 deletions.
465 changes: 181 additions & 284 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{thread, time};
use structopt::StructOpt;

Expand Down
1 change: 1 addition & 0 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// https://github.com/autoclockspeed

#![allow(clippy::uninlined_format_args)]
#![forbid(unsafe_code)]

use autoclockspeed::args::parse_args;
use autoclockspeed::config::get_config;
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use super::daemon::State;
use super::{print_done, warn_user};
use crate::print_error;
Expand Down
1 change: 1 addition & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use efcl::{bold, color, Color};
use rand::Rng;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/csv.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! # CSV logging
//! This file is reponsible for logging data about the running daemon.
//! CSV Logging is by default disabled, however it can be enabled by passing a parameter to the
Expand Down
11 changes: 8 additions & 3 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! The daemon handles the running auto clock speed instance
//!
//! # Modes
Expand Down Expand Up @@ -57,7 +58,6 @@ use crate::system::{
check_available_governors, check_cpu_freq, check_cpu_temperature, check_cpu_usage,
get_highest_temp, inside_docker, inside_wsl, list_cpus,
};
use crate::terminal::terminal_width;
use crate::warn_user;

/// Describes the state of the machine
Expand Down Expand Up @@ -447,7 +447,7 @@ impl Checker for Daemon {
self.graph = self.grapher.update_one(&mut self.grapher.vals.clone());
}

let term_width = terminal_width();
let (term_width, _term_height) = termion::terminal_size().unwrap();

// Render two sections of the output
// Rendering before screen is cleared reduces the time between clear and print
Expand All @@ -473,7 +473,12 @@ impl Checker for Daemon {
// Print all pre-rendered items
print!("{}", preprint);

print_turbo_status(cores, self.settings.animation, term_width, delay_in_millis);
print_turbo_status(
cores,
self.settings.animation,
term_width.into(),
delay_in_millis,
);

// Print more pre-rendered items
print!("{}", postprint);
Expand Down
1 change: 1 addition & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use efcl::{color, Color};
use std::fmt::Display;
use std::thread;
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::fmt;

const BUG_REPORT: &str = "\nGive us a bug report by opening an issue at
Expand Down
1 change: 1 addition & 0 deletions src/gov.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::fmt;

/// Governor
Expand Down
1 change: 1 addition & 0 deletions src/graph.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use rasciigraph::{plot, Config};
use std::default::Default;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/interactive.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use super::config::{get_config, Config};
use super::interface::{DaemonControl, DaemonController, Get, Getter, Interface, Set, Setter};
use super::settings::Settings;
Expand Down
1 change: 1 addition & 0 deletions src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
///! The interface creates an API for getting and setting values with ACS
///!
///! Note: this is not an API for all of the functions in ACS, it's only the ones that get used in
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ pub mod settings;
pub mod setup;
pub mod sysfs;
pub mod system;
pub mod terminal;
pub mod thermal;
1 change: 1 addition & 0 deletions src/network.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use serde::{Deserialize, Serialize};

use crate::logger::Log;
Expand Down
1 change: 1 addition & 0 deletions src/network/hook.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use crate::network::{log_to_daemon, logger, Daemon, Packet};
use std::io::{BufRead, BufReader, Write};
use std::os::unix::net::UnixStream;
Expand Down
1 change: 1 addition & 0 deletions src/network/listen.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use crate::logger;
use crate::logger::Interface;
use crate::network::log_to_daemon;
Expand Down
1 change: 1 addition & 0 deletions src/network/send.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{
io::{BufRead, BufReader, Write},
os::unix::net::UnixStream,
Expand Down
1 change: 1 addition & 0 deletions src/power.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::fs;
use std::path::Path;

Expand Down
1 change: 1 addition & 0 deletions src/power/battery.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use crate::error::Error;
use crate::sysfs;
use std::any::Any;
Expand Down
1 change: 1 addition & 0 deletions src/power/lid.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use crate::error::Error;
use std::cmp::PartialEq;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/proc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::fs::read_to_string;

use crate::error::Error;
Expand Down
1 change: 1 addition & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use super::graph::GraphType;
use std::default::Default;

Expand Down
1 change: 1 addition & 0 deletions src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use super::config::config_dir_exists;
use super::system::{inside_docker, inside_wsl};
use super::warn_user;
Expand Down
1 change: 1 addition & 0 deletions src/sysfs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use crate::error::Error;
use globset::Glob;
use std::fs;
Expand Down
1 change: 1 addition & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use cached::proc_macro::once;
use std::fs::{self, read_dir};
use std::path::Path;
Expand Down
15 changes: 0 additions & 15 deletions src/terminal.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/thermal.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use super::system::{read_int, read_str};
use crate::error::Error;
use efcl::{color, Color};
Expand Down

0 comments on commit 7a37686

Please sign in to comment.