Skip to content

Commit b26a281

Browse files
committed
Make log not panic on failed writes - currently does nothing, once more is rust, may be worth bubbling up IO errors.
1 parent 5a8140c commit b26a281

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • crates/engine_bibtex/src/c_api

crates/engine_bibtex/src/c_api/log.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ fn with_log<T>(f: impl FnOnce(&mut OutputHandle) -> T) -> T {
6868
}
6969

7070
pub(crate) fn write_logs<B: ?Sized + AsBytes>(str: &B) {
71-
with_log(|log| log.write_all(str.as_bytes())).unwrap();
72-
with_stdout(|out| out.write_all(str.as_bytes())).unwrap();
71+
let _ = with_log(|log| log.write_all(str.as_bytes()));
72+
let _ = with_stdout(|out| out.write_all(str.as_bytes()));
7373
}
7474

7575
pub fn init_log_file(file: &CStr) -> bool {
@@ -119,21 +119,21 @@ pub extern "C" fn bib_close_log() {
119119
#[no_mangle]
120120
pub unsafe extern "C" fn bib_log_prints(str: *const libc::c_char) {
121121
let str = CStr::from_ptr(str);
122-
with_log(|log| log.write_all(str.to_bytes())).unwrap()
122+
let _ = with_log(|log| log.write_all(str.to_bytes()));
123123
}
124124

125125
#[no_mangle]
126126
pub extern "C" fn putc_log(c: libc::c_int) {
127127
let c = c as u8;
128-
with_log(|log| log.write_all(&[c])).unwrap();
129-
with_stdout(|out| out.write_all(&[c])).unwrap();
128+
let _ = with_log(|log| log.write_all(&[c]));
129+
let _ = with_stdout(|out| out.write_all(&[c]));
130130
}
131131

132132
#[no_mangle]
133133
pub unsafe extern "C" fn puts_log(str: *const libc::c_char) {
134134
let str = CStr::from_ptr(str);
135-
with_log(|log| log.write_all(str.to_bytes())).unwrap();
136-
with_stdout(|out| out.write_all(str.to_bytes())).unwrap();
135+
let _ = with_log(|log| log.write_all(str.to_bytes()));
136+
let _ = with_stdout(|out| out.write_all(str.to_bytes()));
137137
}
138138

139139
#[no_mangle]

0 commit comments

Comments
 (0)