]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: stick-table: shut up invalid "uninitialized" warning in gcc 8.3
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Jul 2021 16:51:12 +0000 (18:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 6 Jul 2021 16:54:07 +0000 (18:54 +0200)
gcc 8.3.0 spews a bunch of:

  src/stick_table.c: In function 'action_inc_gpc0':
  include/haproxy/freq_ctr.h:66:12: warning: 'period' may be used uninitialized in this function [-Wmaybe-uninitialized]
    curr_tick += period;
            ^~
  src/stick_table.c:2241:15: note: 'period' was declared here
    unsigned int period;
               ^~~~~~
but they're incorrect because all accesses are guarded by the exact same
condition (ptr1 not being null), it's just the compiler being overzealous
about the uninitialized detection that seems to be stronger than its
ability to follow its own optimizations. This code path is not critical,
let's just pre-initialize the period to zero.

No backport is needed.

src/stick_table.c

index 7a02a194991946c190f301162b93ed97ee762b5b..e50ef2571e92812030501d969e2ca9d244b29613 100644 (file)
@@ -2238,7 +2238,7 @@ static enum act_return action_inc_gpc0(struct act_rule *rule, struct proxy *px,
 {
        struct stksess *ts;
        struct stkctr *stkctr;
-       unsigned int period;
+       unsigned int period = 0;
 
        /* Extract the stksess, return OK if no stksess available. */
        if (s)
@@ -2293,7 +2293,7 @@ static enum act_return action_inc_gpc1(struct act_rule *rule, struct proxy *px,
 {
        struct stksess *ts;
        struct stkctr *stkctr;
-       unsigned int period;
+       unsigned int period = 0;
 
        /* Extract the stksess, return OK if no stksess available. */
        if (s)
@@ -3269,7 +3269,7 @@ smp_fetch_sc_inc_gpc0(const struct arg *args, struct sample *smp, const char *kw
 {
        struct stkctr tmpstkctr;
        struct stkctr *stkctr;
-       unsigned int period;
+       unsigned int period = 0;
 
        stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr);
        if (!stkctr)
@@ -3338,7 +3338,7 @@ smp_fetch_sc_inc_gpc1(const struct arg *args, struct sample *smp, const char *kw
 {
        struct stkctr tmpstkctr;
        struct stkctr *stkctr;
-       unsigned int period;
+       unsigned int period = 0;
 
        stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr);
        if (!stkctr)