Skip to content

Commit

Permalink
fix: clang-format.py does not detect *.cc files
Browse files Browse the repository at this point in the history
  • Loading branch information
longfar-ncy committed Nov 27, 2023
1 parent 0f9eec4 commit 788719a
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build_support/run_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def check(arguments, source_dir):
fullpaths = (os.path.join(directory, filename)
for filename in filenames)
source_files = [x for x in fullpaths
if x.endswith(".h") or x.endswith(".cpp")]
if x.endswith(".h") or x.endswith(".cpp") or x.endswith(".cc")]
formatted_filenames.extend(
# Filter out files that match the globs in the globs file
[filename for filename in source_files
Expand Down
4 changes: 1 addition & 3 deletions src/base_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ bool BaseCmd::CheckArg(size_t num) const {
return num >= -arity_;
}

std::vector<std::string> BaseCmd::CurrentKey(PClient* client) const {
return std::vector<std::string>{client->Key()};
}
std::vector<std::string> BaseCmd::CurrentKey(PClient* client) const { return std::vector<std::string>{client->Key()}; }

void BaseCmd::Execute(PClient* client) {
if (!DoInitial(client)) {
Expand Down
3 changes: 1 addition & 2 deletions src/db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/


#include "db.h"
#include <arpa/inet.h>
#include <math.h>
Expand Down Expand Up @@ -424,7 +423,7 @@ int PDBLoader::Load(const char* filename) {
case kTypeQuickList: {
PString key = LoadKey();
PObject obj = LoadObject(indicator);
// DEBUG("encounter key = {}, obj.encoding = {}", key, obj.encoding);
// DEBUG("encounter key = {}, obj.encoding = {}", key, obj.encoding);

assert(absTimeout >= 0);

Expand Down
12 changes: 6 additions & 6 deletions src/helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void getRandomHexChars(char* p, unsigned int len) {
* time() at startup. */
for (j = 0; j < len; j++) {
p[j] ^= rand();
}
}
}
/* Turn it into hex digits taking just 4 bits out of 8 for every byte. */
for (j = 0; j < len; j++) {
Expand Down Expand Up @@ -261,19 +261,19 @@ size_t getMemoryInfo(MemoryInfoType type) {
while (!found && std::getline(ifs, line)) {
switch (type) {
case VmPeak:
if (line.find("VmPeak") == 0) {
if (line.find("VmPeak") == 0) {
found = true;
}
break;

case VmSize:
if (line.find("VmSize") == 0) {
if (line.find("VmSize") == 0) {
found = true;
}
break;

case VmLck:
if (line.find("VmLck") == 0) {
if (line.find("VmLck") == 0) {
found = true;
}
break;
Expand All @@ -285,13 +285,13 @@ size_t getMemoryInfo(MemoryInfoType type) {
break;

case VmRSS:
if (line.find("VmRSS") == 0) {
if (line.find("VmRSS") == 0) {
found = true;
}
break;

case VmSwap:
if (line.find("VmSwap") == 0) {
if (line.find("VmSwap") == 0) {
found = true;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/io_thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void IOThreadPool::Run(int ac, char* av[]) {
for (auto& w : worker_threads_) {
w.join();
}

worker_threads_.clear();

INFO("Process stopped, goodbye...");
Expand Down
3 changes: 2 additions & 1 deletion src/key_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

#include <cassert>
#include <fnmatch.h>
#include <cassert>

#include "log.h"
#include "store.h"

Expand Down
1 change: 0 additions & 1 deletion src/leveldb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/


#include "leveldb.h"
#include "leveldb/db.h"
#include "log.h"
Expand Down
10 changes: 5 additions & 5 deletions src/list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static PError push(const vector<PString>& params, UnboundedBuffer* reply, ListPo

FormatInt(static_cast<long>(list->size()), reply);
if (mayReady && !list->empty()) {
if (reply) {
if (reply) {
// push must before pop(serve)...
Propagate(params); // the push
PSTORE.ServeClient(params[1], list); // the pop
Expand Down Expand Up @@ -134,7 +134,7 @@ PError rpop(const vector<PString>& params, UnboundedBuffer* reply) {
}

static bool blockClient(PClient* client, const PString& key, uint64_t timeout, ListPosition pos,
const PString* dstList = 0) {
const PString* dstList = 0) {
auto now = ::Now();

if (timeout > 0) {
Expand All @@ -147,8 +147,8 @@ static bool blockClient(PClient* client, const PString& key, uint64_t timeout, L
}

static PError genericBlockedPop(vector<PString>::const_iterator keyBegin, vector<PString>::const_iterator keyEnd,
UnboundedBuffer* reply, ListPosition pos, long timeout,
const PString* target = nullptr, bool withKey = true) {
UnboundedBuffer* reply, ListPosition pos, long timeout, const PString* target = nullptr,
bool withKey = true) {
for (auto it(keyBegin); it != keyEnd; ++it) {
PString result;
PError err = GenericPop(*it, pos, result);
Expand Down Expand Up @@ -365,7 +365,7 @@ static void Index2Iterator(long start, long end, PList& list, PList::iterator* b
static size_t GetRange(long start, long end, PList& list, PList::iterator* beginIt = nullptr,
PList::iterator* endIt = nullptr) {
size_t rangeLen = 0;
if (start > end) { // empty
if (start > end) { // empty
if (beginIt) {
*beginIt = list.end();
}
Expand Down
1 change: 0 additions & 1 deletion src/net/unbounded_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/


#include "unbounded_buffer.h"
#include <cassert>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/pstd/thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ void ThreadPool::_MonitorRoutine() {
}
}

}
} // namespace pstd
8 changes: 4 additions & 4 deletions src/server_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ PError flushall(const std::vector<PString>& params, UnboundedBuffer* reply) {

PError bgsave(const std::vector<PString>& params, UnboundedBuffer* reply) {
if (g_qdbPid != -1) {
FormatBulk("-ERR Background save already in progress",
sizeof "-ERR Background save already in progress" - 1, reply);
FormatBulk("-ERR Background save already in progress", sizeof "-ERR Background save already in progress" - 1,
reply);

return PError_ok;
}
Expand All @@ -101,8 +101,8 @@ PError bgsave(const std::vector<PString>& params, UnboundedBuffer* reply) {

PError save(const std::vector<PString>& params, UnboundedBuffer* reply) {
if (g_qdbPid != -1) {
FormatBulk("-ERR Background save already in progress",
sizeof "-ERR Background save already in progress" - 1, reply);
FormatBulk("-ERR Background save already in progress", sizeof "-ERR Background save already in progress" - 1,
reply);

return PError_ok;
}
Expand Down
4 changes: 2 additions & 2 deletions src/store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ bool PStore::DeleteKey(const PString& key) {
size_t ret = 0;
// erase() from folly ConcurrentHashmap will throw an exception if hash function crashes
try {
ret = db->erase(key);
ret = db->erase(key);
} catch (const std::exception& e) {
return false;
return false;
}

return ret != 0;
Expand Down

0 comments on commit 788719a

Please sign in to comment.