Skip to content

Commit 394c825

Browse files
fixing compilation warnings
1 parent d8ef114 commit 394c825

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Diff for: src/decompress/lzss.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void lzss_init(
3535
}
3636

3737
decoder = new LZSSDecoder(
38-
[target_file](const uint8_t c) {
38+
[](const uint8_t c) {
3939
fwrite(&c, 1, 1, target_file);
4040
}
4141
);
@@ -68,7 +68,7 @@ void lzss_decode() {
6868
**************************************************************************************/
6969

7070
// get the number of bits the algorithm will try to get given the state
71-
int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
71+
uint8_t LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
7272
switch(s) {
7373
case FSM_0:
7474
return 1;
@@ -78,18 +78,20 @@ int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
7878
return EI;
7979
case FSM_3:
8080
return EJ;
81+
default:
82+
return 0;
8183
}
8284
}
8385

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

9092

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

142144
break;
143145
}
146+
case FSM_EOF:
147+
break;
144148
}
145149
}
146150

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

165-
int LZSSDecoder::getbit(int n) { // get n bits from buffer
169+
int LZSSDecoder::getbit(uint8_t n) { // get n bits from buffer
166170
int x=0, c;
167171

168172
// if the local bit buffer doesn't have enough bit get them

Diff for: src/decompress/lzss.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class LZSSDecoder {
7878
status handle_state();
7979

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

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

97-
std::function<void(const uint8_t)> put_char_cbk=nullptr;
98-
std::function<uint8_t()> get_char_cbk=nullptr;
97+
std::function<void(const uint8_t)> put_char_cbk;
98+
std::function<uint8_t()> get_char_cbk;
9999

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

102102
// get the number of bits the FSM will require given its state
103-
int bits_required(FSM_STATES s);
103+
uint8_t bits_required(FSM_STATES s);
104104
};
105105

106106
#endif /* SSU_LZSS_H_ */

0 commit comments

Comments
 (0)