Skip to content

Commit d01ed83

Browse files
committed
binding: fix double reference clone warnings
example warning: warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type --> pulse-binding/src/context/ext_device_manager.rs:201:44 | 201 | c_devs.push(CString::new(device.clone()).unwrap()); | ^^^^^^^^ | = note: `#[warn(suspicious_double_ref_op)]` on by default
1 parent 489edd5 commit d01ed83

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

pulse-binding/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# unreleased]
22

3+
* Fixed 'double-reference clone' warnings.
34
* Dropped PA v4 support.
45

56
# 2.27.1 (January 9th, 2023)

pulse-binding/src/context/ext_device_manager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl DeviceManager {
198198
// as_ptr() giving dangling pointers!
199199
let mut c_devs: Vec<CString> = Vec::with_capacity(devices.len());
200200
for device in devices {
201-
c_devs.push(CString::new(device.clone()).unwrap());
201+
c_devs.push(CString::new(*device).unwrap());
202202
}
203203

204204
// Capture array of pointers to the above CString values.
@@ -246,7 +246,7 @@ impl DeviceManager {
246246
let c_role = CString::new(role.clone()).unwrap();
247247
let mut c_devs: Vec<CString> = Vec::with_capacity(devices.len());
248248
for device in devices {
249-
c_devs.push(CString::new(device.clone()).unwrap());
249+
c_devs.push(CString::new(*device).unwrap());
250250
}
251251

252252
// Capture array of pointers to the above CString values.

pulse-binding/src/context/ext_stream_restore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl StreamRestore {
156156
// as_ptr() giving dangling pointers!
157157
let mut c_streams: Vec<CString> = Vec::with_capacity(streams.len());
158158
for stream in streams {
159-
c_streams.push(CString::new(stream.clone()).unwrap());
159+
c_streams.push(CString::new(*stream).unwrap());
160160
}
161161

162162
// Capture array of pointers to the above CString values.

pulse-binding/src/context/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl Context {
507507
// as_ptr() giving dangling pointers!
508508
let mut c_keys: Vec<CString> = Vec::with_capacity(keys.len());
509509
for key in keys {
510-
c_keys.push(CString::new(key.clone()).unwrap());
510+
c_keys.push(CString::new(*key).unwrap());
511511
}
512512

513513
// Capture array of pointers to the above CString values.

pulse-binding/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl Info {
526526
let c_key = CString::new(key.clone()).unwrap();
527527
let mut c_values: Vec<CString> = Vec::with_capacity(values.len());
528528
for v in values {
529-
c_values.push(CString::new(v.clone()).unwrap());
529+
c_values.push(CString::new(*v).unwrap());
530530
}
531531

532532
// Capture array of pointers to the above CString values

pulse-binding/src/proplist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl Proplist {
372372
// as_ptr() giving dangling pointers!
373373
let mut c_keys: Vec<CString> = Vec::with_capacity(keys.len());
374374
for k in keys {
375-
c_keys.push(CString::new(k.clone()).unwrap());
375+
c_keys.push(CString::new(*k).unwrap());
376376
}
377377

378378
// Capture array of pointers to the above CString values.

pulse-binding/src/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ impl Stream {
17521752
// as_ptr() giving dangling pointers!
17531753
let mut c_keys: Vec<CString> = Vec::with_capacity(keys.len());
17541754
for key in keys {
1755-
c_keys.push(CString::new(key.clone()).unwrap());
1755+
c_keys.push(CString::new(*key).unwrap());
17561756
}
17571757

17581758
// Capture array of pointers to the above CString values

0 commit comments

Comments
 (0)