Skip to content

Commit

Permalink
Reduce visibility a bit more and remove unused repr(C)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 12, 2024
1 parent 0a6da4a commit d825ac8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
3 changes: 1 addition & 2 deletions bzip2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ static mut verbosity: i32 = 0;
static mut keep_input_files: bool = false;

#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum DecompressMode {
enum DecompressMode {
Fast = 0,
Small = 1,
}
Expand Down
3 changes: 1 addition & 2 deletions bzip2recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ enum Error {
Fatal,
}

#[repr(C)]
struct BitStream {
handle: File,
buffer: i32,
Expand Down Expand Up @@ -377,7 +376,7 @@ fn main_help(program_name: &Path, in_filename: &Path) -> Result<(), Error> {
Ok(())
}

pub fn main() -> ExitCode {
fn main() -> ExitCode {
let mut it = ::std::env::args_os();

let program_name = PathBuf::from(it.next().unwrap());
Expand Down
23 changes: 7 additions & 16 deletions bzlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ pub(crate) enum ReturnCode {
BZ_CONFIG_ERROR = -9,
}

#[repr(i32)]
#[derive(Copy, Clone)]
pub(crate) enum Mode {
Idle = 1,
Expand All @@ -184,7 +183,6 @@ pub(crate) enum Mode {
Finishing = 4,
}

#[repr(i32)]
#[derive(Copy, Clone)]
pub(crate) enum State {
Output = 1,
Expand All @@ -198,7 +196,6 @@ pub(crate) const BZ_N_OVERSHOOT: usize = (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL +

pub(crate) const FTAB_LEN: usize = u16::MAX as usize + 2;

#[repr(C)]
pub(crate) struct EState {
pub strm: *mut bz_stream,
pub mode: Mode,
Expand All @@ -212,8 +209,6 @@ pub(crate) struct EState {
pub workFactor: i32,
pub state_in_ch: u32,
pub state_in_len: i32,
pub rNToGo: i32,
pub rTPos: i32,
pub nblock: i32,
pub nblockMAX: i32,
pub state_out_pos: i32,
Expand Down Expand Up @@ -363,7 +358,6 @@ impl Ftab {
}
}

#[repr(C)]
pub(crate) struct DState {
pub strm: *mut bz_stream,
pub state: decompress::State,
Expand Down Expand Up @@ -472,15 +466,14 @@ impl<T> DSlice<T> {

#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
#[repr(C)]
pub(crate) struct bzFile {
pub handle: *mut FILE,
pub buf: [i8; BZ_MAX_UNUSED as usize],
pub bufN: i32,
pub strm: bz_stream,
pub lastErr: ReturnCode,
pub operation: Operation,
pub initialisedOk: bool,
handle: *mut FILE,
buf: [i8; BZ_MAX_UNUSED as usize],
bufN: i32,
strm: bz_stream,
lastErr: ReturnCode,
operation: Operation,
initialisedOk: bool,
}

const _C_INT_SIZE: () = assert!(core::mem::size_of::<core::ffi::c_int>() == 4);
Expand Down Expand Up @@ -1038,7 +1031,6 @@ pub unsafe extern "C" fn BZ2_bzCompressEnd(strm: *mut bz_stream) -> c_int {
0 as c_int
}

#[repr(u8)]
pub(crate) enum DecompressMode {
Small,
Fast,
Expand Down Expand Up @@ -2320,7 +2312,6 @@ pub unsafe extern "C" fn BZ2_bzBuffToBuffDecompress(
}

#[derive(Copy, Clone)]
#[repr(u8)]
pub(crate) enum Operation {
Reading,
Writing,
Expand Down
1 change: 0 additions & 1 deletion decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::randtable::BZ2_RNUMS;
const MTFA_SIZE: i32 = 4096;
const MTFL_SIZE: i32 = 16;

#[repr(i32)]
#[derive(Debug, Clone, Copy)]
#[allow(non_camel_case_types)]
pub(crate) enum State {
Expand Down

0 comments on commit d825ac8

Please sign in to comment.