]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix GCC-9 build issues (#413)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sat, 8 Jun 2019 11:40:40 +0000 (11:40 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 8 Jun 2019 11:40:44 +0000 (11:40 +0000)
GCC-9 continues the development track started with GCC-8
producing more warnings and errors about possible code issues
which Squid use of "-Wall -Werror" turns into hard build
failures:

 error: ‘strncpy’ output may be truncated copying 6 bytes from a
   string of length 6 [-Werror=stringop-truncation]

 error: ‘%s’ directive argument is null
  [-Werror=format-overflow=]

 error: ‘void* memset(void*, int, size_t)’ clearing an object of
  type ... with no trivial copy-assignment; use assignment or
  value-initialization instead [-Werror=class-memaccess]

 error: ‘void* memset(void*, int, size_t)’ clearing an object of
  non-trivial type ...; use assignment or value-initialization
  instead [-Werror=class-memaccess]

Also, segmentation faults with minimal builds have been
identified as std::string template differences between
optimized and non-optimized object binaries. This results in
cppunit (built with optimizations) crashing unit tests when
freeing memory. Workaround that temporarily by removing the use
of --disable-optimizations from minimal builds.

12 files changed:
lib/html_quote.c
src/StoreStats.cc
src/StoreStats.h
src/StoreSwapLogData.cc
src/StoreSwapLogData.h
src/auth/negotiate/kerberos/negotiate_kerberos_auth.cc
src/ipc/SharedListen.cc
src/ipc/SharedListen.h
src/mgr/InfoAction.cc
src/mgr/InfoAction.h
src/tests/stub_store_stats.cc
test-suite/buildtests/layer-01-minimal.opts

index 8c179f93f8574b0db975f04b84191933da992d6d..62154177316bcee16889828316c5cbd65eb467e5 100644 (file)
@@ -90,7 +90,7 @@ html_quote(const char *string)
         }
         if (escape) {
             /* Ok, An escaped form was found above. Use it */
-            strncpy(dst, escape, 6);
+            strncpy(dst, escape, 7);
             dst += strlen(escape);
         } else {
             /* Apparently there is no need to escape this character */
index 63cff8bbb1a0473e81d29f34fd755b6af611a7ee..8ac359ef569b6e6f319e09b555b322d2d64d5cd9 100644 (file)
 #include "StoreStats.h"
 #include "tools.h"
 
-/* StoreInfoStats */
-
-StoreInfoStats::StoreInfoStats()
-{
-    memset(this, 0, sizeof(*this));
-}
-
 StoreInfoStats &
 StoreInfoStats::operator +=(const StoreInfoStats &stats)
 {
index 9ba56a62d69b85b6e1c7d2aa1e1812ea1000a57a..1d5ee95ac4394405c8ac130256dcc4236c75db1e 100644 (file)
@@ -17,9 +17,9 @@ public:
     class Part
     {
     public:
-        double size; ///< bytes currently in use
-        double count; ///< number of cached objects
-        double capacity; ///< the size limit
+        double size = 0.0; ///< bytes currently in use
+        double count = 0.0; ///< number of cached objects
+        double capacity = 0.0; ///< the size limit
 
         /// mean size of a cached object
         double meanObjectSize() const { return count > 0 ? size/count : 0.0; }
@@ -32,25 +32,24 @@ public:
     class Swap: public Part
     {
     public:
-        double open_disk_fd; ///< number of opened disk files
+        double open_disk_fd = 0.0; ///< number of opened disk files
     };
 
     /// memory cache (cache_mem) storage stats
     class Mem: public Part
     {
     public:
-        bool shared; ///< whether memory cache is shared among workers
+        bool shared = false; ///< whether memory cache is shared among workers
     };
 
-    StoreInfoStats();
     StoreInfoStats &operator +=(const StoreInfoStats &stats);
 
     Swap swap; ///< cache_mem stats
     Mem mem; ///< all cache_dirs stats
 
     /* stats that could be shared by memory and disk storage */
-    double store_entry_count; ///< number of StoreEntry objects in existence
-    double mem_object_count; ///< number of MemObject objects in existence
+    double store_entry_count = 0.0; ///< number of StoreEntry objects in existence
+    double mem_object_count = 0.0; ///< number of MemObject objects in existence
 };
 
 // TODO: this should be adjusted for use in StoreIoActionData, DiskdActionData
index c8c045c8cf69a500e5c83d4f2cb7307431bdbe38..a21392bb188ee73d95dad5df2a4f31873c7d589a 100644 (file)
@@ -49,11 +49,6 @@ SwapChecksum24::print(std::ostream &os) const
     return os << raw[0] << '-' << raw[1] << '-' << raw[2];
 }
 
-StoreSwapLogData::StoreSwapLogData()
-{
-    memset(this, 0, sizeof(*this));
-}
-
 bool
 StoreSwapLogData::sane() const
 {
index 2f4b468329c3568cb502848506d76d27b1701d2c..424bf83fa83fe8bb07791210009406d9bbbe7a00 100644 (file)
@@ -90,8 +90,6 @@ public:
     /// type to use for storing time-related members; must be signed
     typedef int64_t SwappedTime;
 
-    StoreSwapLogData();
-
     /// consistency self-check: whether the data appears to make sense
     bool sane() const;
 
@@ -102,7 +100,7 @@ public:
      * Either SWAP_LOG_ADD when an object is added to the disk storage,
      * or SWAP_LOG_DEL when an object is deleted.
      */
-    uint8_t op;
+    uint8_t op = 0;
 
     /**
      * Fingerprint to weed out bogus/corrupted swap.state entries.
@@ -116,7 +114,7 @@ public:
      * are set at run time because the order of storage directories
      * may change over time.
      */
-    sfileno swap_filen;
+    sfileno swap_filen = 0;
 
     /**
      * A Unix time value that represents the time when
@@ -125,12 +123,12 @@ public:
      * to that time. Otherwise, it is set to the Squid process time
      * when the response is read (as soon as the end of headers are found).
      */
-    SwappedTime timestamp;
+    SwappedTime timestamp = 0;
 
     /**
      * The last time that a client requested this object.
      */
-    SwappedTime lastref;
+    SwappedTime lastref = 0;
 
     /**
      * The value of the response's Expires: header, if any.
@@ -141,20 +139,20 @@ public:
      * where Squid sets expires to -2. This happens for the
      * internal "netdb" object and for FTP URL responses.
      */
-    SwappedTime expires;
+    SwappedTime expires = 0;
 
     /**
      * The value of the response's Last-modified: header, if any.
      * This is set to -1 if there is no Last-modified: header,
      * or if it is unparseable.
      */
-    SwappedTime lastmod;
+    SwappedTime lastmod = 0;
 
     /**
      * This is the number of bytes that the object occupies on
      * disk. It includes the Squid "swap file header".
      */
-    uint64_t swap_file_sz;
+    uint64_t swap_file_sz = 0;
 
     /**
      * The number of times that this object has been accessed (referenced).
@@ -168,12 +166,12 @@ public:
      * check when rebuilding the cache at startup. Objects that
      * have the KEY_PRIVATE flag set are not added back to the cache.
      */
-    uint16_t flags;
+    uint16_t flags = 0;
 
     /**
      * The 128-bit MD5 hash for this object.
      */
-    unsigned char key[SQUID_MD5_DIGEST_LENGTH];
+    unsigned char key[SQUID_MD5_DIGEST_LENGTH] = {};
 };
 
 /// \ingroup FileFormatSwapStateAPI
index 19a0081c9ef2cf90b9282437441b921faee4a4c4..72d6c4b4c2b5f73c4b15ca07ae4a5013498d45c4 100644 (file)
@@ -822,7 +822,8 @@ main(int argc, char *const argv[])
                 goto cleanup;
             if (major_status & GSS_S_CONTINUE_NEEDED) {
                 debug((char *) "%s| %s: INFO: continuation needed\n", LogTime(), PROGRAM);
-                fprintf(stdout, "ERR token=%s\n", token);
+                // XXX: where to get the server token for delivery to client? token is nullptr here.
+                fprintf(stdout, "ERR\n");
                 goto cleanup;
             }
             gss_release_buffer(&minor_status, &output_token);
index 2030006023c4c3f9869f89f54ed04731912410a4..1a0a5771ed3ad0d2ba367d6a65be9cc316c48870 100644 (file)
@@ -54,11 +54,6 @@ AddToMap(const PendingOpenRequest &por)
     return -1;
 }
 
-Ipc::OpenListenerParams::OpenListenerParams()
-{
-    memset(this, 0, sizeof(*this));
-}
-
 bool
 Ipc::OpenListenerParams::operator <(const OpenListenerParams &p) const
 {
index ed0a01889a5992f8bd399df6303db96cb400e966..9d888afc6d5c226243e7ad0f3c91e3ffa7ea93db 100644 (file)
@@ -24,18 +24,16 @@ namespace Ipc
 class OpenListenerParams
 {
 public:
-    OpenListenerParams();
-
     bool operator <(const OpenListenerParams &p) const; ///< useful for map<>
 
     // bits to re-create the fde entry
-    int sock_type;
-    int proto;
-    int fdNote; ///< index into fd_note() comment strings
+    int sock_type = 0;
+    int proto = 0;
+    int fdNote = 0; ///< index into fd_note() comment strings
 
     // bits to re-create the listener Comm::Connection descriptor
     Ip::Address addr; ///< will be memset and memcopied
-    int flags;
+    int flags = 0;
 
     /// handler to subscribe to Comm::ConnAcceptor when we get the response
     Subscription::Pointer handlerSubscription;
index b9a51909f3660d2a23e3521ff87e59f8274532a0..c7a341f4f06451ded8041256baeb6b50f1046601 100644 (file)
@@ -28,11 +28,6 @@ void GetInfo(Mgr::InfoActionData& stats);
 void DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry);
 void DumpMallocStatistics(StoreEntry* sentry);
 
-Mgr::InfoActionData::InfoActionData()
-{
-    memset(this, 0, sizeof(*this));
-}
-
 Mgr::InfoActionData&
 Mgr::InfoActionData::operator += (const InfoActionData& stats)
 {
index 2a66b253381f059f3af5817d6c7e9c0ebc1b67d3..caea722841c79038abb2f180af52b77a2f98691a 100644 (file)
@@ -22,73 +22,72 @@ namespace Mgr
 class InfoActionData
 {
 public:
-    InfoActionData();
     InfoActionData& operator += (const InfoActionData& stats);
 
 public:
-    struct timeval squid_start;
-    struct timeval current_time;
-    double client_http_clients;
-    double client_http_requests;
-    double icp_pkts_recv;
-    double icp_pkts_sent;
-    double icp_replies_queued;
+    struct timeval squid_start = {};
+    struct timeval current_time = {};
+    double client_http_clients = 0.0;
+    double client_http_requests = 0.0;
+    double icp_pkts_recv = 0.0;
+    double icp_pkts_sent = 0.0;
+    double icp_replies_queued = 0.0;
 #if USE_HTCP
-    double htcp_pkts_recv;
-    double htcp_pkts_sent;
+    double htcp_pkts_recv = 0.0;
+    double htcp_pkts_sent = 0.0;
 #endif
-    double request_failure_ratio;
-    double avg_client_http_requests;
-    double avg_icp_messages;
-    double select_loops;
-    double avg_loop_time;
-    double request_hit_ratio5;
-    double request_hit_ratio60;
-    double byte_hit_ratio5;
-    double byte_hit_ratio60;
-    double request_hit_mem_ratio5;
-    double request_hit_mem_ratio60;
-    double request_hit_disk_ratio5;
-    double request_hit_disk_ratio60;
+    double request_failure_ratio = 0.0;
+    double avg_client_http_requests = 0.0;
+    double avg_icp_messages = 0.0;
+    double select_loops = 0.0;
+    double avg_loop_time = 0.0;
+    double request_hit_ratio5 = 0.0;
+    double request_hit_ratio60 = 0.0;
+    double byte_hit_ratio5 = 0.0;
+    double byte_hit_ratio60 = 0.0;
+    double request_hit_mem_ratio5 = 0.0;
+    double request_hit_mem_ratio60 = 0.0;
+    double request_hit_disk_ratio5 = 0.0;
+    double request_hit_disk_ratio60 = 0.0;
 
     StoreInfoStats store; ///< disk and memory cache statistics
 
-    double unlink_requests;
-    double http_requests5;
-    double http_requests60;
-    double cache_misses5;
-    double cache_misses60;
-    double cache_hits5;
-    double cache_hits60;
-    double near_hits5;
-    double near_hits60;
-    double not_modified_replies5;
-    double not_modified_replies60;
-    double dns_lookups5;
-    double dns_lookups60;
-    double icp_queries5;
-    double icp_queries60;
-    double up_time;
-    double cpu_time;
-    double cpu_usage;
-    double cpu_usage5;
-    double cpu_usage60;
-    double maxrss;
-    double page_faults;
+    double unlink_requests = 0.0;
+    double http_requests5 = 0.0;
+    double http_requests60 = 0.0;
+    double cache_misses5 = 0.0;
+    double cache_misses60 = 0.0;
+    double cache_hits5 = 0.0;
+    double cache_hits60 = 0.0;
+    double near_hits5 = 0.0;
+    double near_hits60 = 0.0;
+    double not_modified_replies5 = 0.0;
+    double not_modified_replies60 = 0.0;
+    double dns_lookups5 = 0.0;
+    double dns_lookups60 = 0.0;
+    double icp_queries5 = 0.0;
+    double icp_queries60 = 0.0;
+    double up_time = 0.0;
+    double cpu_time = 0.0;
+    double cpu_usage = 0.0;
+    double cpu_usage5 = 0.0;
+    double cpu_usage60 = 0.0;
+    double maxrss = 0.0;
+    double page_faults = 0.0;
 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
-    double ms_bytes_total;
-    double ms_bytes_free;
+    double ms_bytes_total = 0.0;
+    double ms_bytes_free = 0.0;
 #endif
-    double total_accounted;
-    double gb_saved_count;
-    double gb_freed_count;
-    double max_fd;
-    double biggest_fd;
-    double number_fd;
-    double opening_fd;
-    double num_fd_free;
-    double reserved_fd;
-    unsigned int count;
+    double total_accounted = 0.0;
+    double gb_saved_count = 0.0;
+    double gb_freed_count = 0.0;
+    double max_fd = 0.0;
+    double biggest_fd = 0.0;
+    double number_fd = 0.0;
+    double opening_fd = 0.0;
+    double num_fd_free = 0.0;
+    double reserved_fd = 0.0;
+    unsigned int count = 0;
 };
 
 /// implement aggregated 'info' action
index c8188a36051b20b19e26510007eab0196421097c..7735f0857fc6cddde7d239f15e76bd010a8ca802 100644 (file)
@@ -14,8 +14,6 @@
 #include "StoreStats.h"
 #include <cstring>
 
-StoreInfoStats::StoreInfoStats() STUB
-
 StoreInfoStats &
 StoreInfoStats::operator +=(const StoreInfoStats &stats) STUB_RETVAL(*this)
 
index ad4fb341ed9e114cc1633413b84ec47ad04cfcd4..e6f50e5d29abe9cf6919ad4d865f2bfd740bb0fa 100644 (file)
@@ -30,6 +30,8 @@ MAKETEST="distcheck"
 #   --without-filedescriptors \
 #   --without-build-environment \
 #
+#  GCC-9 cannot (yet) test this due to segmentation faults in std::string template optimizations (via cppunit)
+#      --disable-optimizations \
 #
 # NP: DISTCHECK_CONFIGURE_FLAGS is a magic automake macro for the 
 #     distcheck target recursive tests beteen scripted runs.
@@ -38,7 +40,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \
        --disable-build-info \
        --disable-loadable-modules \
        --disable-gnuregex \
-       --disable-optimizations \
        --disable-debug-cbdata \
        --disable-xmalloc-statistics \
        --disable-async-io \