]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3911: clang -fsanitize warnings (#125)
authorAmos Jeffries <yadij@users.noreply.github.com>
Mon, 15 Jan 2018 18:59:37 +0000 (07:59 +1300)
committerGitHub <noreply@github.com>
Mon, 15 Jan 2018 18:59:37 +0000 (07:59 +1300)
Fixes warnings from clang when -fsanitize is used. Many of these are also part of the bug 4738 issues.

    error: private field 'callback' is not used [-Werror,-Wunused-private-field]
    error: private field 'cbdata' is not used [-Werror,-Wunused-private-field]
    error: private field 'IO' is not used [-Werror,-Wunused-private-field]
    error: variable 'wccp2_router_id_element' is not needed and
    will not be emitted [-Werror,-Wunneeded-internal-declaration]

We cannot set these warnings as default options yet because the STUB code intentionally does not use any private class members, so it would error on every unit test.

* Convert Store::LocalSearch to C++ initialization

* DiskThreadsDiskFile::IO is unused after setting by the constructor

Also, take the opportunity to redo the construct using C++11 initialization

* Remove currently unused wccp2_router_id_element

This resolves clang warnings until the WCCP redesign is completed.

src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc
src/DiskIO/DiskThreads/DiskThreadsDiskFile.h
src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
src/store/LocalSearch.cc
src/wccp2.cc

index 0babf09934da16d341a784258dff101cb63884f6..c6b1ac5fa96746a5c2b2e467fea25120472ad8bd 100644 (file)
@@ -26,8 +26,7 @@
 
 CBDATA_CLASS_INIT(DiskThreadsDiskFile);
 
-DiskThreadsDiskFile::DiskThreadsDiskFile(char const *aPath, DiskThreadsIOStrategy *anIO):fd(-1), errorOccured (false), IO(anIO),
-    inProgressIOs (0)
+DiskThreadsDiskFile::DiskThreadsDiskFile(char const *aPath)
 {
     assert(aPath);
     debugs(79, 3, "UFSFile::UFSFile: " << aPath);
index 2d47c0463609a30217ca609e8347b98ab1952121..8b4b9cfc096f37e91a1e9c0d11b71b797dbd13cc 100644 (file)
@@ -21,7 +21,7 @@ class DiskThreadsDiskFile : public DiskFile
     CBDATA_CLASS(DiskThreadsDiskFile);
 
 public:
-    DiskThreadsDiskFile(char const *path, DiskThreadsIOStrategy *);
+    DiskThreadsDiskFile(char const *path);
     ~DiskThreadsDiskFile();
     virtual void open(int flags, mode_t mode, RefCount<IORequestor> callback);
     virtual void create(int flags, mode_t mode, RefCount<IORequestor> callback);
@@ -51,11 +51,10 @@ private:
     static DWCB WriteDone;
 #endif
 
-    int fd;
-    bool errorOccured;
-    char const *path_;
-    DiskThreadsIOStrategy *IO;
-    size_t inProgressIOs;
+    int fd = -1;
+    bool errorOccured = false;
+    char const *path_ = nullptr;
+    size_t inProgressIOs = 0;
     static AIOCB OpenDone;
     void openDone(int fd, const char *buf, int aio_return, int aio_errno);
     RefCount<IORequestor> ioRequestor;
index ec1d9869c5f6c91c9fb8dc3d2227d97ae28aa80a..1bb5bd99817149f6708bc055b0bd4d80e525e885 100644 (file)
@@ -225,7 +225,7 @@ DiskThreadsIOStrategy::newFile (char const *path)
         return NULL;
     }
 
-    return new DiskThreadsDiskFile (path, this);
+    return new DiskThreadsDiskFile(path);
 }
 
 bool
index 1ef615a01b677017763137067e0ad501ca12f9dd..f7a1b0bf72f17b470ea62a1fe4ad2dbea3eb7dc3 100644 (file)
@@ -22,8 +22,6 @@ class LocalSearch : public StoreSearch
     CBDATA_CLASS(LocalSearch);
 
 public:
-    LocalSearch();
-
     /* StoreSearch API */
     virtual void next(void (callback)(void *cbdata), void *cbdata) override;
     virtual bool next() override;
@@ -33,10 +31,8 @@ public:
 
 private:
     void copyBucket();
-    void (*callback)(void *cbdata);
-    void *cbdata;
-    bool _done;
-    int bucket;
+    bool _done = false;
+    int bucket = 0;
     std::vector<StoreEntry *> entries;
 };
 
@@ -50,13 +46,6 @@ Store::NewLocalSearch()
     return new LocalSearch;
 }
 
-Store::LocalSearch::LocalSearch() :
-    callback(NULL),
-    cbdata(NULL),
-    _done(false),
-    bucket(0)
-{}
-
 void
 Store::LocalSearch::next(void (aCallback)(void *), void *aCallbackData)
 {
index 6255a99096412f6039e2c7410cbd70913b797923..f17f728feb0652035491ee6923c2d8d9b6812337 100644 (file)
@@ -276,7 +276,8 @@ struct wccp2_router_id_element_t {
     uint32_t received_id;
 };
 
-static struct wccp2_router_id_element_t wccp2_router_id_element;
+// unused (for now)
+// static struct wccp2_router_id_element_t wccp2_router_id_element;
 
 /** \interface WCCPv2_Protocol
  * Sect 5.6.9 Capabilities Info Component
@@ -807,7 +808,7 @@ wccp2Init(void)
         wccp2_cache_view_header.cache_view_type = htons(WCCP2_WC_VIEW_INFO);
 
         wccp2_cache_view_header.cache_view_length = htons(sizeof(wccp2_cache_view_header) - 4 +
-                sizeof(wccp2_cache_view_info) + (wccp2_numrouters * sizeof(wccp2_router_id_element)));
+                sizeof(wccp2_cache_view_info) + (wccp2_numrouters * sizeof(wccp2_router_id_element_t)));
 
         wccp2_cache_view_header.cache_view_version = htonl(1);