diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 538b55703..a6d49d441 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,9 +23,9 @@ # All executables link against libvillas link_libraries(villas) -add_executable(villas-node villas-node.c) -add_executable(villas-test-rtt villas-test-rtt.c) -add_executable(villas-test-shmem villas-test-shmem.c) +add_executable(villas-node villas-node.cpp) +add_executable(villas-test-rtt villas-test-rtt.cpp) +add_executable(villas-test-shmem villas-test-shmem.cpp) install( TARGETS villas-node villas-test-rtt villas-test-shmem @@ -34,10 +34,10 @@ install( ) if(WITH_IO) - add_executable(villas-test-cmp villas-test-cmp.c) - add_executable(villas-convert villas-convert.c) - add_executable(villas-pipe villas-pipe.c) - add_executable(villas-signal villas-signal.c) + add_executable(villas-test-cmp villas-test-cmp.cpp) + add_executable(villas-convert villas-convert.cpp) + add_executable(villas-pipe villas-pipe.cpp) + add_executable(villas-signal villas-signal.cpp) target_link_libraries(villas-pipe PUBLIC Threads::Threads) @@ -49,7 +49,7 @@ if(WITH_IO) endif() if(WITH_IO AND WITH_HOOKS) - add_executable(villas-hook villas-hook.c) + add_executable(villas-hook villas-hook.cpp) install( TARGETS villas-hook diff --git a/src/villas-convert.c b/src/villas-convert.cpp similarity index 94% rename from src/villas-convert.c rename to src/villas-convert.cpp index b02852851..204326fe9 100644 --- a/src/villas-convert.c +++ b/src/villas-convert.cpp @@ -45,8 +45,8 @@ static void usage() int main(int argc, char *argv[]) { int ret, level = V; - char *input_format = "villas.human"; - char *output_format = "villas.human"; + const char *input_format = "villas.human"; + const char *output_format = "villas.human"; char c, *endptr; while ((c = getopt(argc, argv, "Vhd:i:o:")) != -1) { @@ -94,14 +94,14 @@ check: if (optarg == endptr) error("Failed to start log"); struct { - char *name; + const char *name; struct io *io; } dirs[] = { { input_format, &input }, { output_format, &output }, }; - for (int i = 0; i < ARRAY_LEN(dirs); i++) { + for (unsigned i = 0; i < ARRAY_LEN(dirs); i++) { fmt = format_type_lookup(dirs[i].name); if (!fmt) error("Invalid format: %s", dirs[i].name); @@ -127,7 +127,7 @@ check: if (optarg == endptr) io_print(&output, &smp, 1); } - for (int i = 0; i < ARRAY_LEN(dirs); i++) { + for (unsigned i = 0; i < ARRAY_LEN(dirs); i++) { ret = io_close(dirs[i].io); if (ret) error("Failed to close IO"); diff --git a/src/villas-hook.c b/src/villas-hook.cpp similarity index 98% rename from src/villas-hook.c rename to src/villas-hook.cpp index ecf31cf9f..e8e2226e8 100644 --- a/src/villas-hook.c +++ b/src/villas-hook.cpp @@ -111,7 +111,7 @@ static void usage() int main(int argc, char *argv[]) { int ret, recv, sent; - char *format = "villas.human"; + const char *format = "villas.human"; struct format_type *ft; struct hook_type *ht; @@ -180,7 +180,7 @@ check: if (optarg == endptr) if (ret) error("Failed to initialize memory"); - smps = alloc(cnt * sizeof(struct sample *)); + smps = (struct sample **) alloc(cnt * sizeof(struct sample *)); ret = pool_init(&q, 10 * cnt, SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage); if (ret) diff --git a/src/villas-node.c b/src/villas-node.cpp similarity index 99% rename from src/villas-node.c rename to src/villas-node.cpp index f5de8d1c5..22b9c553c 100644 --- a/src/villas-node.c +++ b/src/villas-node.cpp @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) opal_register_region(argc, argv); - char *uri = "opal-shmem.conf"; + const char *uri = "opal-shmem.conf"; #else char c; while ((c = getopt(argc, argv, "hV")) != -1) { diff --git a/src/villas-pipe.c b/src/villas-pipe.cpp similarity index 98% rename from src/villas-pipe.c rename to src/villas-pipe.cpp index 7b387645e..3eadd704f 100644 --- a/src/villas-pipe.c +++ b/src/villas-pipe.cpp @@ -232,12 +232,13 @@ int main(int argc, char *argv[]) { int ret, level = V, timeout = 0; bool reverse = false; - char *format = "villas.human"; + const char *format = "villas.human"; - sendd = recvv = (struct dir) { - .enabled = true, - .limit = -1 - }; + sendd.enabled = true; + sendd.limit = -1; + + recvv.enabled = true; + recvv.limit = -1; json_t *cfg_cli = json_object(); @@ -337,7 +338,7 @@ check: if (optarg == endptr) if (ret) error("Failed to open IO"); - node = list_lookup(&sn.nodes, nodestr); + node = (struct node *) list_lookup(&sn.nodes, nodestr); if (!node) error("Node '%s' does not exist!", nodestr); diff --git a/src/villas-signal.c b/src/villas-signal.cpp similarity index 98% rename from src/villas-signal.c rename to src/villas-signal.cpp index 324f12733..1a3d3011c 100644 --- a/src/villas-signal.c +++ b/src/villas-signal.cpp @@ -42,7 +42,6 @@ struct node n; struct log l; struct io io; struct pool q; - struct sample *t; void usage() @@ -111,7 +110,7 @@ int main(int argc, char *argv[]) struct node_type *nt; struct format_type *ft; - char *format = "villas.human"; /** @todo hardcoded for now */ + const char *format = "villas.human"; /** @todo hardcoded for now */ ret = log_init(&l, l.level, LOG_ALL); if (ret) diff --git a/src/villas-test-cmp.c b/src/villas-test-cmp.cpp similarity index 98% rename from src/villas-test-cmp.c rename to src/villas-test-cmp.cpp index 0c5bad66e..301010edf 100644 --- a/src/villas-test-cmp.c +++ b/src/villas-test-cmp.cpp @@ -35,7 +35,7 @@ struct side { char *path; - char *format; + const char *format; struct sample *sample; @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) /* Default values */ double epsilon = 1e-9; - char *format = "villas.human"; + const char *format = "villas.human"; int flags = SAMPLE_HAS_SEQUENCE | SAMPLE_HAS_VALUES | SAMPLE_HAS_ORIGIN; struct pool pool = { .state = STATE_DESTROYED }; diff --git a/src/villas-test-rtt.c b/src/villas-test-rtt.cpp similarity index 98% rename from src/villas-test-rtt.c rename to src/villas-test-rtt.cpp index 051be9ed9..0599136ed 100644 --- a/src/villas-test-rtt.c +++ b/src/villas-test-rtt.cpp @@ -131,7 +131,7 @@ check: if (optarg == endptr) rt_init(sn.priority, sn.affinity); memory_init(sn.hugepages); - node = list_lookup(&sn.nodes, nodestr); + node = (struct node *) list_lookup(&sn.nodes, nodestr); if (!node) error("There's no node with the name '%s'", nodestr); diff --git a/src/villas-test-shmem.c b/src/villas-test-shmem.cpp similarity index 98% rename from src/villas-test-shmem.c rename to src/villas-test-shmem.cpp index 4e1747dcd..f3e89c3fa 100644 --- a/src/villas-test-shmem.c +++ b/src/villas-test-shmem.cpp @@ -55,9 +55,9 @@ int main(int argc, char* argv[]) struct log log; int readcnt, writecnt, avail; struct shmem_conf conf = { - .queuelen = DEFAULT_SHMEM_QUEUELEN, - .samplelen = DEFAULT_SHMEM_SAMPLELEN, .polling = 0, + .queuelen = DEFAULT_SHMEM_QUEUELEN, + .samplelen = DEFAULT_SHMEM_SAMPLELEN }; log_init(&log, V, LOG_ALL);