@@ -325,15 +325,13 @@ pub fn libc_ram() -> WithError<(u64, u64)> {
325325
326326 let page_size_kb = libc:: sysconf ( libc:: _SC_PAGESIZE) as u64 ;
327327
328- usage = ( 0
329- + stats. active_count as u64
328+ usage = ( stats. active_count as u64
330329 + stats. inactive_count as u64
331330 + stats. wire_count as u64
332331 + stats. speculative_count as u64
333332 + stats. compressor_page_count as u64
334333 - stats. purgeable_count as u64
335- - stats. external_page_count as u64
336- + 0 )
334+ - stats. external_page_count as u64 )
337335 * page_size_kb;
338336 }
339337
@@ -412,7 +410,7 @@ pub fn get_dvfs_mhz(dict: CFDictionaryRef, key: &str) -> (Vec<u32>, Vec<u32>) {
412410pub fn run_system_profiler ( ) -> WithError < serde_json:: Value > {
413411 // system_profiler -listDataTypes
414412 let out = std:: process:: Command :: new ( "system_profiler" )
415- . args ( & [ "SPHardwareDataType" , "SPDisplaysDataType" , "SPSoftwareDataType" , "-json" ] )
413+ . args ( [ "SPHardwareDataType" , "SPDisplaysDataType" , "SPSoftwareDataType" , "-json" ] )
416414 . output ( ) ?;
417415
418416 let out = std:: str:: from_utf8 ( & out. stdout ) ?;
@@ -500,7 +498,7 @@ pub fn get_soc_info() -> WithError<SocInfo> {
500498
501499fn cfio_get_chan ( items : Vec < ( & str , Option < & str > ) > ) -> WithError < CFMutableDictionaryRef > {
502500 // if no items are provided, return all channels
503- if items. len ( ) == 0 {
501+ if items. is_empty ( ) {
504502 unsafe {
505503 let c = IOReportCopyAllChannels ( 0 , 0 ) ;
506504 let r = CFDictionaryCreateMutableCopy ( kCFAllocatorDefault, CFDictionaryGetCount ( c) , c) ;
@@ -512,7 +510,7 @@ fn cfio_get_chan(items: Vec<(&str, Option<&str>)>) -> WithError<CFMutableDiction
512510 let mut channels = vec ! [ ] ;
513511 for ( group, subgroup) in items {
514512 let gname = cfstr ( group) ;
515- let sname = subgroup. map_or ( null ( ) , |x| cfstr ( x ) ) ;
513+ let sname = subgroup. map_or ( null ( ) , cfstr) ;
516514 let chan = unsafe { IOReportCopyChannelsInGroup ( gname, sname, 0 , 0 , 0 ) } ;
517515 channels. push ( chan) ;
518516
@@ -583,7 +581,7 @@ impl IOReport {
583581 }
584582
585583 pub fn get_samples ( & mut self , duration : u64 , count : usize ) -> Vec < ( IOReportIterator , u64 ) > {
586- let count = count. max ( 1 ) . min ( 32 ) ;
584+ let count = count. clamp ( 1 , 32 ) ;
587585 let mut samples: Vec < ( IOReportIterator , u64 ) > = Vec :: with_capacity ( count) ;
588586 let step_msec = duration / count as u64 ;
589587
@@ -663,8 +661,8 @@ pub struct IOHIDSensors {
663661
664662impl IOHIDSensors {
665663 pub fn new ( ) -> WithError < Self > {
666- let keys = vec ! [ cfstr( "PrimaryUsagePage" ) , cfstr( "PrimaryUsage" ) ] ;
667- let nums = vec ! [ cfnum( kHIDPage_AppleVendor) , cfnum( kHIDUsage_AppleVendor_TemperatureSensor) ] ;
664+ let keys = [ cfstr ( "PrimaryUsagePage" ) , cfstr ( "PrimaryUsage" ) ] ;
665+ let nums = [ cfnum ( kHIDPage_AppleVendor) , cfnum ( kHIDUsage_AppleVendor_TemperatureSensor) ] ;
668666
669667 let dict = unsafe {
670668 CFDictionaryCreate (
@@ -799,6 +797,7 @@ pub struct SensorVal {
799797
800798// MARK: SMC
801799
800+ #[ allow( clippy:: upper_case_acronyms) ]
802801pub struct SMC {
803802 conn : u32 ,
804803 keys : HashMap < u32 , KeyInfo > ,
@@ -861,7 +860,7 @@ impl SMC {
861860 let key = key. bytes ( ) . fold ( 0 , |acc, x| ( acc << 8 ) + x as u32 ) ;
862861 if let Some ( ki) = self . keys . get ( & key) {
863862 // println!("cache hit for {}", key);
864- return Ok ( ki . clone ( ) ) ;
863+ return Ok ( * ki ) ;
865864 }
866865
867866 let ival = KeyData { data8 : 9 , key, ..Default :: default ( ) } ;
0 commit comments