Skip to content

Commit a2874e6

Browse files
committed
Fix warning by removing now unnecessary explicit clone
1 parent da7ab68 commit a2874e6

File tree

11 files changed

+76
-76
lines changed

11 files changed

+76
-76
lines changed

pulse-binding/src/channelmap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl Position {
365365
pub fn from_string(s: &str) -> Self {
366366
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
367367
// as_ptr() giving dangling pointers!
368-
let c_str = CString::new(s.clone()).unwrap();
368+
let c_str = CString::new(s).unwrap();
369369
unsafe { capi::pa_channel_position_from_string(c_str.as_ptr()).into() }
370370
}
371371
}
@@ -381,7 +381,7 @@ impl Map {
381381
pub fn new_from_string(s: &str) -> Result<Self, ()> {
382382
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
383383
// as_ptr() giving dangling pointers!
384-
let c_str = CString::new(s.clone()).unwrap();
384+
let c_str = CString::new(s).unwrap();
385385
let mut map: Self = Self::default();
386386
unsafe {
387387
if capi::pa_channel_map_parse((&mut map).as_mut(), c_str.as_ptr()).is_null() {

pulse-binding/src/context/ext_device_manager.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ impl DeviceManager {
175175
{
176176
// Warning: New CStrings will be immediately freed if not bound to a
177177
// variable, leading to as_ptr() giving dangling pointers!
178-
let c_dev = CString::new(device.clone()).unwrap();
179-
let c_desc = CString::new(description.clone()).unwrap();
178+
let c_dev = CString::new(device).unwrap();
179+
let c_desc = CString::new(description).unwrap();
180180

181181
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(bool)>(Box::new(callback));
182182
let ptr = unsafe {
@@ -243,7 +243,7 @@ impl DeviceManager {
243243
{
244244
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
245245
// as_ptr() giving dangling pointers!
246-
let c_role = CString::new(role.clone()).unwrap();
246+
let c_role = CString::new(role).unwrap();
247247
let mut c_devs: Vec<CString> = Vec::with_capacity(devices.len());
248248
for device in devices {
249249
c_devs.push(CString::new(*device).unwrap());

pulse-binding/src/context/introspect.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl Introspector {
464464
{
465465
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
466466
// as_ptr() giving dangling pointers!
467-
let c_name = CString::new(name.clone()).unwrap();
467+
let c_name = CString::new(name).unwrap();
468468

469469
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(ListResult<&SinkInfo>)>(Box::new(callback));
470470
let ptr = unsafe { capi::pa_context_get_sink_info_by_name(self.context, c_name.as_ptr(),
@@ -522,7 +522,7 @@ impl Introspector {
522522
{
523523
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
524524
// as_ptr() giving dangling pointers!
525-
let c_name = CString::new(name.clone()).unwrap();
525+
let c_name = CString::new(name).unwrap();
526526

527527
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
528528
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -556,7 +556,7 @@ impl Introspector {
556556
{
557557
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
558558
// as_ptr() giving dangling pointers!
559-
let c_name = CString::new(name.clone()).unwrap();
559+
let c_name = CString::new(name).unwrap();
560560

561561
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
562562
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -575,7 +575,7 @@ impl Introspector {
575575
{
576576
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
577577
// as_ptr() giving dangling pointers!
578-
let c_name = CString::new(sink_name.clone()).unwrap();
578+
let c_name = CString::new(sink_name).unwrap();
579579

580580
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
581581
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -610,7 +610,7 @@ impl Introspector {
610610
{
611611
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
612612
// as_ptr() giving dangling pointers!
613-
let c_port = CString::new(port.clone()).unwrap();
613+
let c_port = CString::new(port).unwrap();
614614

615615
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
616616
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -629,8 +629,8 @@ impl Introspector {
629629
{
630630
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
631631
// as_ptr() giving dangling pointers!
632-
let c_name = CString::new(name.clone()).unwrap();
633-
let c_port = CString::new(port.clone()).unwrap();
632+
let c_name = CString::new(name).unwrap();
633+
let c_port = CString::new(port).unwrap();
634634

635635
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
636636
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -868,7 +868,7 @@ impl Introspector {
868868
{
869869
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
870870
// as_ptr() giving dangling pointers!
871-
let c_name = CString::new(name.clone()).unwrap();
871+
let c_name = CString::new(name).unwrap();
872872

873873
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(ListResult<&SourceInfo>)>(Box::new(callback));
874874
let ptr = unsafe { capi::pa_context_get_source_info_by_name(self.context, c_name.as_ptr(),
@@ -927,7 +927,7 @@ impl Introspector {
927927
{
928928
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
929929
// as_ptr() giving dangling pointers!
930-
let c_name = CString::new(name.clone()).unwrap();
930+
let c_name = CString::new(name).unwrap();
931931

932932
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
933933
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -961,7 +961,7 @@ impl Introspector {
961961
{
962962
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
963963
// as_ptr() giving dangling pointers!
964-
let c_name = CString::new(name.clone()).unwrap();
964+
let c_name = CString::new(name).unwrap();
965965

966966
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
967967
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -980,7 +980,7 @@ impl Introspector {
980980
{
981981
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
982982
// as_ptr() giving dangling pointers!
983-
let c_name = CString::new(name.clone()).unwrap();
983+
let c_name = CString::new(name).unwrap();
984984

985985
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
986986
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1015,7 +1015,7 @@ impl Introspector {
10151015
{
10161016
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
10171017
// as_ptr() giving dangling pointers!
1018-
let c_port = CString::new(port.clone()).unwrap();
1018+
let c_port = CString::new(port).unwrap();
10191019

10201020
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
10211021
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1034,8 +1034,8 @@ impl Introspector {
10341034
{
10351035
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
10361036
// as_ptr() giving dangling pointers!
1037-
let c_name = CString::new(name.clone()).unwrap();
1038-
let c_port = CString::new(port.clone()).unwrap();
1037+
let c_name = CString::new(name).unwrap();
1038+
let c_port = CString::new(port).unwrap();
10391039

10401040
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
10411041
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1239,8 +1239,8 @@ impl Introspector {
12391239
{
12401240
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
12411241
// as_ptr() giving dangling pointers!
1242-
let c_name = CString::new(name.clone()).unwrap();
1243-
let c_arg = CString::new(argument.clone()).unwrap();
1242+
let c_name = CString::new(name).unwrap();
1243+
let c_arg = CString::new(argument).unwrap();
12441244

12451245
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(u32)>(Box::new(callback));
12461246
let ptr = unsafe { capi::pa_context_load_module(self.context, c_name.as_ptr(),
@@ -1696,7 +1696,7 @@ impl Introspector {
16961696
{
16971697
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
16981698
// as_ptr() giving dangling pointers!
1699-
let c_name = CString::new(name.clone()).unwrap();
1699+
let c_name = CString::new(name).unwrap();
17001700

17011701
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(ListResult<&CardInfo>)>(Box::new(callback));
17021702
let ptr = unsafe { capi::pa_context_get_card_info_by_name(self.context, c_name.as_ptr(),
@@ -1726,7 +1726,7 @@ impl Introspector {
17261726
{
17271727
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
17281728
// as_ptr() giving dangling pointers!
1729-
let c_profile = CString::new(profile.clone()).unwrap();
1729+
let c_profile = CString::new(profile).unwrap();
17301730

17311731
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
17321732
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1745,8 +1745,8 @@ impl Introspector {
17451745
{
17461746
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
17471747
// as_ptr() giving dangling pointers!
1748-
let c_name = CString::new(name.clone()).unwrap();
1749-
let c_profile = CString::new(profile.clone()).unwrap();
1748+
let c_name = CString::new(name).unwrap();
1749+
let c_profile = CString::new(profile).unwrap();
17501750

17511751
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
17521752
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1765,8 +1765,8 @@ impl Introspector {
17651765
{
17661766
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
17671767
// as_ptr() giving dangling pointers!
1768-
let c_name = CString::new(card_name.clone()).unwrap();
1769-
let c_port = CString::new(port_name.clone()).unwrap();
1768+
let c_name = CString::new(card_name).unwrap();
1769+
let c_port = CString::new(port_name).unwrap();
17701770

17711771
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
17721772
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -1936,7 +1936,7 @@ impl Introspector {
19361936
{
19371937
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
19381938
// as_ptr() giving dangling pointers!
1939-
let c_name = CString::new(sink_name.clone()).unwrap();
1939+
let c_name = CString::new(sink_name).unwrap();
19401940

19411941
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
19421942
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -2165,7 +2165,7 @@ impl Introspector {
21652165
{
21662166
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
21672167
// as_ptr() giving dangling pointers!
2168-
let c_name = CString::new(source_name.clone()).unwrap();
2168+
let c_name = CString::new(source_name).unwrap();
21692169

21702170
let (cb_fn, cb_data): (Option<extern "C" fn(_, _, _)>, _) =
21712171
get_su_capi_params::<_, _>(callback, super::success_cb_proxy);
@@ -2349,7 +2349,7 @@ impl Introspector {
23492349
{
23502350
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
23512351
// as_ptr() giving dangling pointers!
2352-
let c_name = CString::new(name.clone()).unwrap();
2352+
let c_name = CString::new(name).unwrap();
23532353

23542354
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(ListResult<&SampleInfo>)>(Box::new(callback));
23552355
let ptr = unsafe { capi::pa_context_get_sample_info_by_name(self.context, c_name.as_ptr(),

pulse-binding/src/context/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Context {
225225
pub fn new(mainloop: &impl Mainloop, name: &str) -> Option<Self> {
226226
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
227227
// as_ptr() giving dangling pointers!
228-
let c_name = CString::new(name.clone()).unwrap();
228+
let c_name = CString::new(name).unwrap();
229229
let ptr =
230230
unsafe { capi::pa_context_new(mainloop.inner().get_api().as_ref(), c_name.as_ptr()) };
231231
Self::create(ptr)
@@ -244,7 +244,7 @@ impl Context {
244244
{
245245
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
246246
// as_ptr() giving dangling pointers!
247-
let c_name = CString::new(name.clone()).unwrap();
247+
let c_name = CString::new(name).unwrap();
248248
let ptr = unsafe { capi::pa_context_new_with_proplist(mainloop.inner().get_api().as_ref(),
249249
c_name.as_ptr(), proplist.0.ptr) };
250250
Self::create(ptr)
@@ -328,7 +328,7 @@ impl Context {
328328
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
329329
// as_ptr() giving dangling pointers!
330330
let c_server = match server {
331-
Some(server) => CString::new(server.clone()).unwrap(),
331+
Some(server) => CString::new(server).unwrap(),
332332
None => CString::new("").unwrap(),
333333
};
334334

@@ -400,7 +400,7 @@ impl Context {
400400
{
401401
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
402402
// as_ptr() giving dangling pointers!
403-
let c_name = CString::new(name.clone()).unwrap();
403+
let c_name = CString::new(name).unwrap();
404404

405405
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(bool)>(Box::new(callback));
406406
let ptr = unsafe { capi::pa_context_set_default_sink(self.ptr, c_name.as_ptr(),
@@ -418,7 +418,7 @@ impl Context {
418418
{
419419
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
420420
// as_ptr() giving dangling pointers!
421-
let c_name = CString::new(name.clone()).unwrap();
421+
let c_name = CString::new(name).unwrap();
422422

423423
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(bool)>(Box::new(callback));
424424
let ptr = unsafe { capi::pa_context_set_default_source(self.ptr, c_name.as_ptr(),
@@ -446,7 +446,7 @@ impl Context {
446446
{
447447
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
448448
// as_ptr() giving dangling pointers!
449-
let c_name = CString::new(name.clone()).unwrap();
449+
let c_name = CString::new(name).unwrap();
450450

451451
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(bool)>(Box::new(callback));
452452
let ptr = unsafe { capi::pa_context_set_name(self.ptr, c_name.as_ptr(),
@@ -618,7 +618,7 @@ impl Context {
618618
pub fn load_cookie_from_file(&mut self, cookie_file_path: &str) -> Result<(), PAErr> {
619619
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
620620
// as_ptr() giving dangling pointers!
621-
let c_path = CString::new(cookie_file_path.clone()).unwrap();
621+
let c_path = CString::new(cookie_file_path).unwrap();
622622
match unsafe { capi::pa_context_load_cookie_from_file(self.ptr, c_path.as_ptr()) } {
623623
0 => Ok(()),
624624
e => Err(PAErr(e)),

pulse-binding/src/context/scache.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Context {
7777
{
7878
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
7979
// as_ptr() giving dangling pointers!
80-
let c_name = CString::new(name.clone()).unwrap();
80+
let c_name = CString::new(name).unwrap();
8181

8282
let cb_data = box_closure_get_capi_ptr::<dyn FnMut(bool)>(Box::new(callback));
8383
let ptr = unsafe { capi::pa_context_remove_sample(self.ptr, c_name.as_ptr(),
@@ -104,9 +104,9 @@ impl Context {
104104
{
105105
// Warning: New CStrings will be immediately freed if not bound to a variable, leading to
106106
// as_ptr() giving dangling pointers!
107-
let c_name = CString::new(name.clone()).unwrap();
107+
let c_name = CString::new(name).unwrap();
108108
let c_dev = match dev {
109-
Some(dev) => CString::new(dev.clone()).unwrap(),
109+
Some(dev) => CString::new(dev).unwrap(),
110110
None => CString::new("").unwrap(),
111111
};
112112

@@ -147,9 +147,9 @@ impl Context {
147147
{
148148
// Warning: New CStrings will be immediately freed if not bound to a
149149
// variable, leading to as_ptr() giving dangling pointers!
150-
let c_name = CString::new(name.clone()).unwrap();
150+
let c_name = CString::new(name).unwrap();
151151
let c_dev = match dev {
152-
Some(dev) => CString::new(dev.clone()).unwrap(),
152+
Some(dev) => CString::new(dev).unwrap(),
153153
None => CString::new("").unwrap(),
154154
};
155155

0 commit comments

Comments
 (0)