Changeset: 9946c70cb04d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9946c70cb04d
Modified Files:
clients/mapilib/connect.c
common/stream/socket_stream.c
gdk/gdk_time.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/generator/generator.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_rank.c
sql/server/rel_optimizer.c
tools/merovingian/daemon/client.c
tools/merovingian/daemon/connections.c
tools/merovingian/daemon/controlrunner.c
Branch: Mar2025
Log Message:
Simplify struct initializations.
diffs (truncated from 311 to 300 lines):
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -244,7 +244,7 @@ connect_socket_tcp(Mapi mid)
mapi_log_record(mid, "CONN", "Connecting to %s:%d", host, port);
- struct addrinfo hints = (struct addrinfo) {
+ struct addrinfo hints = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
.ai_protocol = IPPROTO_TCP,
diff --git a/common/stream/socket_stream.c b/common/stream/socket_stream.c
--- a/common/stream/socket_stream.c
+++ b/common/stream/socket_stream.c
@@ -31,14 +31,14 @@ socket_getoob(const stream *s)
{
SOCKET fd = s->stream_data.s;
#ifdef HAVE_POLL
- struct pollfd pfd = (struct pollfd) {
+ struct pollfd pfd = {
.fd = fd,
.events = POLLPRI,
};
if (poll(&pfd, 1, 0) > 0)
#else
fd_set xfds;
- struct timeval t = (struct timeval) {
+ struct timeval t = {
.tv_sec = 0,
.tv_usec = 0,
};
@@ -129,14 +129,14 @@ socket_getoob_unix(const stream *s)
{
SOCKET fd = s->stream_data.s;
#ifdef HAVE_POLL
- struct pollfd pfd = (struct pollfd) {
+ struct pollfd pfd = {
.fd = fd,
.events = POLLIN,
};
if (poll(&pfd, 1, 0) > 0)
#else
fd_set fds;
- struct timeval t = (struct timeval) {
+ struct timeval t = {
.tv_sec = 0,
.tv_usec = 0,
};
@@ -286,10 +286,10 @@ socket_read(stream *restrict s, void *re
if (s->timeout) {
int ret;
#ifdef HAVE_POLL
- struct pollfd pfd;
-
- pfd = (struct pollfd) {.fd = s->stream_data.s,
- .events = POLLIN};
+ struct pollfd pfd = {
+ .fd = s->stream_data.s,
+ .events = POLLIN
+ };
#ifdef HAVE_SYS_UN_H
if (s->putoob != socket_putoob_unix)
pfd.events |= POLLPRI;
@@ -530,9 +530,8 @@ socket_isalive(const stream *s)
{
SOCKET fd = s->stream_data.s;
#ifdef HAVE_POLL
- struct pollfd pfd;
+ struct pollfd pfd = {.fd = fd};
int ret;
- pfd = (struct pollfd){.fd = fd};
if ((ret = poll(&pfd, 1, 0)) == 0)
return 1;
if (ret == -1 && errno == EINTR)
diff --git a/gdk/gdk_time.c b/gdk/gdk_time.c
--- a/gdk/gdk_time.c
+++ b/gdk/gdk_time.c
@@ -363,7 +363,7 @@ daytime_add_usec_modulo(daytime t, lng u
timestamp
timestamp_fromtime(time_t timeval)
{
- struct tm tm = (struct tm) {0};
+ struct tm tm = {0};
date d;
daytime t;
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -483,7 +483,7 @@ BATXMLoptions(bat *ret, const char *cons
str buf = GDKmalloc(BUFSIZ);
str val = GDKmalloc(BUFSIZ);
size_t size = BUFSIZ, len = strlen(*name);
- BATiter bi = (BATiter) {.b = NULL };
+ BATiter bi = {.b = NULL };
const char *err = OPERATION_FAILED " During bulk options analysis";
if (val == NULL || buf == NULL) {
@@ -1241,7 +1241,7 @@ static const char *
BATxmlaggr(BAT **bnp, BAT *b, BAT *g, BAT *e, BAT *s, int skip_nils)
{
BAT *bn = NULL, *t1, *t2 = NULL;
- BATiter bi = (BATiter) {.b = NULL };
+ BATiter bi = {.b = NULL };
oid min, max;
BUN ngrp;
BUN nils = 0;
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -1073,7 +1073,7 @@ local_timezone(int *isdstp)
}
#elif defined(HAVE_TM_GMTOFF)
time_t t;
- struct tm tm = (struct tm) { 0 };
+ struct tm tm = { 0 };
if ((t = time(NULL)) != (time_t) - 1 && localtime_r(&t, &tm)) {
tzone = (int) tm.tm_gmtoff;
@@ -1081,7 +1081,7 @@ local_timezone(int *isdstp)
}
#else
time_t t;
- struct tm tm = (struct tm) { 0 };
+ struct tm tm = { 0 };
if ((t = time(NULL)) != (time_t) - 1 && gmtime_r(&t, &tm)) {
timestamp lt, gt;
@@ -1170,7 +1170,7 @@ static str
str_to_timestamp(timestamp *ret, const char *const *s, const char *const
*format, const long gmtoff, const char *type,
const char *malfunc)
{
- struct tm tm = (struct tm) {
+ struct tm tm = {
.tm_isdst = -1,
.tm_mday = 1,
#ifdef HAVE_TM_GMTOFF
diff --git a/monetdb5/modules/kernel/batmmath.c
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -130,8 +130,8 @@ CMDscienceBINARY(MalStkPtr stk, InstrPtr
bat bid;
BAT *bn, *b1 = NULL, *b2 = NULL, *s1 = NULL, *s2 = NULL;
int tp1, tp2;
- struct canditer ci1 = (struct canditer) { 0 },
- ci2 = (struct canditer) { 0 };
+ struct canditer ci1 = { 0 },
+ ci2 = { 0 };
oid x1, x2, off1, off2;
BUN i, ncand, nils = 0;
int e = 0, ex = 0;
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -82,7 +82,7 @@ CLTsetScenario(Client cntxt, MalBlkPtr m
static void
CLTtimeConvert(time_t l, char *s)
{
- struct tm localt = (struct tm) { 0 };
+ struct tm localt = { 0 };
(void) localtime_r(&l, &localt);
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -307,7 +307,7 @@ SERVERlistenThread(SOCKET *Sock)
}
}
/* Wait up to 0.1 seconds (0.01 if testing) */
- struct timeval tv = (struct timeval) {
+ struct timeval tv = {
.tv_usec = ATOMIC_GET(&GDKdebug) & TESTINGMASK ? 10000
: 100000,
};
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1080,7 +1080,7 @@ BATPCRElike_imp(Client cntxt, MalBlkPtr
BUN q = 0;
bit *restrict ret = NULL;
struct RE *mnre_simple = NULL;
- BATiter bi = (BATiter) { 0 }, pi;
+ BATiter bi = { 0 }, pi;
(void) cntxt;
if (input_is_a_bat) {
diff --git a/sql/backends/monet5/UDF/capi/capi.c
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -462,7 +462,7 @@ static str CUDFeval(Client cntxt, MalBlk
lng initial_output_count = -1;
- struct sigaction sa = (struct sigaction) {.sa_flags = 0}, oldsa, oldsb;
+ struct sigaction sa = {.sa_flags = 0}, oldsa, oldsb;
sigset_t signal_set;
#ifdef NDEBUG
diff --git a/sql/backends/monet5/generator/generator.c
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -472,7 +472,7 @@ VLTgenerator_subselect(Client cntxt, Mal
oid o1, o2;
BUN n = 0;
BAT *bn, *cand = NULL;
- struct canditer ci = (struct canditer) {.tpe = cand_dense};
+ struct canditer ci = {.tpe = cand_dense};
InstrPtr p;
int tpe;
@@ -892,7 +892,7 @@ str VLTgenerator_thetasubselect(Client c
int tpe;
bat cndid =0;
BAT *cand = 0, *bn = NULL;
- struct canditer ci = (struct canditer) {.tpe = cand_dense};
+ struct canditer ci = {.tpe = cand_dense};
BUN cap,j, c = 0;
oid o = 0;
InstrPtr p;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -896,7 +896,7 @@ sql_variables(Client cntxt, MalBlkPtr mb
sql_var *var = (sql_var*) n->data;
atom value = var->var;
ValPtr myptr = &(value.data);
- ValRecord val = (ValRecord) {.vtype = TYPE_void,};
+ ValRecord val = {.vtype = TYPE_void,};
gdk_return res;
if (value.tpe.type->localtype != TYPE_str) {
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -961,7 +961,7 @@ SQLlast_value(Client cntxt, MalBlkPtr mb
if (!VALisnil(nth) && val < 1)
\
throw(SQL, "sql.nth_value", SQLSTATE(42000) "nth_value
must be greater than zero"); \
if (VALisnil(nth) || val > 1) {
\
- ValRecord def = (ValRecord) {.vtype = TYPE_void,};
\
+ ValRecord def = {.vtype = TYPE_void,};
\
if (!VALinit(&def, tp1, ATOMnilptr(tp1)) ||
!VALcopy(res, &def)) { \
VALclear(&def);
\
throw(SQL, "sql.nth_value", SQLSTATE(HY013)
MAL_MALLOC_FAIL); \
@@ -1040,7 +1040,7 @@ SQLnth_value(Client cntxt, MalBlkPtr mb,
goto bailout;
}
if (is_lng_nil(nth) || nth > 1) {
- ValRecord def = (ValRecord) {.vtype = TYPE_void,};
+ ValRecord def = {.vtype = TYPE_void,};
if (!VALinit(&def, tpe, ATOMnilptr(tpe)) ||
!VALcopy(res, &def)) {
VALclear(&def);
msg = createException(SQL, "sql.nth_value",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1201,7 +1201,7 @@ do_lead_lag(Client cntxt, MalBlkPtr mb,
if (!VALcopy(res, in))
msg = createException(SQL, op, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
} else {
- ValRecord def = (ValRecord) {.vtype = TYPE_void,};
+ ValRecord def = {.vtype = TYPE_void,};
if (!VALinit(&def, tp1, default_value) || !VALcopy(res,
&def))
msg = createException(SQL, op, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -667,7 +667,7 @@ run_optimizer_set(visitor *v, sql_optimi
static sql_rel *
rel_optimizer_one(mvc *sql, sql_rel *rel, int profile, int instantiate, int
value_based_opt, int storage_based_opt)
{
- global_props gp = (global_props) {.cnt = {0}, .instantiate =
(uint8_t)instantiate, .opt_cycle = 0,
+ global_props gp = {.cnt = {0}, .instantiate = (uint8_t)instantiate,
.opt_cycle = 0,
.has_special_modify = rel && is_modify(rel->op) && rel->flag&UPD_COMP};
visitor v = { .sql = sql, .value_based_opt = value_based_opt,
.storage_based_opt = storage_based_opt, .changes = 1, .data = &gp };
diff --git a/tools/merovingian/daemon/client.c
b/tools/merovingian/daemon/client.c
--- a/tools/merovingian/daemon/client.c
+++ b/tools/merovingian/daemon/client.c
@@ -469,7 +469,7 @@ acceptConnections(int socks[3])
}
/* Wait up to 5 seconds */
- struct timeval tv = (struct timeval) {.tv_sec = 5};
+ struct timeval tv = {.tv_sec = 5};
retval = select(sock + 1, &fds, NULL, NULL, &tv);
sock = -1;
#endif
diff --git a/tools/merovingian/daemon/connections.c
b/tools/merovingian/daemon/connections.c
--- a/tools/merovingian/daemon/connections.c
+++ b/tools/merovingian/daemon/connections.c
@@ -41,7 +41,7 @@ openConnectionIP(int *socks, bool udp, c
const char *msghost = bindaddr ? bindaddr : "any"; /* for messages */
int ipv6_vs6only = -1;
- struct addrinfo hints = (struct addrinfo) {
+ struct addrinfo hints = {
.ai_family = AF_INET6,
.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM,
.ai_flags = AI_PASSIVE | AI_NUMERICSERV,
diff --git a/tools/merovingian/daemon/controlrunner.c
b/tools/merovingian/daemon/controlrunner.c
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]