Bug 1413639: u2f-hid-rs: Remove unnecessary mut annotation. r?jcj draft
authorRalph Giles <giles@mozilla.com>
Wed, 01 Nov 2017 11:19:58 -0700
changeset 690137 46927fe5fa9071ca7ae298542480d1ed5e06bfb9
parent 690034 cd7217cf05a2332a8fd7b498767a07b2c31ea657
child 738507 c0cfa795e836e74f16362d772a519e3bbc731a6e
push id87230
push userbmo:giles@thaumas.net
push dateWed, 01 Nov 2017 18:37:37 +0000
reviewersjcj
bugs1413639
milestone58.0a1
Bug 1413639: u2f-hid-rs: Remove unnecessary mut annotation. r?jcj Fix a warning when building for windows targets. Data here doesn't need to be mutable. The contents of the struct are modified inside the unsafe block, and that's allowed because libc::malloc() returns a *mut. But the value of the binding itself, that is, the location in memory that data references, never changes. MozReview-Commit-ID: 3l2IL5xXvjF
dom/webauthn/u2f-hid-rs/src/windows/winapi.rs
--- a/dom/webauthn/u2f-hid-rs/src/windows/winapi.rs
+++ b/dom/webauthn/u2f-hid-rs/src/windows/winapi.rs
@@ -190,17 +190,17 @@ impl DeviceInterfaceDetailData {
             cb_size = 4 + 2; // 4-byte uint + default TCHAR size. size_of is inaccurate.
         }
 
         if size < cb_size {
             warn!("DeviceInterfaceDetailData is too small. {}", size);
             return None;
         }
 
-        let mut data = unsafe { libc::malloc(size) as PSP_DEVICE_INTERFACE_DETAIL_DATA_W };
+        let data = unsafe { libc::malloc(size) as PSP_DEVICE_INTERFACE_DETAIL_DATA_W };
         if data.is_null() {
             return None;
         }
 
         // Set total size of the structure.
         unsafe { (*data).cbSize = cb_size as UINT };
 
         // Compute offset of `SP_DEVICE_INTERFACE_DETAIL_DATA_W.DevicePath`.