Skip to content

Commit

Permalink
fixing compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed Feb 5, 2024
1 parent 65b77ee commit eb58243
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/decompress/lzss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void lzss_init(
}

decoder = new LZSSDecoder(
[target_file](const uint8_t c) {
[](const uint8_t c) {
fwrite(&c, 1, 1, target_file);
}
);
Expand Down Expand Up @@ -68,7 +68,7 @@ void lzss_decode() {
**************************************************************************************/

// get the number of bits the algorithm will try to get given the state
int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
uint8_t LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
switch(s) {
case FSM_0:
return 1;
Expand All @@ -78,18 +78,20 @@ int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
return EI;
case FSM_3:
return EJ;
default:
return 0;
}
}

LZSSDecoder::LZSSDecoder(std::function<int()> getc_cbk, std::function<void(const uint8_t)> putc_cbk)
: put_char_cbk(putc_cbk), get_char_cbk(getc_cbk), state(FSM_0), available(0) {
: available(0), state(FSM_0), put_char_cbk(putc_cbk), get_char_cbk(getc_cbk) {
for (int i = 0; i < N - F; i++) buffer[i] = ' ';
r = N - F;
}


LZSSDecoder::LZSSDecoder(std::function<void(const uint8_t)> putc_cbk)
: put_char_cbk(putc_cbk), state(FSM_0), available(0) {
: available(0), state(FSM_0), put_char_cbk(putc_cbk), get_char_cbk(nullptr) {
for (int i = 0; i < N - F; i++) buffer[i] = ' ';
r = N - F;
}
Expand Down Expand Up @@ -141,6 +143,8 @@ LZSSDecoder::status LZSSDecoder::handle_state() {

break;
}
case FSM_EOF:
break;
}
}

Expand All @@ -162,7 +166,7 @@ LZSSDecoder::status LZSSDecoder::decompress(uint8_t* const buffer, uint32_t size
return res;
}

int LZSSDecoder::getbit(int n) { // get n bits from buffer
int LZSSDecoder::getbit(uint8_t n) { // get n bits from buffer
int x=0, c;

// if the local bit buffer doesn't have enough bit get them
Expand Down
8 changes: 4 additions & 4 deletions src/decompress/lzss.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LZSSDecoder {
status handle_state();

// get 1 bit from the available input buffer
int getbit(int n);
int getbit(uint8_t n);
// the following 2 are variables used by getbits
uint32_t buf, buf_size=0;

Expand All @@ -94,13 +94,13 @@ class LZSSDecoder {
// there is no documentation about their meaning
int i, r;

std::function<void(const uint8_t)> put_char_cbk=nullptr;
std::function<uint8_t()> get_char_cbk=nullptr;
std::function<void(const uint8_t)> put_char_cbk;
std::function<uint8_t()> get_char_cbk;

inline void putc(const uint8_t c) { if(put_char_cbk) { put_char_cbk(c); } }

// get the number of bits the FSM will require given its state
int bits_required(FSM_STATES s);
uint8_t bits_required(FSM_STATES s);
};

#endif /* SSU_LZSS_H_ */

0 comments on commit eb58243

Please sign in to comment.