PR-786 Run cpplint against runtime and fix a large number of digressions

This commit is contained in:
Garret Fick 2019-11-19 13:54:53 -05:00
parent 4627b60abe
commit accba041c0
No known key found for this signature in database
GPG Key ID: A1BBEF9D2AB249C6
5 changed files with 24 additions and 18 deletions

View File

@ -171,8 +171,7 @@ void bootstrap()
// Our next step here is to start the main loop, so start any
// services that we want now.
for (auto it = config.services.begin(); it != config.services.end(); ++it)
{
for (auto it = config.services.begin(); it != config.services.end(); ++it) {
const char* service_config = "";
ServiceDefinition* def = services_find(it->c_str());
def->start(service_config);

View File

@ -80,8 +80,7 @@ class Dnp3ToSpdLogger final : public openpal::ILogHandler, private openpal::Unco
spdlog::info("{}", entry.message);
}
static std::shared_ptr<openpal::ILogHandler>Create()
{
static std::shared_ptr<openpal::ILogHandler>Create() {
return std::make_shared<Dnp3ToSpdLogger>();
}

View File

@ -145,8 +145,7 @@ std::int8_t copy_command_config(const char *source, char target[],
/// @param port
/// @return the file descriptor for the socket, or less than 0 if a socket
/// if an error occurred.
int interactive_open_socket(uint16_t port)
{
int interactive_open_socket(uint16_t port) {
int socket_fd;
struct sockaddr_in server_addr;
@ -161,7 +160,7 @@ int interactive_open_socket(uint16_t port)
// Set SO_REUSEADDR
int enable = 1;
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR,
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR
&enable, sizeof(int)) < 0)
{
perror("setsockopt(SO_REUSEADDR) failed");
@ -198,8 +197,7 @@ int interactive_open_socket(uint16_t port)
/// @param run A flag that is set to false when we should stop polling.
/// @param socket_fd The socket file descriptor we are listening on.
/// @return the client file descriptor.
int interactive_wait_new_client(volatile bool& run, int socket_fd)
{
int interactive_wait_new_client(volatile bool& run, int socket_fd) {
int client_fd;
struct sockaddr_in client_addr;
socklen_t client_len;
@ -260,7 +258,8 @@ void interactive_client_command(const char* command, int client_fd)
else if (strncmp(command, "stop_modbus()", 13) == 0)
{
ServiceDefinition* def = services_find("modbusslave");
if (def) {
if (def)
{
def->stop();
}
}
@ -276,12 +275,14 @@ void interactive_client_command(const char* command, int client_fd)
else if (strncmp(command, "stop_dnp3()", 11) == 0)
{
ServiceDefinition* def = services_find("dnp3s");
if (def) {
if (def)
{
def->stop();
}
}
#endif // OPLC_DNP3_OUTSTATION
else if (strncmp(command, "start_enip(", 11) == 0) {
else if (strncmp(command, "start_enip(", 11) == 0)
{
spdlog::info("Issued start_enip() command to start on port: {}", readCommandArgument(command));
enip_port = readCommandArgument(command);
if (run_enip)
@ -314,9 +315,11 @@ void interactive_client_command(const char* command, int client_fd)
def->start(command_buffer);
}
}
else if (strncmp(command, "stop_pstorage()", 15) == 0) {
else if (strncmp(command, "stop_pstorage()", 15) == 0)
{
ServiceDefinition* def = services_find("pstorage");
if (def) {
if (def)
{
def->stop();
}
}

View File

@ -55,8 +55,7 @@ uint8_t run_openplc = 1; // Variable to control OpenPLC Runtime execution
/// \param ts
/// \param delay in milliseconds
////////////////////////////////////////////////////////////////////////////////
void sleep_until(struct timespec *ts, int delay)
{
void sleep_until(struct timespec *ts, int delay) {
ts->tv_nsec += delay;
if (ts->tv_nsec >= 1000*1000*1000)
{
@ -175,6 +174,13 @@ int main(int argc, char **argv)
{
std::lock_guard<std::mutex> guard(bufferLock);
// Make sure the buffer pointers are correct and
// attached to the user variables
glueVars();
// Read input image
updateBuffersIn();
updateCustomIn();
// Update input image table with data from slave devices
updateBuffersIn_MB();

View File

@ -306,8 +306,7 @@ inline int8_t read_and_check(istream& input_stream, const char header[],
}
int8_t pstorage_read(istream& input_stream,
const GlueVariablesBinding& bindings)
{
const GlueVariablesBinding& bindings) {
// Read the file header - we define the file header as a constant that
// must be present as the header. We don't allow UTF BOMs here.
char header_check[FILE_HEADER_SIZE];