Skip to content

Commit b02c23b

Browse files
authored
Fix Windows clippy. (#621)
2 parents 229c9e8 + a4b762b commit b02c23b

File tree

9 files changed

+32
-37
lines changed

9 files changed

+32
-37
lines changed

‎samply/src/windows/coreclr.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ pub fn coreclr_xperf_args(props: &ElevatedRecordingProps) -> Vec<String> {
352352

353353
if info_keywords != 0 {
354354
providers.push(format!(
355-
"Microsoft-Windows-DotNETRuntime:0x{:x}:4",
356-
info_keywords
355+
"Microsoft-Windows-DotNETRuntime:0x{info_keywords:x}:4"
357356
));
358357
}
359358

@@ -364,15 +363,13 @@ pub fn coreclr_xperf_args(props: &ElevatedRecordingProps) -> Vec<String> {
364363
// and I'm not sure which events include the mapping -- MethodJittingStarted is also
365364
// verbose).
366365
providers.push(format!(
367-
"Microsoft-Windows-DotNETRuntime:0x{:x}:5",
368-
verbose_keywords
366+
"Microsoft-Windows-DotNETRuntime:0x{verbose_keywords:x}:5"
369367
));
370368
}
371369

372370
if rundown_verbose_keywords != 0 {
373371
providers.push(format!(
374-
"Microsoft-Windows-DotNETRuntimeRundown:0x{:x}:5",
375-
rundown_verbose_keywords
372+
"Microsoft-Windows-DotNETRuntimeRundown:0x{rundown_verbose_keywords:x}:5"
376373
));
377374
}
378375

@@ -560,7 +557,7 @@ pub fn handle_coreclr_event(
560557
let _object_count: u32 = parser.parse("ObjectCountForTypeSample");
561558
let total_size: u64 = parser.parse("TotalSizeForTypeSample");
562559

563-
let clr_type = context.handle_for_profile_string(&format!("0x{:x}", type_id));
560+
let clr_type = context.handle_for_profile_string(&format!("0x{type_id:x}"));
564561
let mh = context.add_thread_instant_marker(
565562
timestamp_raw,
566563
tid,
@@ -576,7 +573,7 @@ pub fn handle_coreclr_event(
576573

577574
let reason: u32 = parser.parse("Reason");
578575
let reason = GcReason::from_u32(reason).or_else(|| {
579-
eprintln!("Unknown CLR GC Triggered reason: {}", reason);
576+
eprintln!("Unknown CLR GC Triggered reason: {reason}");
580577
None
581578
});
582579

@@ -603,7 +600,7 @@ pub fn handle_coreclr_event(
603600
let reason: u32 = parser.parse("Reason");
604601

605602
let reason = GcSuspendEeReason::from_u32(reason).or_else(|| {
606-
eprintln!("Unknown CLR GCSuspendEEBegin reason: {}", reason);
603+
eprintln!("Unknown CLR GCSuspendEEBegin reason: {reason}");
607604
None
608605
});
609606

@@ -648,12 +645,12 @@ pub fn handle_coreclr_event(
648645
let gc_type: u32 = parser.parse("Type");
649646

650647
let reason = GcReason::from_u32(reason).or_else(|| {
651-
eprintln!("Unknown CLR GCStart reason: {}", reason);
648+
eprintln!("Unknown CLR GCStart reason: {reason}");
652649
None
653650
});
654651

655652
let gc_type = GcType::from_u32(gc_type).or_else(|| {
656-
eprintln!("Unknown CLR GCStart type: {}", gc_type);
653+
eprintln!("Unknown CLR GCStart type: {gc_type}");
657654
None
658655
});
659656

‎samply/src/windows/etw_gecko.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn process_trace(
9191
let clock_type: u32 = parser.parse("ReservedFlags");
9292
let events_lost: u32 = parser.parse("EventsLost");
9393
if events_lost != 0 {
94-
log::warn!("{} events lost", events_lost);
94+
log::warn!("{events_lost} events lost");
9595
}
9696

9797
context.handle_header(timestamp_raw, perf_freq, clock_type);

‎samply/src/windows/etw_reader/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ pub fn start_trace<F: FnMut(&EventRecord)>(mut callback: F) {
250250
&info.properties as *const _ as *mut _,
251251
Etw::EVENT_TRACE_CONTROL_STOP,
252252
);
253-
println!("ControlTrace = {:?}", status);
253+
println!("ControlTrace = {status:?}");
254254
let status = Etw::StartTraceW(
255255
&mut handle,
256256
session_name,
257257
&info.properties as *const _ as *mut _,
258258
);
259-
println!("StartTrace = {:?} handle {:?}", status, handle);
259+
println!("StartTrace = {status:?} handle {handle:?}");
260260
info.trace_name = [0; 260];
261261

262262
let status = Etw::ControlTraceW(
@@ -308,9 +308,9 @@ pub fn start_trace<F: FnMut(&EventRecord)>(mut callback: F) {
308308

309309
panic!("Invalid handle");
310310
}
311-
println!("OpenTrace {:?}", session_handle);
311+
println!("OpenTrace {session_handle:?}");
312312
let status = unsafe { Etw::ProcessTrace(&[session_handle], None, None) };
313-
println!("status: {:?}", status);
313+
println!("status: {status:?}");
314314
}
315315

316316
pub fn event_properties_to_string(
@@ -386,7 +386,7 @@ pub fn write_property(
386386
}
387387
}
388388
if cleared_value != 0 {
389-
remaining_bits_str = format!("{:x}", cleared_value);
389+
remaining_bits_str = format!("{cleared_value:x}");
390390
matches.push(&remaining_bits_str);
391391
//println!("unnamed bits {:x} {:x} {:x?}", value, cleared_value, map_info.map);
392392
}
@@ -399,7 +399,7 @@ pub fn write_property(
399399
.map
400400
.get(&value)
401401
.map(Cow::from)
402-
.unwrap_or_else(|| Cow::from(format!("Unknown: {}", value)))
402+
.unwrap_or_else(|| Cow::from(format!("Unknown: {value}")))
403403
)
404404
.unwrap();
405405
}
@@ -438,21 +438,21 @@ pub fn write_property(
438438
TdhInType::InTypeUInt64 => {
439439
let i = TryParse::<u64>::try_parse(parser, &property.name);
440440
if desc.out_type == TdhOutType::OutTypeHexInt64 {
441-
i.map(|x| format!("0x{:x}", x))
441+
i.map(|x| format!("0x{x:x}"))
442442
} else {
443443
i.map(|x| x.to_string())
444444
}
445445
}
446446
TdhInType::InTypeHexInt64 => {
447447
let i = TryParse::<i64>::try_parse(parser, &property.name);
448-
i.map(|x| format!("0x{:x}", x))
448+
i.map(|x| format!("0x{x:x}"))
449449
}
450450
TdhInType::InTypePointer | TdhInType::InTypeSizeT => {
451451
TryParse::<u64>::try_parse(parser, &property.name)
452-
.map(|x| format!("0x{:x}", x))
452+
.map(|x| format!("0x{x:x}"))
453453
}
454454
TdhInType::InTypeGuid => TryParse::<GUID>::try_parse(parser, &property.name)
455-
.map(|x| format!("{:?}", x)),
455+
.map(|x| format!("{x:?}")),
456456
TdhInType::InTypeInt32 => {
457457
TryParse::<i32>::try_parse(parser, &property.name).map(|x| x.to_string())
458458
}
@@ -478,14 +478,14 @@ pub fn write_property(
478478
),
479479
Err(e) => format!("Err({:?}) type: {:?}", e, property.desc),
480480
};
481-
write!(output, "{}", value).unwrap();
481+
write!(output, "{value}").unwrap();
482482
}
483483
}
484484

485485
pub fn print_property(parser: &mut Parser, property: &Property, write_types: bool) {
486486
let mut result = String::new();
487487
write_property(&mut result, parser, property, write_types);
488-
println!("{}", result);
488+
println!("{result}");
489489
}
490490

491491
pub fn add_custom_schemas(locator: &mut SchemaLocator) {
@@ -535,7 +535,7 @@ pub fn enumerate_trace_guids_ex(print_instances: bool) {
535535
vec![GUID::zeroed(); required_size as usize / mem::size_of::<GUID>()];
536536

537537
let size = (guids.len() * mem::size_of::<GUID>()) as u32;
538-
println!("get {}", required_size);
538+
println!("get {required_size}");
539539

540540
let result = unsafe {
541541
EnumerateTraceGuidsEx(
@@ -550,7 +550,7 @@ pub fn enumerate_trace_guids_ex(print_instances: bool) {
550550
match result.ok() {
551551
Ok(()) => {
552552
for guid in guids.iter() {
553-
println!("{:?}", guid);
553+
println!("{guid:?}");
554554
let info = get_provider_info(guid);
555555
let instance_count =
556556
unsafe { *(info.as_ptr() as *const TRACE_GUID_INFO) }.InstanceCount;
@@ -609,7 +609,7 @@ pub fn get_provider_info(guid: &GUID) -> Vec<u8> {
609609
}
610610
Err(e) => {
611611
if e.code() != ERROR_INSUFFICIENT_BUFFER.to_hresult() {
612-
panic!("{:?}", e);
612+
panic!("{e:?}");
613613
}
614614
}
615615
}

‎samply/src/windows/etw_reader/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a> Parser<'a> {
230230
.properties
231231
.name_to_indx
232232
.get(name)
233-
.ok_or_else(|| ParserError::PropertyError(format!("Unknown property: {}", name)))?;
233+
.ok_or_else(|| ParserError::PropertyError(format!("Unknown property: {name}")))?;
234234
if indx < self.cache.len() {
235235
return Ok(indx);
236236
}

‎samply/src/windows/etw_reader/tdh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ pub fn list_etw_providers() {
126126
);
127127
}
128128
} else {
129-
println!("TdhEnumerateProviders failed with error code {:?}", status);
129+
println!("TdhEnumerateProviders failed with error code {status:?}");
130130
}
131131
} else {
132-
println!("TdhEnumerateProviders failed with error code {:?}", status);
132+
println!("TdhEnumerateProviders failed with error code {status:?}");
133133
}
134134
}

‎samply/src/windows/firefox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn firefox_xperf_args(props: &ElevatedRecordingProps) -> Vec<String> {
3737

3838
// UserTiming + GC markers
3939
let bits = (EtwMarkerGroup::UserMarkers | EtwMarkerGroup::Memory).bits();
40-
providers.push(format!("{}:{:#x}", FIREFOX_PROVIDER_GUID, bits));
40+
providers.push(format!("{FIREFOX_PROVIDER_GUID}:{bits:#x}"));
4141

4242
providers
4343
}

‎samply/src/windows/gfx.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ pub fn gfx_xperf_args(props: &ElevatedRecordingProps) -> Vec<String> {
1414

1515
if level_1_dxgkrnl_keywords != 0 {
1616
providers.push(format!(
17-
"Microsoft-Windows-DxgKrnl:0x{:x}:1",
18-
level_1_dxgkrnl_keywords
17+
"Microsoft-Windows-DxgKrnl:0x{level_1_dxgkrnl_keywords:x}:1"
1918
));
2019
}
2120

‎samply/src/windows/profile_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl ProfileContext {
643643
// if we didn't translate (still have a \\ path), prefix with GLOBALROOT as
644644
// an escape
645645
if path.starts_with("\\\\") {
646-
format!("\\\\?\\GLOBALROOT{}", path)
646+
format!("\\\\?\\GLOBALROOT{path}")
647647
} else {
648648
path.into()
649649
}
@@ -798,7 +798,7 @@ impl ProfileContext {
798798
let (process_handle, main_thread_handle, main_thread_label) = if let Some(recycling_data) =
799799
&recycling_data
800800
{
801-
log::info!("Found old process for pid {} and name {}", pid, name);
801+
log::info!("Found old process for pid {pid} and name {name}");
802802
let (main_thread_handle, main_thread_label) = recycling_data.main_thread_recycling_data;
803803
(
804804
recycling_data.process_handle,

‎samply/src/windows/profiler.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ pub fn run(
105105
let exit_status = child.wait().unwrap();
106106
if !process_launch_props.ignore_exit_code && !exit_status.success() {
107107
eprintln!(
108-
"Skipping remaining iterations due to non-success exit status: \"{}\"",
109-
exit_status
108+
"Skipping remaining iterations due to non-success exit status: \"{exit_status}\""
110109
);
111110
break;
112111
}

0 commit comments

Comments
 (0)