From 1ae56389fc611eb58e565a4f5180e3edc1126e19 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Wed, 8 May 2024 21:08:46 +0200 Subject: [PATCH] [fix] debug prints have to go to stderr --- src/crypto.rs | 12 ++++++------ src/main.rs | 2 +- src/reader.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/crypto.rs b/src/crypto.rs index 3676994..d62531a 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -35,7 +35,7 @@ pub fn encrypt>( ReadInfo::NormalChunk(n) => { assert_eq!(n, BUFSIZE); assert_eq!(buf.len(), BUFSIZE); - println!("[encrypt]: read normal chunk"); + eprintln!("[encrypt]: read normal chunk"); stream_encryptor.encrypt_next_in_place(&[], &mut buf)?; f_encrypted.write_all(&buf)?; // buf grows after encrypt_next_in_place because of tag that is added @@ -43,14 +43,14 @@ pub fn encrypt>( buf.truncate(BUFSIZE); } ReadInfo::LastChunk(n) => { - println!("[encrypt]: read last chunk"); + eprintln!("[encrypt]: read last chunk"); buf.truncate(n); stream_encryptor.encrypt_last_in_place(&[], &mut buf)?; f_encrypted.write_all(&buf)?; break; } ReadInfo::EmptyChunk => { - println!("[encrypt]: read empty chunk"); + eprintln!("[encrypt]: read empty chunk"); panic!("[ERROR] Empty Chunk while reading"); } } @@ -81,20 +81,20 @@ pub fn decrypt>( match read_result { ReadInfo::NormalChunk(n) => { assert_eq!(n, BUFSIZE + 16); - println!("[decrypt]: read normal chunk"); + eprintln!("[decrypt]: read normal chunk"); stream_decryptor.decrypt_next_in_place(&[], &mut buf)?; f_plain.write_all(&buf)?; buf.resize(BUFSIZE + 16, 0); } ReadInfo::LastChunk(n) => { - println!("[decrypt]: read last chunk"); + eprintln!("[decrypt]: read last chunk"); buf.truncate(n); stream_decryptor.decrypt_last_in_place(&[], &mut buf)?; f_plain.write_all(&buf)?; break; } ReadInfo::EmptyChunk => { - println!("[decrypt]: read empty chunk"); + eprintln!("[decrypt]: read empty chunk"); panic!("Empty Chunk while reading"); } } diff --git a/src/main.rs b/src/main.rs index b0780a3..d828831 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,6 @@ fn run(cli: Cli) -> Result<(), FcryError> { fn main() { let cli = Cli::parse(); if let Err(e) = run(cli) { - println!("Error: {:?}", e); + eprintln!("Error: {:?}", e); } } diff --git a/src/reader.rs b/src/reader.rs index 1e0fc65..8a48459 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -49,11 +49,11 @@ impl AheadReader { pub fn read_ahead(&mut self, userbuf: &mut [u8]) -> io::Result { // 1st read if self.bufsz == 0 { - println!("[reader] first read"); + eprintln!("[reader] first read"); return self.first_read(userbuf); } - println!("[reader] normal read"); + eprintln!("[reader] normal read"); // normal read (not the 1st one) self.normal_read(userbuf) }