mirror of
https://github.com/NinjaCheetah/rustii.git
synced 2026-03-17 06:47:49 -04:00
Correct lots of weak warnings, fix CI
This commit is contained in:
@@ -81,9 +81,9 @@ impl ContentRegion {
|
||||
return Err(ContentError::MissingContents { required: content_records.len(), found: contents.len()});
|
||||
}
|
||||
let mut content_region = Self::new(content_records)?;
|
||||
for i in 0..contents.len() {
|
||||
let target_index = content_region.content_records[i].index;
|
||||
content_region.load_enc_content(&contents[i], target_index as usize)?;
|
||||
for (index, content) in contents.iter().enumerate() {
|
||||
let target_index = content_region.content_records[index].index;
|
||||
content_region.load_enc_content(content, target_index as usize)?;
|
||||
}
|
||||
Ok(content_region)
|
||||
}
|
||||
@@ -213,15 +213,15 @@ impl ContentRegion {
|
||||
}
|
||||
self.content_records[index].content_size = content_size;
|
||||
self.content_records[index].content_hash = content_hash;
|
||||
if cid.is_some() {
|
||||
if let Some(cid) = cid {
|
||||
// Make sure that the new CID isn't already in use.
|
||||
if self.content_records.iter().any(|record| record.content_id == cid.unwrap()) {
|
||||
return Err(ContentError::CIDAlreadyExists(cid.unwrap()));
|
||||
if self.content_records.iter().any(|record| record.content_id == cid) {
|
||||
return Err(ContentError::CIDAlreadyExists(cid));
|
||||
}
|
||||
self.content_records[index].content_id = cid.unwrap();
|
||||
self.content_records[index].content_id = cid;
|
||||
}
|
||||
if content_type.is_some() {
|
||||
self.content_records[index].content_type = content_type.unwrap();
|
||||
if let Some(content_type) = content_type {
|
||||
self.content_records[index].content_type = content_type;
|
||||
}
|
||||
self.contents[index] = content.to_vec();
|
||||
Ok(())
|
||||
@@ -320,12 +320,18 @@ pub struct SharedContentMap {
|
||||
pub records: Vec<ContentMapEntry>,
|
||||
}
|
||||
|
||||
impl Default for SharedContentMap {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SharedContentMap {
|
||||
/// Creates a new SharedContentMap instance from the binary data of a content.map file.
|
||||
pub fn from_bytes(data: &[u8]) -> Result<SharedContentMap, ContentError> {
|
||||
// The uid.sys file must be divisible by a multiple of 28, or something is wrong, since each
|
||||
// entry is 28 bytes long.
|
||||
if (data.len() % 28) != 0 {
|
||||
if !data.len().is_multiple_of(28) {
|
||||
return Err(ContentError::InvalidSharedContentMapLength);
|
||||
}
|
||||
let record_count = data.len() / 28;
|
||||
|
||||
@@ -190,8 +190,8 @@ impl Title {
|
||||
/// Sets a new Title ID for the Title. This will re-encrypt the Title Key in the Ticket, since
|
||||
/// the Title ID is used as the IV for decrypting the Title Key.
|
||||
pub fn set_title_id(&mut self, title_id: [u8; 8]) -> Result<(), TitleError> {
|
||||
self.tmd.set_title_id(title_id)?;
|
||||
self.ticket.set_title_id(title_id)?;
|
||||
self.tmd.set_title_id(title_id);
|
||||
self.ticket.set_title_id(title_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ pub fn download_tmd(title_id: [u8; 8], title_version: Option<u16>, wiiu_endpoint
|
||||
} else {
|
||||
WII_NUS_ENDPOINT.to_owned()
|
||||
};
|
||||
let tmd_url = if title_version.is_some() {
|
||||
format!("{}{}/tmd.{}", endpoint_url, &hex::encode(title_id), title_version.unwrap())
|
||||
let tmd_url = if let Some(title_version) = title_version {
|
||||
format!("{}{}/tmd.{}", endpoint_url, &hex::encode(title_id), title_version)
|
||||
} else {
|
||||
format!("{}{}/tmd", endpoint_url, &hex::encode(title_id))
|
||||
};
|
||||
|
||||
@@ -320,10 +320,9 @@ impl Ticket {
|
||||
|
||||
/// Sets a new Title ID for the Ticket. This will re-encrypt the Title Key, since the Title ID
|
||||
/// is used as the IV for decrypting the Title Key.
|
||||
pub fn set_title_id(&mut self, title_id: [u8; 8]) -> Result<(), TicketError> {
|
||||
pub fn set_title_id(&mut self, title_id: [u8; 8]) {
|
||||
let new_enc_title_key = crypto::encrypt_title_key(self.title_key_dec(), self.common_key_index, title_id, self.is_dev());
|
||||
self.title_key = new_enc_title_key;
|
||||
self.title_id = title_id;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@ impl TMD {
|
||||
}
|
||||
|
||||
/// Sets the content records in the TMD.
|
||||
pub fn set_content_records(&mut self, content_records: &Vec<ContentRecord>) {
|
||||
self.content_records = content_records.clone()
|
||||
pub fn set_content_records(&mut self, content_records: &[ContentRecord]) {
|
||||
self.content_records = content_records.to_vec();
|
||||
}
|
||||
|
||||
/// Gets whether a TMD is fakesigned using the strncmp (trucha) bug or not.
|
||||
@@ -449,9 +449,8 @@ impl TMD {
|
||||
}
|
||||
|
||||
/// Sets a new Title ID for a TMD.
|
||||
pub fn set_title_id(&mut self, title_id: [u8; 8]) -> Result<(), TMDError> {
|
||||
pub fn set_title_id(&mut self, title_id: [u8; 8]) {
|
||||
self.title_id = title_id;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Gets the Title ID of the IOS required by a TMD.
|
||||
|
||||
Reference in New Issue
Block a user