Repository: eclipse-bluechi/bluechi (language: python)

Issue:
Apply code formatting rules
## Please describe what you would like to see

Based on the discussions in https://github.com/engelmi/orch/pull/55: 
- Exchange all `#ifndef xyz #define xyz` by `#pragma once`
- Re-order the `#include` in all source files to have the system headers first, followed by an empty line and then the local includes


Discussion / hints:

Fix patch:
diff --git a/binchihua/src/common/hashmap/hashmap.h b/binchihua/src/common/hashmap/hashmap.h
index 4b72481bca..ed6e4ac7d5 100644
--- a/binchihua/src/common/hashmap/hashmap.h
+++ b/binchihua/src/common/hashmap/hashmap.h
@@ -2,8 +2,7 @@
 // Use of this source code is governed by an MIT-style
 // license that can be found in the LICENSE file.
 
-#ifndef HASHMAP_H
-#define HASHMAP_H
+#pragma once
 
 #include <stdbool.h>
 #include <stddef.h>
@@ -49,5 +48,3 @@ uint64_t hashmap_murmur(const void *data, size_t len, uint64_t seed0, uint64_t s
 
 // DEPRECATED: use `hashmap_new_with_allocator`
 void hashmap_set_allocator(void *(*malloc)(size_t), void (*free)(void *));
-
-#endif
diff --git a/binchihua/src/common/list.h b/binchihua/src/common/list.h
index 9c49df2eea..435738c933 100644
--- a/binchihua/src/common/list.h
+++ b/binchihua/src/common/list.h
@@ -21,8 +21,7 @@
   and was formatted to follow this project's formatting style.)
 ***/
 
-#ifndef _BLUE_CHIHUAHUA_COMMON_LIST
-#define _BLUE_CHIHUAHUA_COMMON_LIST
+#pragma once
 
 #include <assert.h>
 #include <stdbool.h>
@@ -211,5 +210,3 @@
                         LIST_REMOVE(name, *_a, _p); \
                 _p;                                 \
         })
-
-#endif
\ No newline at end of file
diff --git a/binchihua/src/common/opt.h b/binchihua/src/common/opt.h
index ed37906dd2..37b6fb58d2 100644
--- a/binchihua/src/common/opt.h
+++ b/binchihua/src/common/opt.h
@@ -1,6 +1,6 @@
-#ifndef _BLUE_CHIHUAHUA_NODE_OPTIONS_COMMON
-#define _BLUE_CHIHUAHUA_NODE_OPTIONS_COMMON
+#pragma once
 
+// NOLINTBEGIN(modernize-macro-to-enum)
 #define ARG_PORT "port"
 #define ARG_PORT_SHORT 'P'
 #define ARG_HOST "host"
@@ -9,5 +9,4 @@
 #define ARG_CONFIG_SHORT 'c'
 #define ARG_HELP "help"
 #define ARG_HELP_SHORT 'h'
-
-#endif
\ No newline at end of file
+// NOLINTEND(modernize-macro-to-enum)
diff --git a/binchihua/src/common/parse-util.c b/binchihua/src/common/parse-util.c
index 9830f45379..bfc58ba5dc 100644
--- a/binchihua/src/common/parse-util.c
+++ b/binchihua/src/common/parse-util.c
@@ -1,10 +1,11 @@
-#include "parse-util.h"
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include "parse-util.h"
+
 bool parse_long(const char *in, long *ret) {
         const int base = 10;
         char *x = NULL;
diff --git a/binchihua/src/common/parse-util.h b/binchihua/src/common/parse-util.h
index b0c8293a73..5401995212 100644
--- a/binchihua/src/common/parse-util.h
+++ b/binchihua/src/common/parse-util.h
@@ -1,10 +1,7 @@
-#ifndef _BLUE_CHIHUAHUA_ORCH_PARSEUTIL
-#define _BLUE_CHIHUAHUA_ORCH_PARSEUTIL
+#pragma once
 
 #include <inttypes.h>
 #include <stdbool.h>
 
 bool parse_long(const char *in, long *ret);
 bool parse_port(const char *in, uint16_t *ret);
-
-#endif
diff --git a/binchihua/src/common/strings.h b/binchihua/src/common/strings.h
index 72af6b1d55..97e723467b 100644
--- a/binchihua/src/common/strings.h
+++ b/binchihua/src/common/strings.h
@@ -1,9 +1,6 @@
-#ifndef _BLUE_CHIHUAHUA_ORCH_STRINGS
-#define _BLUE_CHIHUAHUA_ORCH_STRINGS
+#pragma once
 
 #include <string.h>
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
 #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
-
-#endif
\ No newline at end of file
diff --git a/binchihua/src/ini/config.c b/binchihua/src/ini/config.c
index 43b57e8a74..f9d2899629 100644
--- a/binchihua/src/ini/config.c
+++ b/binchihua/src/ini/config.c
@@ -1,8 +1,8 @@
+#include <assert.h>
 #include <stdlib.h>
 
 #include "../../../libchihua-msg/include/common/common.h"
 #include "../common/strings.h"
-#include "assert.h"
 #include "config.h"
 #include "ini.h"
 
diff --git a/binchihua/src/ini/config.h b/binchihua/src/ini/config.h
index e65c6e0429..59a623e256 100644
--- a/binchihua/src/ini/config.h
+++ b/binchihua/src/ini/config.h
@@ -1,3 +1,5 @@
+#pragma once
+
 #include "../common/hashmap/hashmap.h"
 
 typedef struct {
diff --git a/binchihua/src/ini/ini.h b/binchihua/src/ini/ini.h
index 93ab06c79c..9fac438ed4 100644
--- a/binchihua/src/ini/ini.h
+++ b/binchihua/src/ini/ini.h
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 
-#ifndef INI_H
-#define INI_H
+#pragma once
 
 /* Make this header file easier to include in C++ code */
 #ifdef __cplusplus
@@ -157,5 +156,3 @@ INI_API int ini_parse_string(const char *string, ini_handler handler, void *user
 #ifdef __cplusplus
 }
 #endif
-
-#endif /* INI_H */
\ No newline at end of file
diff --git a/binchihua/src/node/node.c b/binchihua/src/node/node.c
index d66d776902..5fd8c3bf14 100644
--- a/binchihua/src/node/node.c
+++ b/binchihua/src/node/node.c
@@ -1,10 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "../../../libchihua-msg/include/node.h"
 #include "../ini/config.h"
 #include "opt.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 int main(int argc, char *argv[]) {
         fprintf(stdout, "Hello from node!\n");
diff --git a/binchihua/src/node/opt.c b/binchihua/src/node/opt.c
index a5fa055417..21048fba37 100644
--- a/binchihua/src/node/opt.c
+++ b/binchihua/src/node/opt.c
@@ -1,12 +1,12 @@
-#include "opt.h"
-#include "../common/opt.h"
-#include "../common/parse-util.h"
-
 #include <arpa/inet.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../common/opt.h"
+#include "../common/parse-util.h"
+#include "opt.h"
+
 const struct option options[] = { { ARG_HOST, required_argument, 0, ARG_HOST_SHORT },
                                   { ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
                                   { NULL, 0, 0, '\0' } };
diff --git a/binchihua/src/node/opt.h b/binchihua/src/node/opt.h
index a09898a9bd..ec1005cedd 100644
--- a/binchihua/src/node/opt.h
+++ b/binchihua/src/node/opt.h
@@ -1,8 +1,5 @@
-#ifndef _BLUE_CHIHUAHUA_NODE_OPTIONS
-#define _BLUE_CHIHUAHUA_NODE_OPTIONS
+#pragma once
 
 #include <netinet/in.h>
 
 void get_opts(int argc, char *argv[], struct sockaddr_in *orch_addr);
-
-#endif
\ No newline at end of file
diff --git a/binchihua/src/orch/opt.c b/binchihua/src/orch/opt.c
index a24efdd028..862291d525 100644
--- a/binchihua/src/orch/opt.c
+++ b/binchihua/src/orch/opt.c
@@ -1,11 +1,11 @@
-#include "opt.h"
-#include "../common/opt.h"
-#include "../common/parse-util.h"
-
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../common/opt.h"
+#include "../common/parse-util.h"
+#include "opt.h"
+
 const struct option options[] = { { ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
                                   { ARG_CONFIG, required_argument, 0, ARG_CONFIG_SHORT },
                                   { NULL, 0, 0, '\0' } };
diff --git a/binchihua/src/orch/opt.h b/binchihua/src/orch/opt.h
index c93a4969ba..77c43967a3 100644
--- a/binchihua/src/orch/opt.h
+++ b/binchihua/src/orch/opt.h
@@ -1,8 +1,5 @@
-#ifndef _BLUE_CHIHUAHUA_ORCH_OPTIONS
-#define _BLUE_CHIHUAHUA_ORCH_OPTIONS
+#pragma once
 
 #include <inttypes.h>
 
 void get_opts(int argc, char *argv[], uint16_t *ctrl_port, char **config_path);
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/include/common/memory.h b/libchihua-msg/include/common/memory.h
index f77ce7893f..7b5e3f428d 100644
--- a/libchihua-msg/include/common/memory.h
+++ b/libchihua-msg/include/common/memory.h
@@ -1,6 +1,3 @@
-#ifndef _BLUE_CHIHUAHUA_LIB_COMMON_MEMORY
-#define _BLUE_CHIHUAHUA_LIB_COMMON_MEMORY
+#pragma once
 
 #define _cleanup_(x) __attribute__((__cleanup__(x)))
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/include/node.h b/libchihua-msg/include/node.h
index 6630a4342f..2cbf6f595d 100644
--- a/libchihua-msg/include/node.h
+++ b/libchihua-msg/include/node.h
@@ -1,13 +1,12 @@
-#ifndef _BLUE_CHIHUAHUA_LIB_NODE
-#define _BLUE_CHIHUAHUA_LIB_NODE
-
-#include "./common/memory.h"
+#pragma once
 
 #include <netinet/in.h>
 #include <stdbool.h>
 #include <sys/socket.h>
 #include <systemd/sd-event.h>
 
+#include "./common/memory.h"
+
 typedef struct {
         struct sockaddr_in *orch_addr;
 } NodeParams;
@@ -24,5 +23,3 @@ bool node_start(const Node *node);
 bool node_stop(const Node *node);
 
 #define _cleanup_node_ _cleanup_(node_unrefp)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/include/node/peer-dbus.h b/libchihua-msg/include/node/peer-dbus.h
index ddb052d84d..b33f9e1546 100644
--- a/libchihua-msg/include/node/peer-dbus.h
+++ b/libchihua-msg/include/node/peer-dbus.h
@@ -1,7 +1,4 @@
-#ifndef _BLUE_CHIHUAHUA_LIB_NODE_PEER_DBUS
-#define _BLUE_CHIHUAHUA_LIB_NODE_PEER_DBUS
-
-#include "../common/memory.h"
+#pragma once
 
 #include <netinet/in.h>
 #include <stdbool.h>
@@ -9,6 +6,8 @@
 #include <systemd/sd-bus.h>
 #include <systemd/sd-event.h>
 
+#include "../common/memory.h"
+
 typedef struct {
         char *peer_dbus_addr;
         sd_bus *internal_dbus;
@@ -22,5 +21,3 @@ void peer_dbus_unrefp(PeerDBus **dbus);
 bool peer_dbus_start(PeerDBus *dbus);
 
 #define _cleanup_peer_dbus_ _cleanup_(peer_dbus_unrefp)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/include/orchestrator.h b/libchihua-msg/include/orchestrator.h
index a3a7013f63..5df0af6709 100644
--- a/libchihua-msg/include/orchestrator.h
+++ b/libchihua-msg/include/orchestrator.h
@@ -1,12 +1,11 @@
-#ifndef _BLUE_CHIHUAHUA_LIB_ORCHESTRATOR
-#define _BLUE_CHIHUAHUA_LIB_ORCHESTRATOR
-
-#include "./common/memory.h"
+#pragma once
 
 #include <inttypes.h>
 #include <stdbool.h>
 #include <systemd/sd-event.h>
 
+#include "./common/memory.h"
+
 typedef struct {
         uint16_t port;
 } OrchestratorParams;
@@ -23,5 +22,3 @@ bool orch_start(const Orchestrator *orchestrator);
 bool orch_stop(const Orchestrator *orchestrator);
 
 #define _cleanup_orchestrator_ _cleanup_(orch_unrefp)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/include/orchestrator/controller.h b/libchihua-msg/include/orchestrator/controller.h
index f65f066f38..90b9a14fa0 100644
--- a/libchihua-msg/include/orchestrator/controller.h
+++ b/libchihua-msg/include/orchestrator/controller.h
@@ -1,12 +1,9 @@
-#ifndef _BLUE_CHIHUAHUA_LIB_ORCHESTRATOR_CONTROLLER
-#define _BLUE_CHIHUAHUA_LIB_ORCHESTRATOR_CONTROLLER
-
-#include "../common/memory.h"
+#pragma once
 
 #include <stdbool.h>
 #include <systemd/sd-event.h>
 
-// TODO: include common/dbus and cleanup event_source in _new
+#include "../common/memory.h"
 
 typedef struct {
         int accept_fd;
@@ -19,5 +16,3 @@ void controller_unrefp(Controller **controller);
 sd_event_io_handler_t default_accept_handler();
 
 #define _cleanup_controller_ _cleanup_(controller_unrefp)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/src/common/dbus.h b/libchihua-msg/src/common/dbus.h
index 749be079fa..2104c89511 100644
--- a/libchihua-msg/src/common/dbus.h
+++ b/libchihua-msg/src/common/dbus.h
@@ -1,15 +1,12 @@
-#ifndef _BLUE_CHIHUAHUA_COMMON_DBUS
-#define _BLUE_CHIHUAHUA_COMMON_DBUS
-
-#include "memory.h"
+#pragma once
 
 #include <systemd/sd-bus.h>
 #include <systemd/sd-event.h>
 
+#include "memory.h"
+
 #define _cleanup_sd_event_ _cleanup_(sd_event_unrefp)
 #define _cleanup_sd_event_source_ _cleanup_(sd_event_source_unrefp)
 #define _cleanup_sd_bus_ _cleanup_(sd_bus_unrefp)
 #define _cleanup_sd_bus_slot_ _cleanup_(sd_bus_slot_unrefp)
 #define _cleanup_sd_bus_message_ _cleanup_(sd_bus_message_unrefp)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/src/common/memory.h b/libchihua-msg/src/common/memory.h
index 4b1eb99d12..1f3289424b 100644
--- a/libchihua-msg/src/common/memory.h
+++ b/libchihua-msg/src/common/memory.h
@@ -1,11 +1,10 @@
-#ifndef _BLUE_CHIHUAHUA_COMMON_MEMORY
-#define _BLUE_CHIHUAHUA_COMMON_MEMORY
-
-#include "../../include/common/memory.h"
+#pragma once
 
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "../../include/common/memory.h"
+
 static inline void *steal_pointer(void *ptr) {
         void **ptrp = (void **) ptr;
         void *p = *ptrp;
@@ -27,5 +26,3 @@ static inline void freep(void *p) {
 
 #define _cleanup_free_ _cleanup_(freep)
 #define _cleanup_fd_ _cleanup_(closep)
-
-#endif
\ No newline at end of file
diff --git a/libchihua-msg/src/node.c b/libchihua-msg/src/node.c
index 47d0f66ba8..07b3d1439f 100644
--- a/libchihua-msg/src/node.c
+++ b/libchihua-msg/src/node.c
@@ -1,9 +1,9 @@
+#include <stdio.h>
+
 #include "../include/node.h"
 #include "../include/node/peer-dbus.h"
 #include "./common/dbus.h"
 
-#include <stdio.h>
-
 Node *node_new(const NodeParams *params) {
         fprintf(stdout, "Creating Node...\n");
 
diff --git a/libchihua-msg/src/node/peer-dbus.c b/libchihua-msg/src/node/peer-dbus.c
index 17b8625e41..5b350040ae 100644
--- a/libchihua-msg/src/node/peer-dbus.c
+++ b/libchihua-msg/src/node/peer-dbus.c
@@ -1,9 +1,9 @@
-#include "../../include/node/peer-dbus.h"
-#include "../common/dbus.h"
-
 #include <arpa/inet.h>
 #include <stdio.h>
 
+#include "../../include/node/peer-dbus.h"
+#include "../common/dbus.h"
+
 char *assemble_address(const struct sockaddr_in *addr) {
         if (addr == NULL) {
                 fprintf(stderr, "Can not assemble an empty address\n");
diff --git a/libchihua-msg/src/orchestrator.c b/libchihua-msg/src/orchestrator.c
index 4a2ffd4cf5..b234b2a2af 100644
--- a/libchihua-msg/src/orchestrator.c
+++ b/libchihua-msg/src/orchestrator.c
@@ -1,10 +1,10 @@
+#include <stdio.h>
+#include <string.h>
+
 #include "../include/orchestrator.h"
 #include "../include/orchestrator/controller.h"
 #include "./common/dbus.h"
 
-#include <stdio.h>
-#include <string.h>
-
 Orchestrator *orch_new(const OrchestratorParams *params) {
         fprintf(stdout, "Creating Orchestrator...\n");
 
diff --git a/libchihua-msg/src/orchestrator/controller.c b/libchihua-msg/src/orchestrator/controller.c
index d0a3ca7fe3..035cc1aad6 100644
--- a/libchihua-msg/src/orchestrator/controller.c
+++ b/libchihua-msg/src/orchestrator/controller.c
@@ -1,13 +1,13 @@
+#include "../../include/orchestrator/controller.h"
+#include "../../include/common/common.h"
+#include "../common/dbus.h"
+
 #include <errno.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/socket.h>
 
-#include "../../include/common/common.h"
-#include "../../include/orchestrator/controller.h"
-#include "../common/dbus.h"
-
 static int create_master_socket(uint16_t port) {
         struct sockaddr_in servaddr;
 


Test patch:
diff --git a/binchihua/test/common/list_test.c b/binchihua/test/common/list_test.c
index 97589c2d1e..06c19c9852 100644
--- a/binchihua/test/common/list_test.c
+++ b/binchihua/test/common/list_test.c
@@ -1,6 +1,7 @@
-#include "../../src/common/list.h"
 #include <stdio.h>
 
+#include "../../src/common/list.h"
+
 #define VOID_0 ((void) 0)
 
 #define ELEMENTSOF(x)                                                            \
diff --git a/binchihua/test/common/parse-util_test.c b/binchihua/test/common/parse-util_test.c
index 10fa456064..acbd067a94 100644
--- a/binchihua/test/common/parse-util_test.c
+++ b/binchihua/test/common/parse-util_test.c
@@ -1,10 +1,11 @@
-#include "../../src/common/parse-util.h"
-
 #include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../../src/common/parse-util.h"
+
+
 #ifndef __FUNCTION_NAME__
 #        define __FUNCTION_NAME__ __func__
 #endif