Skip to content

Commit df42a28

Browse files
committed
fix compiler errors about non-trivial designated initializers with GCC 7
1 parent e2a89df commit df42a28

6 files changed

Lines changed: 67 additions & 56 deletions

File tree

common

include/villas/node.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct node_direction {
6666
struct node
6767
{
6868
char *name; /**< A short identifier of the node, only used for configuration and logging */
69+
70+
enum state state;
71+
6972
char *_name; /**< Singleton: A string used to print to screen. */
7073
char *_name_long; /**< Singleton: A string used to print to screen. */
7174

@@ -79,8 +82,6 @@ struct node
7982

8083
struct vlist signals; /**< Signal meta data for data which is __received__ by node_read(). */
8184

82-
enum state state;
83-
8485
#ifdef __linux__
8586
int mark; /**< Socket mark for netem, routing and filtering */
8687

include/villas/queue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ struct queue_cell {
5757

5858
/** A lock-free multiple-producer, multiple-consumer (MPMC) queue. */
5959
struct queue {
60-
cacheline_pad_t _pad0; /**< Shared area: all threads read */
61-
6260
atomic_state state;
6361

62+
cacheline_pad_t _pad0; /**< Shared area: all threads read */
63+
6464
size_t buffer_mask;
6565
off_t buffer_off; /**< Relative pointer to struct queue_cell[] */
6666

lib/web.cpp

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,54 +69,64 @@ lws_protocols protocols[] = {
6969
.rx_buffer_size = 0
7070
},
7171
#endif /* LIBWEBSOCKETS_FOUND */
72-
{ nullptr /* terminator */ }
72+
{
73+
.name = nullptr /* terminator */
74+
}
7375
};
7476

7577
/** List of libwebsockets mounts. */
7678
static lws_http_mount mounts[] = {
7779
#ifdef WITH_API
7880
{
79-
.mount_next = &mounts[1],
80-
.mountpoint = "/api/v1",
81-
.origin = "http-api",
82-
.def = nullptr,
83-
.cgienv = nullptr,
84-
.cgi_timeout = 0,
85-
.cache_max_age = 0,
86-
.cache_reusable = 0,
87-
.cache_revalidate = 0,
88-
.cache_intermediaries = 0,
89-
.origin_protocol = LWSMPRO_CALLBACK,
90-
.mountpoint_len = 7
81+
.mount_next = &mounts[1], /* linked-list "next" */
82+
.mountpoint = "/api/v1", /* mountpoint URL */
83+
.origin = "http-api", /* protocol */
84+
.def = nullptr,
85+
.protocol = "http-api",
86+
.cgienv = nullptr,
87+
.extra_mimetypes = nullptr,
88+
.interpret = nullptr,
89+
.cgi_timeout = 0,
90+
.cache_max_age = 0,
91+
.auth_mask = 0,
92+
.cache_reusable = 0,
93+
.cache_revalidate = 0,
94+
.cache_intermediaries = 0,
95+
.origin_protocol = LWSMPRO_CALLBACK, /* dynamic */
96+
.mountpoint_len = 7 /* char count */
9197
},
9298
#endif /* WITH_API */
9399
{
94-
.mount_next = nullptr,
95-
.mountpoint = "/",
96-
.origin = nullptr,
97-
.def = "/index.html",
98-
.cgienv = nullptr,
99-
.cgi_timeout = 0,
100-
.cache_max_age = 0,
101-
.cache_reusable = 0,
102-
.cache_revalidate = 0,
100+
.mount_next = nullptr,
101+
.mountpoint = "/",
102+
.origin = nullptr,
103+
.def = "/index.html",
104+
.protocol = nullptr,
105+
.cgienv = nullptr,
106+
.extra_mimetypes = nullptr,
107+
.interpret = nullptr,
108+
.cgi_timeout = 0,
109+
.cache_max_age = 0,
110+
.auth_mask = 0,
111+
.cache_reusable = 0,
112+
.cache_revalidate = 0,
103113
.cache_intermediaries = 0,
104-
.origin_protocol = LWSMPRO_FILE,
105-
.mountpoint_len = 1
114+
.origin_protocol = LWSMPRO_FILE,
115+
.mountpoint_len = 1
106116
}
107117
};
108118

109119
/** List of libwebsockets extensions. */
110120
static const lws_extension extensions[] = {
111121
{
112-
"permessage-deflate",
113-
lws_extension_callback_pm_deflate,
114-
"permessage-deflate"
122+
.name = "permessage-deflate",
123+
.callback = lws_extension_callback_pm_deflate,
124+
.client_offer = "permessage-deflate"
115125
},
116126
{
117-
"deflate-frame",
118-
lws_extension_callback_pm_deflate,
119-
"deflate_frame"
127+
.name = "deflate-frame",
128+
.callback = lws_extension_callback_pm_deflate,
129+
.client_offer = "deflate_frame"
120130
},
121131
{ nullptr /* terminator */ }
122132
};
@@ -227,22 +237,22 @@ int Web::parse(json_t *cfg)
227237
void Web::start()
228238
{
229239
/* Start server */
230-
lws_context_creation_info ctx_info = {
231-
.port = port,
232-
.protocols = protocols,
233-
.extensions = extensions,
234-
.ssl_cert_filepath = ssl_cert.empty() ? nullptr : ssl_cert.c_str(),
235-
.ssl_private_key_filepath = ssl_private_key.empty() ? nullptr : ssl_private_key.c_str(),
236-
.gid = -1,
237-
.uid = -1,
238-
.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
239-
.user = (void *) this,
240+
lws_context_creation_info ctx_info;
241+
242+
ctx_info.port = port;
243+
ctx_info.protocols = protocols;
244+
ctx_info.extensions = extensions;
245+
ctx_info.ssl_cert_filepath = ssl_cert.empty() ? nullptr : ssl_cert.c_str();
246+
ctx_info.ssl_private_key_filepath = ssl_private_key.empty() ? nullptr : ssl_private_key.c_str();
247+
ctx_info.gid = -1;
248+
ctx_info.uid = -1;
249+
ctx_info.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS | LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
250+
ctx_info.user = (void *) this;
240251
#if LWS_LIBRARY_VERSION_NUMBER <= 3000000
241-
// https://github.com/warmcat/libwebsockets/issues/1249
242-
.max_http_header_pool = 1024,
252+
// https://github.com/warmcat/libwebsockets/issues/1249
253+
ctx_info.max_http_header_pool = 1024;
243254
#endif
244-
.mounts = mounts
245-
};
255+
ctx_info.mounts = mounts;
246256

247257
logger->info("Starting sub-system: htdocs={}", htdocs.c_str());
248258

@@ -262,7 +272,7 @@ void Web::start()
262272
logger->warn("WebSocket: failed to setup vhost. Trying another port: {}", ctx_info.port);
263273
}
264274

265-
if (vhost == NULL)
275+
if (vhost == nullptr)
266276
throw RuntimeError("Failed to initialize virtual host");
267277

268278
/* Start thread */

src/villas-signal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
172172

173173
const char *format = "villas.human"; /** @todo hardcoded for now */
174174

175-
struct node n = { .state = STATE_DESTROYED };
175+
struct node n = { .name = nullptr, .state = STATE_DESTROYED };
176176
struct io io = { .state = STATE_DESTROYED };
177177
struct pool q = { .state = STATE_DESTROYED };
178178
struct sample *t;

tests/unit/queue.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ void * producer_consumer_many(void *ctx)
245245
Test(queue, single_threaded, .init = init_memory)
246246
{
247247
int ret;
248-
struct param p = {
249-
.iter_count = 1 << 8,
250-
.queue_size = 1 << 10,
251-
.start = 1 /* we start immeadiatly */
252-
};
248+
struct param p;
249+
250+
p.iter_count = 1 << 8;
251+
p.queue_size = 1 << 10;
252+
p.start = 1; /* we start immeadiatly */
253253

254254
ret = queue_init(&p.queue, p.queue_size, &memory_heap);
255255
cr_assert_eq(ret, 0, "Failed to create queue");

0 commit comments

Comments
 (0)