]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 5481: Fix GCC v14 build [-Wmaybe-uninitialized] (#1982)
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 14 Jan 2025 19:22:36 +0000 (19:22 +0000)
committerFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Sun, 19 Jan 2025 22:24:18 +0000 (22:24 +0000)
Successful xstrtoui(start,end) calls do initialize `end`, but we can
polish this code and avoid triggering that GCC warning at the same time.

src/ip/QosConfig.cc

index a9e2e178b722243ec325ffa942f85591b3514eff..c0bcbd810c6c193e09e30edd5a12d55255c21a7b 100644 (file)
@@ -390,12 +390,13 @@ Ip::Qos::Config::parseConfigLine()
 
         } else if (strncmp(token, "miss=",5) == 0) {
 
-            char *end;
             if (mark) {
+                char *end = nullptr;
                 if (!xstrtoui(&token[5], &end, &markMiss, 0, std::numeric_limits<nfmark_t>::max())) {
                     debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss value " << &token[5]);
                     self_destruct();
                 }
+                Assure(end);
                 if (*end == '/') {
                     if (!xstrtoui(end + 1, nullptr, &markMissMask, 0, std::numeric_limits<nfmark_t>::max())) {
                         debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss mask value " << (end + 1) << ". Using 0xFFFFFFFF instead.");
@@ -405,12 +406,14 @@ Ip::Qos::Config::parseConfigLine()
                     markMissMask = 0xFFFFFFFF;
                 }
             } else {
+                char *end = nullptr;
                 unsigned int v = 0;
                 if (!xstrtoui(&token[5], &end, &v, 0, std::numeric_limits<tos_t>::max())) {
                     debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss value " << &token[5]);
                     self_destruct();
                 }
                 tosMiss = (tos_t)v;
+                Assure(end);
                 if (*end == '/') {
                     if (!xstrtoui(end + 1, nullptr, &v, 0, std::numeric_limits<tos_t>::max())) {
                         debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss mask value " << (end + 1) << ". Using 0xFF instead.");