Skip to content

Commit

Permalink
Clang format newline (faasm#29)
Browse files Browse the repository at this point in the history
* using same clang format binary than faasm

* applied new clang-format to all codebase

* adding newline at the end of the bash script
  • Loading branch information
csegarragonz authored Nov 20, 2020
1 parent 521fe47 commit 4eef481
Show file tree
Hide file tree
Showing 73 changed files with 89 additions and 73 deletions.
18 changes: 17 additions & 1 deletion bin/run_clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

set -e

function append_newline {
if [[ -z "$(tail -c 1 "$1")" ]]; then
:
else
echo >> "$1"
fi
}

if [ -z "$1" ]; then
TARGET_DIR="."
else
Expand All @@ -11,7 +19,15 @@ fi
pushd ${TARGET_DIR} >> /dev/null

# Find all source files using Git to automatically respect .gitignore
clang-format-10 -i $(git ls-files "*.h" "*.cpp" "*.c")
FILES=$(git ls-files "*.h" "*.cpp" "*.c")

# Run clang-format
clang-format-10 -i ${FILES}

# Check newlines
for f in ${FILES}; do
append_newline $f
done

popd >> /dev/null

2 changes: 1 addition & 1 deletion faabric.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// Stub to link together top-level CMake library
// Stub to link together top-level CMake library
2 changes: 1 addition & 1 deletion include/faabric/executor/FaabricExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class FaabricExecutor
bool success,
const std::string& errorMsg);
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/executor/FaabricMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class FaabricMain

faabric::executor::FaabricPool& pool;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/proto/RPCServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class RPCServer

virtual void doStart(const std::string& serverAddr) = 0;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/proto/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
#define DEFAULT_RPC_HOST "0.0.0.0"
#define STATE_PORT 8003
#define FUNCTION_CALL_PORT 8004
#define MPI_MESSAGE_PORT 8005
#define MPI_MESSAGE_PORT 8005
2 changes: 1 addition & 1 deletion include/faabric/scheduler/ExecGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ int countExecGraphNodes(const ExecGraph& graph);
std::string execNodeToJson(const ExecGraphNode& node);

std::string execGraphToJson(const ExecGraph& graph);
}
}
2 changes: 1 addition & 1 deletion include/faabric/scheduler/FunctionCallClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class FunctionCallClient

void sendMPIMessage(const faabric::MPIMessage& msg);
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/scheduler/FunctionCallServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class FunctionCallServer final
private:
Scheduler& scheduler;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/scheduler/InMemoryMessageQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
namespace faabric::scheduler {
typedef faabric::util::Queue<faabric::Message> InMemoryMessageQueue;
typedef std::pair<std::string, InMemoryMessageQueue*> InMemoryMessageQueuePair;
}
}
2 changes: 1 addition & 1 deletion include/faabric/scheduler/MpiContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class MpiContext
int rank;
int worldId;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/scheduler/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ class Scheduler
};

Scheduler& getScheduler();
}
}
2 changes: 1 addition & 1 deletion include/faabric/state/DummyStateServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class DummyStateServer
state::StateServer stateServer;
};

}
}
2 changes: 1 addition & 1 deletion include/faabric/state/InMemoryStateRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class InMemoryStateRegistry
};

InMemoryStateRegistry& getInMemoryStateRegistry();
}
}
2 changes: 1 addition & 1 deletion include/faabric/state/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class State
};

State& getGlobalState();
}
}
2 changes: 1 addition & 1 deletion include/faabric/state/StateClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class StateClient

void unlock();
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/state/StateKeyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ class StateKeyValueException : public std::runtime_error
: runtime_error(message)
{}
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/state/StateServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ class StateServer final
private:
State& state;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class Barrier
std::mutex mx;
std::condition_variable cv;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ int safeCopyToBuffer(const uint8_t* dataIn,
int dataLen,
uint8_t* buffer,
int bufferLen);
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/chaining.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class ChainedCallFailedException : public faabric::util::FaabricException
: FaabricException(std::move(message))
{}
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class Clock
};

Clock& getGlobalClock();
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ class SystemConfig
};

SystemConfig& getSystemConfig();
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ std::string setEnvVar(const std::string& varName, const std::string& value);
void unsetEnvVar(const std::string& varName);

unsigned int getUsableCores();
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class FaabricException : public std::exception
protected:
std::string _message;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class FileAtUrlIsDirectoryException : public faabric::util::FaabricException
: FaabricException(std::move(message))
{}
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/gids.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

namespace faabric::util {
unsigned int generateGid();
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class JsonFieldNotFound : public faabric::util::FaabricException

std::string getValueFromJsonString(const std::string& key,
const std::string& jsonIn);
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/locks.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ namespace faabric::util {
typedef std::unique_lock<std::mutex> UniqueLock;
typedef std::unique_lock<std::shared_mutex> FullLock;
typedef std::shared_lock<std::shared_mutex> SharedLock;
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace faabric::util {
void initLogging();

std::shared_ptr<spdlog::logger> getLogger();
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ size_t getRequiredHostPagesRoundDown(size_t nBytes);
size_t alignOffsetDown(size_t offset);

AlignedChunk getPageAlignedChunk(long offset, long length);
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ namespace faabric::util {
std::string getIPFromHostname(const std::string& hostname);

std::string getPrimaryIPForThisHost(const std::string& interface);
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ class TokenPool
int _size;
Queue<int> queue;
};
}
}
2 changes: 1 addition & 1 deletion include/faabric/util/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace faabric::util {
std::string randomString(int len);

std::string randomStringFromSet(const std::unordered_set<std::string>& s);
}
}
2 changes: 1 addition & 1 deletion include/faabric/wasm/wasm.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

int helloFaabricWasm();
int helloFaabricWasm();
2 changes: 1 addition & 1 deletion src/executor/FaabricExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ void FaabricExecutor::postFinish() {}

void FaabricExecutor::postFlush() {}

}
}
2 changes: 1 addition & 1 deletion src/proto/RPCServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ void RPCServer::stop()
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/scheduler/FunctionCallClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ void FunctionCallClient::sendMPIMessage(const faabric::MPIMessage& msg)
faabric::FunctionStatusResponse response;
CHECK_RPC("mpi_message", stub->MPICall(&context, msg, &response));
}
}
}
2 changes: 1 addition & 1 deletion src/scheduler/FunctionCallServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ Status FunctionCallServer::MPICall(ServerContext* context,

return Status::OK;
}
}
}
2 changes: 1 addition & 1 deletion src/scheduler/MpiContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ int MpiContext::getWorldId()
{
return worldId;
}
}
}
2 changes: 1 addition & 1 deletion src/scheduler/MpiWorldRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ void MpiWorldRegistry::clear()
faabric::util::FullLock lock(registryMutex);
worldMap.clear();
}
}
}
2 changes: 1 addition & 1 deletion src/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,4 @@ std::unordered_set<unsigned int> Scheduler::getChainedFunctions(

return chainedIds;
}
}
}
2 changes: 1 addition & 1 deletion src/state/DummyStateServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ void DummyStateServer::stop()
serverThread.join();
}
}
}
}
2 changes: 1 addition & 1 deletion src/state/RedisStateKeyValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ void RedisStateKeyValue::clearAppendedFromRemote()
{
redis::Redis::getState().del(joinedKey);
}
}
}
2 changes: 1 addition & 1 deletion src/state/StateClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ void StateClient::unlock()
ClientContext context;
CHECK_RPC("state_unlock", stub->Unlock(&context, request, &response))
}
}
}
2 changes: 1 addition & 1 deletion src/state/StateKeyValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@ std::vector<StateChunk> StateKeyValue::getDirtyChunks(

return chunks;
}
}
}
2 changes: 1 addition & 1 deletion src/util/barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ int Barrier::getUseCount()
return uses;
}

}
}
2 changes: 1 addition & 1 deletion src/util/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ unsigned int getUsableCores()

return nCores;
}
}
}
2 changes: 1 addition & 1 deletion src/util/gids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ unsigned int generateGid()
return intHash + counter.fetch_add(1);
}
}
}
}
2 changes: 1 addition & 1 deletion src/util/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ std::shared_ptr<spdlog::logger> getLogger()

return logger;
}
}
}
2 changes: 1 addition & 1 deletion src/util/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ std::string randomStringFromSet(const std::unordered_set<std::string>& s)

return *it;
}
}
}
2 changes: 1 addition & 1 deletion src/util/timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ void nanosToTimespec(uint64_t nanos, struct timespec* nativeTimespec)
nativeTimespec->tv_sec = nanos / 1000000000;
nativeTimespec->tv_nsec = nanos % 1000000000;
}
}
}
2 changes: 1 addition & 1 deletion tests/test/endpoint/test_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ TEST_CASE("Check getting function status from endpoint", "[endpoint]")

REQUIRE(actual == expectedOutput);
}
}
}
2 changes: 1 addition & 1 deletion tests/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ int main(int argc, char* argv[])
fflush(stdout);

return result;
}
}
Loading

0 comments on commit 4eef481

Please sign in to comment.