CLEANUP: hpack: export debug functions and move inlines to .h

When building contrib/hpack there is a warning about an unused static
function. Actually it makes no sense to make it static, instead it must
be regularly exported. Similarly there is hpack_dht_get_tail() which is
inlined in the C file and which would make more sense with all other ones
in the H file.
This commit is contained in:
Willy Tarreau 2020-06-05 09:05:31 +02:00
parent 6be7849f39
commit 4f6535d734
2 changed files with 17 additions and 12 deletions

View File

@ -49,8 +49,13 @@
extern const struct http_hdr hpack_sht[HPACK_SHT_SIZE];
extern struct pool_head *pool_head_hpack_tbl;
extern int __hpack_dht_make_room(struct hpack_dht *dht, unsigned int needed);
extern int hpack_dht_insert(struct hpack_dht *dht, struct ist name, struct ist value);
int __hpack_dht_make_room(struct hpack_dht *dht, unsigned int needed);
int hpack_dht_insert(struct hpack_dht *dht, struct ist name, struct ist value);
#ifdef DEBUG_HPACK
void hpack_dht_dump(FILE *out, const struct hpack_dht *dht);
void hpack_dht_check_consistency(const struct hpack_dht *dht);
#endif
/* return a pointer to the entry designated by index <idx> (starting at 1) or
* NULL if this index is not there.
@ -126,6 +131,14 @@ static inline struct ist hpack_idx_to_value(const struct hpack_dht *dht, uint32_
return hpack_get_value(dht, dte);
}
/* returns the slot number of the oldest entry (tail). Must not be used on an
* empty table.
*/
static inline unsigned int hpack_dht_get_tail(const struct hpack_dht *dht)
{
return ((dht->head + 1U < dht->used) ? dht->wrap : 0) + dht->head + 1U - dht->used;
}
/* Purges table dht until a header field of <needed> bytes fits according to
* the protocol (adding 32 bytes overhead). Returns non-zero on success, zero
* on failure (ie: table empty but still not sufficient).

View File

@ -101,17 +101,9 @@ const struct http_hdr hpack_sht[HPACK_SHT_SIZE] = {
struct pool_head *pool_head_hpack_tbl = NULL;
/* returns the slot number of the oldest entry (tail). Must not be used on an
* empty table.
*/
static inline unsigned int hpack_dht_get_tail(const struct hpack_dht *dht)
{
return ((dht->head + 1U < dht->used) ? dht->wrap : 0) + dht->head + 1U - dht->used;
}
#ifdef DEBUG_HPACK
/* dump the whole dynamic header table */
static void hpack_dht_dump(FILE *out, const struct hpack_dht *dht)
void hpack_dht_dump(FILE *out, const struct hpack_dht *dht)
{
unsigned int i;
unsigned int slot;
@ -128,7 +120,7 @@ static void hpack_dht_dump(FILE *out, const struct hpack_dht *dht)
}
/* check for the whole dynamic header table consistency, abort on failures */
static void hpack_dht_check_consistency(const struct hpack_dht *dht)
void hpack_dht_check_consistency(const struct hpack_dht *dht)
{
unsigned slot = hpack_dht_get_tail(dht);
unsigned used2 = dht->used;