Fix Swift 6 warning about unused result

- Add explicit discarding of removeValue results in NoiseSession
- Remove unnecessary _ = from BluetoothMeshService sync block
- Ensures clean builds with no warnings (except AppIntents metadata)

The warning was caused by Swift 6 being stricter about unused
results from methods that return values inside sync blocks.
This commit is contained in:
jack
2025-07-22 11:38:20 +02:00
parent d804b93488
commit 9e035c9c14
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -255,7 +255,7 @@ class NoiseSessionManager {
func removeSession(for peerID: String) {
managerQueue.sync(flags: .barrier) {
sessions.removeValue(forKey: peerID)
_ = sessions.removeValue(forKey: peerID)
}
}
@@ -265,7 +265,7 @@ class NoiseSessionManager {
if let session = sessions[oldPeerID] {
// Move the session to the new peer ID
sessions[newPeerID] = session
sessions.removeValue(forKey: oldPeerID)
_ = sessions.removeValue(forKey: oldPeerID)
SecurityLogger.log("Migrated Noise session from \(oldPeerID) to \(newPeerID)", category: SecurityLogger.noise, level: .info)
}
@@ -290,7 +290,7 @@ class NoiseSessionManager {
// Remove any existing non-established session
if let existingSession = sessions[peerID], !existingSession.isEstablished() {
sessions.removeValue(forKey: peerID)
_ = sessions.removeValue(forKey: peerID)
}
// Create new initiator session
@@ -306,7 +306,7 @@ class NoiseSessionManager {
return handshakeData
} catch {
// Clean up failed session
sessions.removeValue(forKey: peerID)
_ = sessions.removeValue(forKey: peerID)
throw error
}
}
@@ -328,7 +328,7 @@ class NoiseSessionManager {
// If we're in the middle of a handshake and receive a new initiation,
// reset and start fresh (the other side may have restarted)
if existing.getState() == .handshaking && message.count == 32 {
sessions.removeValue(forKey: peerID)
_ = sessions.removeValue(forKey: peerID)
shouldCreateNew = true
} else {
existingSession = existing
@@ -369,7 +369,7 @@ class NoiseSessionManager {
return response
} catch {
// Reset the session on handshake failure so next attempt can start fresh
sessions.removeValue(forKey: peerID)
_ = sessions.removeValue(forKey: peerID)
// Schedule callback outside the synchronized block to prevent deadlock
DispatchQueue.global().async { [weak self] in
+1 -1
View File
@@ -883,7 +883,7 @@ class BluetoothMeshService: NSObject {
private func notifyPeerIDChange(oldPeerID: String, newPeerID: String, fingerprint: String) {
DispatchQueue.main.async { [weak self] in
// Remove old peer ID from active peers and announcedPeers
_ = self?.collectionsQueue.sync(flags: .barrier) {
self?.collectionsQueue.sync(flags: .barrier) {
self?.activePeers.remove(oldPeerID)
// Don't pre-insert the new peer ID - let the announce packet handle it
// This ensures the connect message logic works properly