Skip to content

Commit be38209

Browse files
committed
Don't use unnecessary braces in lzfse
Another checkpatch warning: remove all braces around blocks that have a single statement, except for two cases where it makes more sense to reorganize long comments so that the warnings stop. Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
1 parent 84e57c4 commit be38209

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

lzfse/lzfse_decode_base.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,18 @@ static int lzfse_decode_lmd(lzfse_decoder_state *s)
210210
int res;
211211
/* Decode the next L, M, D symbol from the input stream. */
212212
res = fse_in_flush(&in, &src, src_start);
213-
if (res) {
213+
if (res)
214214
return LZFSE_STATUS_ERROR;
215-
}
216215
L = fse_value_decode(&l_state, bs->l_decoder, &in);
217-
if ((lit + L) >= (bs->literals + LZFSE_LITERALS_PER_BLOCK + 64)) {
216+
if ((lit + L) >= (bs->literals + LZFSE_LITERALS_PER_BLOCK + 64))
218217
return LZFSE_STATUS_ERROR;
219-
}
220218
res = fse_in_flush2(&in, &src, src_start);
221-
if (res) {
219+
if (res)
222220
return LZFSE_STATUS_ERROR;
223-
}
224221
M = fse_value_decode(&m_state, bs->m_decoder, &in);
225222
res = fse_in_flush2(&in, &src, src_start);
226-
if (res) {
223+
if (res)
227224
return LZFSE_STATUS_ERROR;
228-
}
229225
new_d = fse_value_decode(&d_state, bs->d_decoder, &in);
230226
D = new_d ? new_d : D;
231227
symbols--;
@@ -487,9 +483,8 @@ int lzfse_decode(lzfse_decoder_state *s)
487483
return LZFSE_STATUS_SRC_EMPTY; /* need all encoded block */
488484

489485
/* Sanity checks */
490-
if (lzfse_check_block_header_v1(&header1) != 0) {
486+
if (lzfse_check_block_header_v1(&header1) != 0)
491487
return LZFSE_STATUS_ERROR;
492-
}
493488

494489
/* Skip header */
495490
s->src += header_size;

lzfse/lzfse_fse.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ int fse_init_decoder_table(int nstates, int nsymbols, const uint16_t *__restrict
4646

4747
sum_of_freq += f;
4848

49-
if (sum_of_freq > nstates) {
49+
if (sum_of_freq > nstates)
5050
return -1;
51-
}
5251

5352
k = __builtin_clz(f) - n_clz; /* shift needed to ensure N <= (F<<K) < 2*N */
5453
j0 = ((2 * nstates) >> k) - f;

lzfse/lzfse_fse.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ static __always_inline int fse_in_checked_init64(fse_in_stream64 *s, fse_bit_cou
296296
}
297297

298298
if ((s->accum_nbits < 56 || s->accum_nbits >= 64) || ((s->accum >> s->accum_nbits) != 0)) {
299-
return -1; /* the incoming input is wrong (encoder should have zeroed the upper bits) */
299+
/*
300+
* the incoming input is wrong (encoder should have zeroed the
301+
* upper bits)
302+
*/
303+
return -1;
300304
}
301305

302306
return 0; /* OK */
@@ -324,7 +328,11 @@ static __always_inline int fse_in_checked_init32(fse_in_stream32 *s, fse_bit_cou
324328
}
325329

326330
if ((s->accum_nbits < 24 || s->accum_nbits >= 32) || ((s->accum >> s->accum_nbits) != 0)) {
327-
return -1; /* the incoming input is wrong (encoder should have zeroed the upper bits) */
331+
/*
332+
* the incoming input is wrong (encoder should have zeroed the
333+
* upper bits)
334+
*/
335+
return -1;
328336
}
329337

330338
return 0; /* OK */
@@ -345,9 +353,8 @@ static __always_inline int fse_in_checked_flush64(fse_in_stream64 *s, const uint
345353
const uint8_t *buf = (*pbuf) - (nbits >> 3);
346354
uint64_t incoming;
347355

348-
if (buf < buf_start) {
356+
if (buf < buf_start)
349357
return -1; /* out of range */
350-
}
351358
*pbuf = buf;
352359
memcpy(&incoming, buf, 8);
353360
/* Update the state object and verify its validity (in DEBUG). */
@@ -371,9 +378,8 @@ static __always_inline int fse_in_checked_flush32(fse_in_stream32 *s, const uint
371378
const uint8_t *buf = (*pbuf) - (nbits >> 3);
372379
uint32_t incoming;
373380

374-
if (buf < buf_start) {
381+
if (buf < buf_start)
375382
return -1; /* out of range */
376-
}
377383

378384
*pbuf = buf;
379385

@@ -518,9 +524,8 @@ static __always_inline int fse_check_freq(const uint16_t *freq_table, const size
518524
size_t sum_of_freq = 0;
519525
int i;
520526

521-
for (i = 0; i < table_size; i++) {
527+
for (i = 0; i < table_size; i++)
522528
sum_of_freq += freq_table[i];
523-
}
524529
return (sum_of_freq > number_of_states) ? -1 : 0;
525530
}
526531

0 commit comments

Comments
 (0)