From df42a2880c201ca742626993f7060a6c74122069 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 21 Jan 2019 17:11:11 +0100 Subject: [PATCH] fix compiler errors about non-trivial designated initializers with GCC 7 --- common | 2 +- include/villas/node.h | 5 ++- include/villas/queue.h | 4 +- lib/web.cpp | 100 ++++++++++++++++++++++------------------- src/villas-signal.cpp | 2 +- tests/unit/queue.cpp | 10 ++--- 6 files changed, 67 insertions(+), 56 deletions(-) diff --git a/common b/common index 3e3c507e5..41adb5c00 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 3e3c507e5c987bd4e1212c9ebd7c713600cb3587 +Subproject commit 41adb5c005517c1d8cda7f90e2ea5c13fa49df0c diff --git a/include/villas/node.h b/include/villas/node.h index 57492c34b..94e59d9de 100644 --- a/include/villas/node.h +++ b/include/villas/node.h @@ -66,6 +66,9 @@ struct node_direction { struct node { char *name; /**< A short identifier of the node, only used for configuration and logging */ + + enum state state; + char *_name; /**< Singleton: A string used to print to screen. */ char *_name_long; /**< Singleton: A string used to print to screen. */ @@ -79,8 +82,6 @@ struct node struct vlist signals; /**< Signal meta data for data which is __received__ by node_read(). */ - enum state state; - #ifdef __linux__ int mark; /**< Socket mark for netem, routing and filtering */ diff --git a/include/villas/queue.h b/include/villas/queue.h index a3b7814df..7cfe5a5a6 100644 --- a/include/villas/queue.h +++ b/include/villas/queue.h @@ -57,10 +57,10 @@ struct queue_cell { /** A lock-free multiple-producer, multiple-consumer (MPMC) queue. */ struct queue { - cacheline_pad_t _pad0; /**< Shared area: all threads read */ - atomic_state state; + cacheline_pad_t _pad0; /**< Shared area: all threads read */ + size_t buffer_mask; off_t buffer_off; /**< Relative pointer to struct queue_cell[] */ diff --git a/lib/web.cpp b/lib/web.cpp index 6f1b10398..8b38618f7 100644 --- a/lib/web.cpp +++ b/lib/web.cpp @@ -69,54 +69,64 @@ lws_protocols protocols[] = { .rx_buffer_size = 0 }, #endif /* LIBWEBSOCKETS_FOUND */ - { nullptr /* terminator */ } + { + .name = nullptr /* terminator */ + } }; /** List of libwebsockets mounts. */ static lws_http_mount mounts[] = { #ifdef WITH_API { - .mount_next = &mounts[1], - .mountpoint = "/api/v1", - .origin = "http-api", - .def = nullptr, - .cgienv = nullptr, - .cgi_timeout = 0, - .cache_max_age = 0, - .cache_reusable = 0, - .cache_revalidate = 0, - .cache_intermediaries = 0, - .origin_protocol = LWSMPRO_CALLBACK, - .mountpoint_len = 7 + .mount_next = &mounts[1], /* linked-list "next" */ + .mountpoint = "/api/v1", /* mountpoint URL */ + .origin = "http-api", /* protocol */ + .def = nullptr, + .protocol = "http-api", + .cgienv = nullptr, + .extra_mimetypes = nullptr, + .interpret = nullptr, + .cgi_timeout = 0, + .cache_max_age = 0, + .auth_mask = 0, + .cache_reusable = 0, + .cache_revalidate = 0, + .cache_intermediaries = 0, + .origin_protocol = LWSMPRO_CALLBACK, /* dynamic */ + .mountpoint_len = 7 /* char count */ }, #endif /* WITH_API */ { - .mount_next = nullptr, - .mountpoint = "/", - .origin = nullptr, - .def = "/index.html", - .cgienv = nullptr, - .cgi_timeout = 0, - .cache_max_age = 0, - .cache_reusable = 0, - .cache_revalidate = 0, + .mount_next = nullptr, + .mountpoint = "/", + .origin = nullptr, + .def = "/index.html", + .protocol = nullptr, + .cgienv = nullptr, + .extra_mimetypes = nullptr, + .interpret = nullptr, + .cgi_timeout = 0, + .cache_max_age = 0, + .auth_mask = 0, + .cache_reusable = 0, + .cache_revalidate = 0, .cache_intermediaries = 0, - .origin_protocol = LWSMPRO_FILE, - .mountpoint_len = 1 + .origin_protocol = LWSMPRO_FILE, + .mountpoint_len = 1 } }; /** List of libwebsockets extensions. */ static const lws_extension extensions[] = { { - "permessage-deflate", - lws_extension_callback_pm_deflate, - "permessage-deflate" + .name = "permessage-deflate", + .callback = lws_extension_callback_pm_deflate, + .client_offer = "permessage-deflate" }, { - "deflate-frame", - lws_extension_callback_pm_deflate, - "deflate_frame" + .name = "deflate-frame", + .callback = lws_extension_callback_pm_deflate, + .client_offer = "deflate_frame" }, { nullptr /* terminator */ } }; @@ -227,22 +237,22 @@ int Web::parse(json_t *cfg) void Web::start() { /* Start server */ - lws_context_creation_info ctx_info = { - .port = port, - .protocols = protocols, - .extensions = extensions, - .ssl_cert_filepath = ssl_cert.empty() ? nullptr : ssl_cert.c_str(), - .ssl_private_key_filepath = ssl_private_key.empty() ? nullptr : ssl_private_key.c_str(), - .gid = -1, - .uid = -1, - .options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT, - .user = (void *) this, + lws_context_creation_info ctx_info; + + ctx_info.port = port; + ctx_info.protocols = protocols; + ctx_info.extensions = extensions; + ctx_info.ssl_cert_filepath = ssl_cert.empty() ? nullptr : ssl_cert.c_str(); + ctx_info.ssl_private_key_filepath = ssl_private_key.empty() ? nullptr : ssl_private_key.c_str(); + ctx_info.gid = -1; + ctx_info.uid = -1; + ctx_info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; + ctx_info.user = (void *) this; #if LWS_LIBRARY_VERSION_NUMBER <= 3000000 - // https://github.com/warmcat/libwebsockets/issues/1249 - .max_http_header_pool = 1024, + // https://github.com/warmcat/libwebsockets/issues/1249 + ctx_info.max_http_header_pool = 1024; #endif - .mounts = mounts - }; + ctx_info.mounts = mounts; logger->info("Starting sub-system: htdocs={}", htdocs.c_str()); @@ -262,7 +272,7 @@ void Web::start() logger->warn("WebSocket: failed to setup vhost. Trying another port: {}", ctx_info.port); } - if (vhost == NULL) + if (vhost == nullptr) throw RuntimeError("Failed to initialize virtual host"); /* Start thread */ diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index e64c53925..6a323c0e3 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) const char *format = "villas.human"; /** @todo hardcoded for now */ - struct node n = { .state = STATE_DESTROYED }; + struct node n = { .name = nullptr, .state = STATE_DESTROYED }; struct io io = { .state = STATE_DESTROYED }; struct pool q = { .state = STATE_DESTROYED }; struct sample *t; diff --git a/tests/unit/queue.cpp b/tests/unit/queue.cpp index ab867fee0..f72eca101 100644 --- a/tests/unit/queue.cpp +++ b/tests/unit/queue.cpp @@ -245,11 +245,11 @@ void * producer_consumer_many(void *ctx) Test(queue, single_threaded, .init = init_memory) { int ret; - struct param p = { - .iter_count = 1 << 8, - .queue_size = 1 << 10, - .start = 1 /* we start immeadiatly */ - }; + struct param p; + + p.iter_count = 1 << 8; + p.queue_size = 1 << 10; + p.start = 1; /* we start immeadiatly */ ret = queue_init(&p.queue, p.queue_size, &memory_heap); cr_assert_eq(ret, 0, "Failed to create queue");