Replace final with fin to make clang-format-3.9 happy
This commit is contained in:
parent
a591001e7b
commit
bc0f501dd3
|
@ -828,7 +828,7 @@ static size_t encode_length(uint8_t *buf, size_t n, size_t prefix) {
|
|||
* If the |initial| is nonzero, it is used as a initial value, this
|
||||
* function assumes the |in| starts with intermediate data.
|
||||
*
|
||||
* An entire integer is decoded successfully, decoded, the |*final| is
|
||||
* An entire integer is decoded successfully, decoded, the |*fin| is
|
||||
* set to nonzero.
|
||||
*
|
||||
* This function stores the decoded integer in |*res| if it succeed,
|
||||
|
@ -836,7 +836,7 @@ static size_t encode_length(uint8_t *buf, size_t n, size_t prefix) {
|
|||
* in the next call will be stored in |*shift_ptr|) and returns number
|
||||
* of bytes processed, or returns -1, indicating decoding error.
|
||||
*/
|
||||
static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
||||
static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *fin,
|
||||
uint32_t initial, size_t shift, const uint8_t *in,
|
||||
const uint8_t *last, size_t prefix) {
|
||||
uint32_t k = (uint8_t)((1 << prefix) - 1);
|
||||
|
@ -844,12 +844,12 @@ static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
|||
const uint8_t *start = in;
|
||||
|
||||
*shift_ptr = 0;
|
||||
*final = 0;
|
||||
*fin = 0;
|
||||
|
||||
if (n == 0) {
|
||||
if ((*in & k) != k) {
|
||||
*res = (*in) & k;
|
||||
*final = 1;
|
||||
*fin = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -891,7 +891,7 @@ static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
|||
}
|
||||
|
||||
*res = n;
|
||||
*final = 1;
|
||||
*fin = 1;
|
||||
return (ssize_t)(in + 1 - start);
|
||||
}
|
||||
|
||||
|
@ -1665,13 +1665,13 @@ static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater,
|
|||
nghttp2_buf *buf, const uint8_t *in,
|
||||
const uint8_t *last) {
|
||||
ssize_t readlen;
|
||||
int final = 0;
|
||||
int fin = 0;
|
||||
if ((size_t)(last - in) >= inflater->left) {
|
||||
last = in + inflater->left;
|
||||
final = 1;
|
||||
fin = 1;
|
||||
}
|
||||
readlen = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, buf, in,
|
||||
(size_t)(last - in), final);
|
||||
(size_t)(last - in), fin);
|
||||
|
||||
if (readlen < 0) {
|
||||
DEBUGF("inflatehd: huffman decoding failed\n");
|
||||
|
@ -2269,10 +2269,10 @@ int nghttp2_hd_emit_table_size(nghttp2_bufs *bufs, size_t table_size) {
|
|||
return emit_table_size(bufs, table_size);
|
||||
}
|
||||
|
||||
ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
||||
ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *fin,
|
||||
uint32_t initial, size_t shift, uint8_t *in,
|
||||
uint8_t *last, size_t prefix) {
|
||||
return decode_length(res, shift_ptr, final, initial, shift, in, last, prefix);
|
||||
return decode_length(res, shift_ptr, fin, initial, shift, in, last, prefix);
|
||||
}
|
||||
|
||||
static size_t hd_get_num_table_entries(nghttp2_hd_context *context) {
|
||||
|
|
|
@ -372,7 +372,7 @@ int nghttp2_hd_emit_table_size(nghttp2_bufs *bufs, size_t table_size);
|
|||
nghttp2_hd_nv nghttp2_hd_table_get(nghttp2_hd_context *context, size_t index);
|
||||
|
||||
/* For unittesting purpose */
|
||||
ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
||||
ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *fin,
|
||||
uint32_t initial, size_t shift, uint8_t *in,
|
||||
uint8_t *last, size_t prefix);
|
||||
|
||||
|
@ -410,8 +410,8 @@ void nghttp2_hd_huff_decode_context_init(nghttp2_hd_huff_decode_context *ctx);
|
|||
* will be written to |buf|. This function assumes that |buf| has the
|
||||
* enough room to store the decoded byte string.
|
||||
*
|
||||
* The caller must set the |final| to nonzero if the given input is
|
||||
* the final block.
|
||||
* The caller must set the |fin| to nonzero if the given input is the
|
||||
* final block.
|
||||
*
|
||||
* This function returns the number of read bytes from the |in|.
|
||||
*
|
||||
|
@ -425,6 +425,6 @@ void nghttp2_hd_huff_decode_context_init(nghttp2_hd_huff_decode_context *ctx);
|
|||
*/
|
||||
ssize_t nghttp2_hd_huff_decode(nghttp2_hd_huff_decode_context *ctx,
|
||||
nghttp2_buf *buf, const uint8_t *src,
|
||||
size_t srclen, int final);
|
||||
size_t srclen, int fin);
|
||||
|
||||
#endif /* NGHTTP2_HD_H */
|
||||
|
|
|
@ -1433,7 +1433,7 @@ static size_t encode_length(uint8_t *buf, uint64_t n, size_t prefix) {
|
|||
void test_nghttp2_hd_decode_length(void) {
|
||||
uint32_t out;
|
||||
size_t shift;
|
||||
int final;
|
||||
int fin;
|
||||
uint8_t buf[16];
|
||||
uint8_t *bufp;
|
||||
size_t len;
|
||||
|
@ -1443,39 +1443,39 @@ void test_nghttp2_hd_decode_length(void) {
|
|||
memset(buf, 0, sizeof(buf));
|
||||
len = encode_length(buf, UINT32_MAX, 7);
|
||||
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &final, 0, 0, buf, buf + len, 7);
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7);
|
||||
|
||||
CU_ASSERT((ssize_t)len == rv);
|
||||
CU_ASSERT(0 != final);
|
||||
CU_ASSERT(0 != fin);
|
||||
CU_ASSERT(UINT32_MAX == out);
|
||||
|
||||
/* Make sure that we can decode integer if we feed 1 byte at a
|
||||
time */
|
||||
out = 0;
|
||||
shift = 0;
|
||||
final = 0;
|
||||
fin = 0;
|
||||
bufp = buf;
|
||||
|
||||
for (i = 0; i < len; ++i, ++bufp) {
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &final, out, shift, bufp,
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &fin, out, shift, bufp,
|
||||
bufp + 1, 7);
|
||||
|
||||
CU_ASSERT(rv == 1);
|
||||
|
||||
if (final) {
|
||||
if (fin) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CU_ASSERT(i == len - 1);
|
||||
CU_ASSERT(0 != final);
|
||||
CU_ASSERT(0 != fin);
|
||||
CU_ASSERT(UINT32_MAX == out);
|
||||
|
||||
/* Check overflow case */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
len = encode_length(buf, 1ll << 32, 7);
|
||||
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &final, 0, 0, buf, buf + len, 7);
|
||||
rv = nghttp2_hd_decode_length(&out, &shift, &fin, 0, 0, buf, buf + len, 7);
|
||||
|
||||
CU_ASSERT(-1 == rv);
|
||||
}
|
||||
|
|
|
@ -158,14 +158,14 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
|
|||
nghttp2_buf_chain *ci;
|
||||
nghttp2_buf *buf;
|
||||
nghttp2_buf bp;
|
||||
int final;
|
||||
int fin;
|
||||
size_t processed;
|
||||
|
||||
processed = 0;
|
||||
|
||||
for (ci = bufs->head; ci; ci = ci->next) {
|
||||
buf = &ci->buf;
|
||||
final = nghttp2_buf_len(buf) == 0 || ci->next == NULL;
|
||||
fin = nghttp2_buf_len(buf) == 0 || ci->next == NULL;
|
||||
bp = *buf;
|
||||
|
||||
if (offset) {
|
||||
|
@ -179,7 +179,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
|
|||
for (;;) {
|
||||
inflate_flags = 0;
|
||||
rv = nghttp2_hd_inflate_hd2(inflater, &nv, &inflate_flags, bp.pos,
|
||||
nghttp2_buf_len(&bp), final);
|
||||
nghttp2_buf_len(&bp), fin);
|
||||
|
||||
if (rv < 0) {
|
||||
return rv;
|
||||
|
|
Loading…
Reference in New Issue