Skip to content

Commit

Permalink
Bug 3911: clang -fsanitize warnings (#125)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yadij committed Jan 15, 2018
1 parent 205f234 commit 43b6575
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc
Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions src/DiskIO/DiskThreads/DiskThreadsDiskFile.h
Expand Up @@ -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);
Expand Down Expand Up @@ -51,11 +51,10 @@ class DiskThreadsDiskFile : public DiskFile
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;
Expand Down
2 changes: 1 addition & 1 deletion src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
Expand Up @@ -225,7 +225,7 @@ DiskThreadsIOStrategy::newFile (char const *path)
return NULL;
}

return new DiskThreadsDiskFile (path, this);
return new DiskThreadsDiskFile(path);
}

bool
Expand Down
15 changes: 2 additions & 13 deletions src/store/LocalSearch.cc
Expand Up @@ -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;
Expand All @@ -33,10 +31,8 @@ class LocalSearch : public StoreSearch

private:
void copyBucket();
void (*callback)(void *cbdata);
void *cbdata;
bool _done;
int bucket;
bool _done = false;
int bucket = 0;
std::vector<StoreEntry *> entries;
};

Expand All @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions src/wccp2.cc
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 43b6575

Please sign in to comment.