Cargo clippy fixes

This commit is contained in:
Jackson Coxson
2025-07-30 15:06:58 -06:00
parent cb36f510ec
commit 182ec10dc2
10 changed files with 23 additions and 24 deletions

View File

@@ -33,6 +33,8 @@ jobs:
- name: Build all Apple targets and examples/tools - name: Build all Apple targets and examples/tools
run: | run: |
export HOMEBREW_PREFIX=$(brew --prefix)
export CXXFLAGS="-I$HOMEBREW_PREFIX/include"
just macos-ci-check just macos-ci-check
- name: Upload static libraries - name: Upload static libraries

View File

@@ -18,8 +18,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
find_package(PkgConfig REQUIRED)
# Find all C++ example files # Find all C++ example files
file(GLOB EXAMPLE_SOURCES ${EXAMPLES_DIR}/*.cpp) file(GLOB EXAMPLE_SOURCES ${EXAMPLES_DIR}/*.cpp)
@@ -39,7 +37,6 @@ foreach(EXAMPLE_FILE ${EXAMPLE_SOURCES})
# Link the static Rust library # Link the static Rust library
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${STATIC_LIB}) target_link_libraries(${EXAMPLE_NAME} PRIVATE ${STATIC_LIB})
# Bulk-link common macOS system frameworks # Bulk-link common macOS system frameworks
if(APPLE) if(APPLE)
target_link_libraries(${EXAMPLE_NAME} PRIVATE target_link_libraries(${EXAMPLE_NAME} PRIVATE

View File

@@ -219,7 +219,7 @@ fn ensure_pem_headers(data: &[u8], pem_type: &str) -> Vec<u8> {
let mut result = Vec::new(); let mut result = Vec::new();
// Add header // Add header
let header = format!("-----BEGIN {}-----\n", pem_type); let header = format!("-----BEGIN {pem_type}-----\n");
result.extend_from_slice(header.as_bytes()); result.extend_from_slice(header.as_bytes());
// Add base64 content with line breaks every 64 characters // Add base64 content with line breaks every 64 characters
@@ -244,7 +244,7 @@ fn ensure_pem_headers(data: &[u8], pem_type: &str) -> Vec<u8> {
result.push(b'\n'); result.push(b'\n');
// Add footer // Add footer
let footer = format!("-----END {}-----", pem_type); let footer = format!("-----END {pem_type}-----");
result.extend_from_slice(footer.as_bytes()); result.extend_from_slice(footer.as_bytes());
result result

View File

@@ -66,7 +66,7 @@ impl std::fmt::Display for AfcError {
AfcError::NotEnoughData => "Not enough data", AfcError::NotEnoughData => "Not enough data",
AfcError::DirNotEmpty => "Directory not empty", AfcError::DirNotEmpty => "Directory not empty",
}; };
write!(f, "{}", description) write!(f, "{description}")
} }
} }

View File

@@ -107,10 +107,10 @@ impl<R: ReadWrite> DebugProxyClient<R> {
let checksum = calculate_checksum(&packet_data); let checksum = calculate_checksum(&packet_data);
// Construct the full packet // Construct the full packet
let packet = format!("${}#{}", packet_data, checksum); let packet = format!("${packet_data}#{checksum}");
// Log the packet for debugging // Log the packet for debugging
debug!("Sending packet: {}", packet); debug!("Sending packet: {packet}");
// Send the packet // Send the packet
self.socket.write_all(packet.as_bytes()).await?; self.socket.write_all(packet.as_bytes()).await?;
@@ -237,7 +237,7 @@ impl<R: ReadWrite> DebugProxyClient<R> {
// Hex encode the argument // Hex encode the argument
for byte in arg.bytes() { for byte in arg.bytes() {
let hex = format!("{:02X}", byte); let hex = format!("{byte:02X}");
pkt[pktp..pktp + 2].copy_from_slice(hex.as_bytes()); pkt[pktp..pktp + 2].copy_from_slice(hex.as_bytes());
pktp += 2; pktp += 2;
} }
@@ -290,7 +290,7 @@ impl<R: ReadWrite> DebugProxyClient<R> {
/// between '$' and '#', formatted as two lowercase hex digits. /// between '$' and '#', formatted as two lowercase hex digits.
fn calculate_checksum(data: &str) -> String { fn calculate_checksum(data: &str) -> String {
let checksum = data.bytes().fold(0u8, |acc, byte| acc.wrapping_add(byte)); let checksum = data.bytes().fold(0u8, |acc, byte| acc.wrapping_add(byte));
format!("{:02x}", checksum) format!("{checksum:02x}")
} }
/// Hex-encodes bytes as uppercase string /// Hex-encodes bytes as uppercase string

View File

@@ -501,15 +501,15 @@ impl Message {
impl std::fmt::Debug for AuxValue { impl std::fmt::Debug for AuxValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
AuxValue::String(s) => write!(f, "String({:?})", s), AuxValue::String(s) => write!(f, "String({s:?})"),
AuxValue::Array(arr) => write!( AuxValue::Array(arr) => write!(
f, f,
"Array(len={}, first_bytes={:?})", "Array(len={}, first_bytes={:?})",
arr.len(), arr.len(),
&arr[..arr.len().min(10)] &arr[..arr.len().min(10)]
), // Show only first 10 bytes ), // Show only first 10 bytes
AuxValue::U32(n) => write!(f, "U32({})", n), AuxValue::U32(n) => write!(f, "U32({n})"),
AuxValue::I64(n) => write!(f, "I64({})", n), AuxValue::I64(n) => write!(f, "I64({n})"),
} }
} }
} }

View File

@@ -101,8 +101,8 @@ mod tests {
async fn test_get_tunneld_devices() { async fn test_get_tunneld_devices() {
let host = SocketAddr::new(IpAddr::from_str("127.0.0.1").unwrap(), DEFAULT_PORT); let host = SocketAddr::new(IpAddr::from_str("127.0.0.1").unwrap(), DEFAULT_PORT);
match get_tunneld_devices(host).await { match get_tunneld_devices(host).await {
Ok(devices) => println!("Found tunneld devices: {:#?}", devices), Ok(devices) => println!("Found tunneld devices: {devices:#?}"),
Err(e) => println!("Error querying tunneld: {}", e), Err(e) => println!("Error querying tunneld: {e}"),
} }
} }
} }

View File

@@ -103,25 +103,25 @@ fn print_plist(p: &Value, indentation: usize) -> String {
.collect(); .collect();
format!("{{\n{}\n{}}}", items.join(",\n"), indent) format!("{{\n{}\n{}}}", items.join(",\n"), indent)
} }
Value::Boolean(b) => format!("{}", b), Value::Boolean(b) => format!("{b}"),
Value::Data(vec) => { Value::Data(vec) => {
let len = vec.len(); let len = vec.len();
let preview: String = vec let preview: String = vec
.iter() .iter()
.take(20) .take(20)
.map(|b| format!("{:02X}", b)) .map(|b| format!("{b:02X}"))
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(" "); .join(" ");
if len > 20 { if len > 20 {
format!("Data({}... Len: {})", preview, len) format!("Data({preview}... Len: {len})")
} else { } else {
format!("Data({} Len: {})", preview, len) format!("Data({preview} Len: {len})")
} }
} }
Value::Date(date) => format!("Date({})", date.to_xml_format()), Value::Date(date) => format!("Date({})", date.to_xml_format()),
Value::Real(f) => format!("{}", f), Value::Real(f) => format!("{f}"),
Value::Integer(i) => format!("{}", i), Value::Integer(i) => format!("{i}"),
Value::String(s) => format!("\"{}\"", s), Value::String(s) => format!("\"{s}\""),
Value::Uid(_uid) => "Uid(?)".to_string(), Value::Uid(_uid) => "Uid(?)".to_string(),
_ => "Unknown".to_string(), _ => "Unknown".to_string(),
} }

View File

@@ -529,7 +529,7 @@ impl std::fmt::Debug for XPCMessage {
let known_mask = 0x00000001 | 0x00000100 | 0x00010000 | 0x00400000; let known_mask = 0x00000001 | 0x00000100 | 0x00010000 | 0x00400000;
let custom_bits = self.flags & !known_mask; let custom_bits = self.flags & !known_mask;
if custom_bits != 0 { if custom_bits != 0 {
parts.push(format!("Custom(0x{:08X})", custom_bits)); parts.push(format!("Custom(0x{custom_bits:08X})"));
} }
write!( write!(

View File

@@ -45,7 +45,7 @@ xcframework: apple-build
-library swift/libs/idevice-macos.a -headers swift/include \ -library swift/libs/idevice-macos.a -headers swift/include \
-output swift/IDevice.xcframework -output swift/IDevice.xcframework
zip -r bundle.zip IDevice.xcframework zip -r bundle.zip swift/IDevice.xcframework
openssl dgst -sha256 bundle.zip openssl dgst -sha256 bundle.zip
[working-directory: 'ffi'] [working-directory: 'ffi']