Skip to content

Commit 6e6124a

Browse files
committed
Fix even more Clippy and other compiler warnings
1 parent e1a9be2 commit 6e6124a

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

src/existing_dirs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub struct ExistingUserDirectory {
113113
/// Finds existing user folders on disk. Will only return locations that actually have files in them, and a really basic check to see if the data is valid.
114114
pub fn find_existing_user_dirs() -> Vec<ExistingUserDirectory> {
115115
let mut user_dirs = Vec::new();
116+
#[allow(deprecated)] // We still want std::env::home_dir
116117
let Some(_) = home_dir() else {
117118
return user_dirs;
118119
};
@@ -177,9 +178,10 @@ pub fn find_existing_user_dirs() -> Vec<ExistingUserDirectory> {
177178
}
178179

179180
fn from_home_dir(path: &'static str) -> String {
181+
#[allow(deprecated)] // We still want std::env::home_dir
180182
let mut new_path = home_dir().unwrap();
181183
new_path.push(path);
182-
return new_path.into_os_string().into_string().unwrap();
184+
new_path.into_os_string().into_string().unwrap()
183185
}
184186

185187
fn is_valid_game_dir(path: &String) -> bool {

src/gamedata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl GameData {
187187
Some((entry, chunk)) => {
188188
let mut dat_file = self.get_dat_file(path, chunk, entry.data_file_id.into())?;
189189

190-
dat_file.read_from_offset(entry.offset as u64)
190+
dat_file.read_from_offset(entry.offset)
191191
}
192192
None => None,
193193
}

src/patch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::ByteBuffer;
1414

1515
use crate::common::{get_platform_string, Platform, Region};
1616
use crate::common_file_operations::{get_string_len, read_bool_from, read_string, write_bool_as, write_string};
17-
use crate::shpk::ShaderPackage;
1817
use crate::sqpack::{read_data_block_patch, write_data_block_patch};
1918

2019
#[binrw]
@@ -734,13 +733,13 @@ impl ZiPatch {
734733
add_file_chunk.write(&mut writer).ok()?;
735734

736735
// reverse reading crc32
737-
writer.seek(SeekFrom::Current(-4));
736+
writer.seek(SeekFrom::Current(-4)).ok()?;
738737

739738
// add file data, dummy ver for now
740739
write_data_block_patch(&mut writer, file_data);
741740

742741
// re-apply crc32
743-
writer.seek(SeekFrom::Current(4));
742+
writer.seek(SeekFrom::Current(4)).ok()?;
744743
}
745744

746745
// Process deleted files

src/patchlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl PatchList {
9696
id: "".to_string(),
9797
content_location: "".to_string(),
9898
requested_version: "".to_string(),
99-
patch_length: patch_length,
99+
patch_length,
100100
patches,
101101
}
102102
}
@@ -155,7 +155,7 @@ impl PatchList {
155155
str.push_str(&patch.hashes[0]);
156156
for hash in &patch.hashes[1..] {
157157
str.push(',');
158-
str.push_str(&hash);
158+
str.push_str(hash);
159159
}
160160
str.push('\t');
161161
}

src/sha1.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,6 @@ impl Sha1 {
283283

284284
Digest { data: state }
285285
}
286-
287-
/// Retrieve the digest result as hex string directly.
288-
///
289-
/// (The function is only available if the `std` feature is enabled)
290-
#[cfg(feature = "std")]
291-
pub fn hexdigest(&self) -> std::string::String {
292-
use std::string::ToString;
293-
self.digest().to_string()
294-
}
295286
}
296287

297288
impl Digest {

src/sqpack.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn read_data_block_patch<T: Read + Seek>(mut buf: T) -> Option<Vec<u8>> {
7676
}
7777

7878
pub fn write_data_block_patch<T: Write + Seek>(mut writer: T, data: Vec<u8>) {
79-
let new_file_size: usize = (data.len() as usize + 143) & 0xFFFFFF80;
79+
let new_file_size: usize = (data.len() + 143) & 0xFFFFFF80;
8080

8181
// This only adds uncompressed data for now, to simplify implementation
8282
// TODO: write compressed blocks
@@ -86,8 +86,8 @@ pub fn write_data_block_patch<T: Write + Seek>(mut writer: T, data: Vec<u8>) {
8686
file_size: data.len() as i32,
8787
},
8888
};
89-
block_header.write(&mut writer);
89+
block_header.write(&mut writer).unwrap();
9090

91-
data.write(&mut writer);
91+
data.write(&mut writer).unwrap();
9292
}
9393

0 commit comments

Comments
 (0)