Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekmedia committed Apr 14, 2024
1 parent 9c5eb06 commit 021fa39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/rust/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ pub struct CcxOptions {
}

impl CcxOptions {
pub fn to_ctype(&self, options: *mut ccx_s_options) {
pub unsafe fn to_ctype(&self, options: *mut ccx_s_options) {
unsafe {
(*options).extract = if let Some(value) = self.extract {
value
Expand Down
22 changes: 11 additions & 11 deletions src/rust/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use num_integer::Integer;
use std::convert::TryInto;
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::ptr::addr_of_mut;
use std::string::String;

use cfg_if::cfg_if;
Expand Down Expand Up @@ -132,7 +133,7 @@ where
}
}

fn process_word_file(filename: &str, list: &mut Vec<String>) -> Result<(), std::io::Error> {
unsafe fn process_word_file(filename: &str, list: *mut Vec<String>) -> Result<(), std::io::Error> {
let file = File::open(filename)?;
let reader = BufReader::new(file);
let mut num = 0;
Expand All @@ -154,7 +155,7 @@ fn process_word_file(filename: &str, list: &mut Vec<String>) -> Result<(), std::
}

if new_len > 0 {
list.push(line.trim().to_string());
(*list).push(line.trim().to_string());
}
}
Ok(())
Expand Down Expand Up @@ -397,7 +398,7 @@ impl CcxOptions {
}

fn append_file_to_queue(&mut self, filename: &str) -> i32 {
if filename.len() == 0 {
if filename.is_empty() {
return 0;
}

Expand Down Expand Up @@ -440,7 +441,7 @@ impl CcxOptions {
}
if n == -1 {
// None. No expansion needed
return self.append_file_to_queue(&filename);
return self.append_file_to_queue(filename);
}

let mut m: i32 = n;
Expand Down Expand Up @@ -494,14 +495,13 @@ impl CcxOptions {
}
if let Some(ref files) = args.inputfile {
for inputfile in files {
let rc: i32;
let plus_sign = '+';

if !inputfile.ends_with(plus_sign) {
rc = self.append_file_to_queue(&inputfile);
let rc: i32 = if !inputfile.ends_with(plus_sign) {
self.append_file_to_queue(inputfile)
} else {
rc = self.add_file_sequence(&mut inputfile.clone());
}
self.add_file_sequence(&mut inputfile.clone())
};

if rc < 0 {
println!("Fatal: Not enough memory to parse parameters.\n");
Expand Down Expand Up @@ -1361,7 +1361,7 @@ impl CcxOptions {
unsafe {
CAPITALIZATION_LIST = get_vector_words(&CAPITALIZED_BUILTIN);
if let Some(ref sentence_cap_file) = self.sentence_cap_file {
process_word_file(sentence_cap_file, &mut CAPITALIZATION_LIST)
process_word_file(sentence_cap_file, addr_of_mut!(CAPITALIZATION_LIST))
.expect("There was an error processing the capitalization file.\n");
}
}
Expand All @@ -1370,7 +1370,7 @@ impl CcxOptions {
unsafe {
PROFANE = get_vector_words(&PROFANE_BUILTIN);
if let Some(ref profanityfile) = self.filter_profanity_file {
process_word_file(profanityfile.as_str(), &mut PROFANE)
process_word_file(profanityfile.as_str(), addr_of_mut!(PROFANE))
.expect("There was an error processing the profanity file.\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn string_to_c_chars(strs: Vec<String>) -> *mut *mut c_char {
for s in &cstr_vec {
c_char_vec.push(s.as_ptr());
}
let ptr = c_char_vec.as_ptr() as *const *const c_char;
let ptr = c_char_vec.as_ptr();

std::mem::forget(cstr_vec);
std::mem::forget(c_char_vec);
Expand Down

0 comments on commit 021fa39

Please sign in to comment.