BUILD: http_htx: silence uninitialized warning on some gcc versions
Building on gcc 4.4 reports "start may be used uninitialized". This is a classical case of dependency between two variables where the compiler lost track of their initialization and doesn't know that if one is not set, the other is. By just moving the second test in the else clause of the assignment both fixes it and makes the code more efficient, and this can be simplified as a ternary operator. It's probably not needed to backport this, unless anyone reports build warnings with more recent compilers (intermediary optimization levels such as -O1 can sometimes trigger such warnings).
This commit is contained in:
parent
c2cd6a419c
commit
db812f73af
@ -605,22 +605,19 @@ int http_prepend_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const s
|
||||
struct htx_blk *blk = ctx->blk;
|
||||
struct ist v;
|
||||
uint32_t off = 0;
|
||||
uint8_t first = 0;
|
||||
uint8_t first;
|
||||
|
||||
if (!blk)
|
||||
goto fail;
|
||||
|
||||
v = htx_get_blk_value(htx, blk);
|
||||
|
||||
if (!istlen(v)) {
|
||||
start = v.ptr;
|
||||
first = 1;
|
||||
}
|
||||
first = !istlen(v);
|
||||
start = first ? v.ptr : istptr(ctx->value) - ctx->lws_before;
|
||||
|
||||
if (unlikely(!istlen(ctx->value)))
|
||||
goto fail; /* invalid: value is empty, not supported */
|
||||
|
||||
if (!first)
|
||||
start = istptr(ctx->value) - ctx->lws_before;
|
||||
off = start - v.ptr;
|
||||
|
||||
blk = htx_replace_blk_value(htx, blk, ist2(start, 0), data);
|
||||
|
Loading…
Reference in New Issue
Block a user