@@ -154,7 +154,7 @@ pub fn create_sha3(bits: Option<usize>) -> UResult<HashAlgorithm> {
154154}
155155
156156#[ allow( clippy:: comparison_chain) ]
157- fn cksum_output ( res : & ChecksumResult , ignore_missing : bool , status : bool ) {
157+ fn cksum_output ( res : & ChecksumResult , status : bool ) {
158158 if res. bad_format == 1 {
159159 show_warning_caps ! ( "{} line is improperly formatted" , res. bad_format) ;
160160 } else if res. bad_format > 1 {
@@ -168,12 +168,10 @@ fn cksum_output(res: &ChecksumResult, ignore_missing: bool, status: bool) {
168168 show_warning_caps ! ( "{} computed checksums did NOT match" , res. failed_cksum) ;
169169 }
170170 }
171- if !ignore_missing {
172- if res. failed_open_file == 1 {
173- show_warning_caps ! ( "{} listed file could not be read" , res. failed_open_file) ;
174- } else if res. failed_open_file > 1 {
175- show_warning_caps ! ( "{} listed files could not be read" , res. failed_open_file) ;
176- }
171+ if res. failed_open_file == 1 {
172+ show_warning_caps ! ( "{} listed file could not be read" , res. failed_open_file) ;
173+ } else if res. failed_open_file > 1 {
174+ show_warning_caps ! ( "{} listed files could not be read" , res. failed_open_file) ;
177175 }
178176}
179177
@@ -364,10 +362,16 @@ fn get_file_to_check(
364362 if filename == "-" {
365363 Some ( Box :: new ( stdin ( ) ) ) // Use stdin if "-" is specified in the checksum file
366364 } else {
365+ let mut failed_open = || {
366+ println ! ( "{filename}: FAILED open or read" ) ;
367+ res. failed_open_file += 1 ;
368+ } ;
367369 match File :: open ( filename) {
368370 Ok ( f) => {
369371 if f. metadata ( ) . ok ( ) ?. is_dir ( ) {
370372 show ! ( USimpleError :: new( 1 , format!( "{filename}: Is a directory" ) ) ) ;
373+ // also regarded as a failed open
374+ failed_open ( ) ;
371375 None
372376 } else {
373377 Some ( Box :: new ( f) )
@@ -377,9 +381,8 @@ fn get_file_to_check(
377381 if !ignore_missing {
378382 // yes, we have both stderr and stdout here
379383 show ! ( err. map_err_context( || filename. to_string( ) ) ) ;
380- println ! ( "{filename}: FAILED open or read" ) ;
384+ failed_open ( ) ;
381385 }
382- res. failed_open_file += 1 ;
383386 // we could not open the file but we want to continue
384387 None
385388 }
@@ -612,6 +615,9 @@ where
612615 return Ok ( ( ) ) ;
613616 }
614617
618+ // if any incorrectly formatted line, show it
619+ cksum_output ( & res, status) ;
620+
615621 if ignore_missing && correct_format == 0 {
616622 // we have only bad format
617623 // and we had ignore-missing
@@ -633,9 +639,6 @@ where
633639 if ( res. failed_cksum > 0 || res. failed_open_file > 0 ) && !ignore_missing {
634640 set_exit_code ( 1 ) ;
635641 }
636-
637- // if any incorrectly formatted line, show it
638- cksum_output ( & res, ignore_missing, status) ;
639642 }
640643
641644 Ok ( ( ) )
0 commit comments