]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: http_fetch: silence an uninitiialized warning with gcc-4/5/6 at -Os
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Oct 2022 07:18:34 +0000 (09:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Oct 2022 07:18:34 +0000 (09:18 +0200)
Gcc 4.x, 5.x and 6.x report this when compiling http_fetch.c:

  src/http_fetch.c: In function 'smp_fetch_meth':
  src/http_fetch.c:357:6: warning: 'htx' may be used uninitialized in this function [-Wmaybe-uninitialized]
     sl = http_get_stline(htx);

That's quite weird since there's no such code path, but presetting the
htx variable to NULL during declaration is enough to shut it up.

This may be backported to any version that has dbbdb25f1 ("BUG/MINOR:
http-fetch: Use integer value when possible in "method" sample fetch")
as it's the one that triggered this warning (hence at least 2.0).

src/http_fetch.c

index 1579b4ede925fb24a77b696652ce824d89fb006e..abb19a4554533549dd87601db963642385c8ca0d 100644 (file)
@@ -334,7 +334,7 @@ static int smp_fetch_meth(const struct arg *args, struct sample *smp, const char
 {
        struct channel *chn = SMP_REQ_CHN(smp);
        struct http_txn *txn;
-       struct htx *htx;
+       struct htx *htx = NULL;
        int meth;
 
        txn = (smp->strm ? smp->strm->txn : NULL);