Changeset: 8ced9a076045 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8ced9a076045
Modified Files:
clients/mapiclient/eventparser.c
clients/mapiclient/mnc.c
clients/mapiclient/stethoscope.c
clients/mapiclient/tachograph.c
clients/mapiclient/tomograph.c
clients/mapilib/mapi.c
clients/odbc/driver/ODBCConvert.c
clients/odbc/driver/ODBCDesc.c
common/utils/msabaoth.c
common/utils/mutils.c
gdk/gdk_align.c
gdk/gdk_atoms.c
gdk/gdk_bat.c
gdk/gdk_utils.c
monetdb5/mal/mal_instruction.c
monetdb5/modules/atoms/inet.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/mal/tablet.c
monetdb5/optimizer/opt_pushselect.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/vaults/bam/bam_wrapper.c
sql/server/rel_optimizer.c
sql/server/sql_atom.c
sql/server/sql_partition.c
sql/storage/store.c
tools/merovingian/daemon/connections.c
tools/merovingian/daemon/proxy.c
tools/merovingian/utils/control.c
Branch: default
Log Message:
Use compound literal for initialization.
diffs (truncated from 836 to 300 lines):
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -114,8 +114,9 @@ resetEventRecord(EventRecord *ev)
if( ev->numa) free(ev->numa);
if(ev->beauty) free(ev->beauty);
if(ev->prereq) free(ev->prereq);
- memset( (char*) ev, 0, sizeof(EventRecord));
- ev->eventnr = -1;
+ *ev = (EventRecord) {
+ .eventnr = -1,
+ };
clearArguments();
}
@@ -353,7 +354,7 @@ lineparser(char *row, EventRecord *ev)
return -3;
/* convert time to epoch in seconds*/
cc =c;
- memset(&stm, 0, sizeof(struct tm));
+ stm = (struct tm) {0};
#ifdef HAVE_STRPTIME
c = strptime(c + 1, "%H:%M:%S", &stm);
ev->clkticks = (((int64_t) stm.tm_hour * 60 + stm.tm_min) * 60 +
stm.tm_sec) * 1000000;
diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c
--- a/clients/mapiclient/mnc.c
+++ b/clients/mapiclient/mnc.c
@@ -155,10 +155,11 @@ main(int argc, char **argv)
snprintf(sport, sizeof(sport), "%d", port & 0xFFFF);
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
+ hints = (struct addrinfo) {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM,
+ .ai_protocol = IPPROTO_TCP,
+ };
ret = getaddrinfo(host, sport, &hints, &res);
if (ret) {
fprintf(stderr, "getaddrinfo failed: %s\n",
gai_strerror(ret));
@@ -194,10 +195,11 @@ main(int argc, char **argv)
fprintf(stderr, "gethostbyname failed: %s\n", errno ?
strerror(errno) : hstrerror(h_errno));
exit(1);
}
- memset(&server, 0, sizeof(server));
+ server = (struct sockaddr_in) {
+ .sin_family = hp->h_addrtype,
+ .sin_port = htons((unsigned short) port),
+ };
memcpy(&server.sin_addr, hp->h_addr_list[0], hp->h_length);
- server.sin_family = hp->h_addrtype;
- server.sin_port = htons((unsigned short) (port & 0xFFFF));
s = socket(server.sin_family, SOCK_STREAM
#ifdef SOCK_CLOEXEC
| SOCK_CLOEXEC
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -186,7 +186,7 @@ convertOldFormat(char *inputfile)
}
fprintf(trace,"[\n{");
len = 0;
- memset(&event, 0, sizeof(event));
+ event = (EventRecord) {0};
while (fgets(buf + len, (int) (bufsize - len), fdin) != NULL) {
while ((e = strchr(buf + len, '\n')) == NULL) {
/* rediculously long line */
diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -319,8 +319,7 @@ update(EventRecord *ev)
if(ev->fcn && strstr(ev->fcn,"querylog.define") ){
// extract a string argument from a known MAL signature
maxevents = malsize;
- events = (Event*) malloc(maxevents * sizeof(Event));
- memset((char*)events, 0, maxevents * sizeof(Event));
+ events = calloc(maxevents, sizeof(Event));
// use the truncated query text, beware that the \ is
already escaped in the call argument.
if(currentquery) {
if( prevquery &&
strcmp(currentquery,prevquery)){
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -1370,12 +1370,10 @@ update(char *line, EventRecord *ev)
int uid = 0,qid = 0;
if (topbox == maxbox || maxbox < topbox) {
-
if( box == 0){
- box = (Box*) malloc(MAXBOX * sizeof(Box));
- memset((char*) box, 0, sizeof(Box) * MAXBOX);
+ box = calloc(MAXBOX, sizeof(Box));
} else
- box = (Box*) realloc((void*)box, (maxbox + MAXBOX) *
sizeof(Box));
+ box = realloc(box, (maxbox + MAXBOX) * sizeof(Box));
if( box == NULL){
fprintf(stderr, "Out of space for trace, exceeds max
entries %d\n", maxbox);
fprintf(stderr, "Restart with a slower beat might help,
e.g. --beat=5000 or --beat=0\n");
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2323,8 +2323,9 @@ mapi_reconnect(Mapi mid)
#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
(void) fcntl(s, F_SETFD, FD_CLOEXEC);
#endif
- memset(&userver, 0, sizeof(struct sockaddr_un));
- userver.sun_family = AF_UNIX;
+ userver = (struct sockaddr_un) {
+ .sun_family = AF_UNIX,
+ };
strncpy(userver.sun_path, mid->hostname,
sizeof(userver.sun_path) - 1);
userver.sun_path[sizeof(userver.sun_path) - 1] = 0;
@@ -2376,10 +2377,11 @@ mapi_reconnect(Mapi mid)
mid->hostname = strdup("localhost");
snprintf(port, sizeof(port), "%d", mid->port & 0xFFFF);
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
+ hints = (struct addrinfo) {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM,
+ .ai_protocol = IPPROTO_TCP,
+ };
ret = getaddrinfo(mid->hostname, port, &hints, &res);
if (ret) {
snprintf(errbuf, sizeof(errbuf), "getaddrinfo failed:
%s", gai_strerror(ret));
@@ -2430,10 +2432,11 @@ mapi_reconnect(Mapi mid)
);
return mapi_setError(mid, errbuf, "mapi_reconnect",
MERROR);
}
- memset(&server, 0, sizeof(server));
+ server = (struct sockaddr_in) {
+ .sin_family = hp->h_addrtype,
+ .sin_port = htons((unsigned short) mid->port),
+ };
memcpy(&server.sin_addr, hp->h_addr_list[0], hp->h_length);
- server.sin_family = hp->h_addrtype;
- server.sin_port = htons((unsigned short) (mid->port & 0xFFFF));
s = socket(server.sin_family, SOCK_STREAM
#ifdef SOCK_CLOEXEC
| SOCK_CLOEXEC
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -232,7 +232,7 @@ parsedate(const char *data, DATE_STRUCT
{
int n;
- memset(dval, 0, sizeof(*dval));
+ *dval = (DATE_STRUCT) {0};
while (space(*data))
data++;
if (sscanf(data, "{d '%hd-%hu-%hu'}%n",
@@ -258,7 +258,7 @@ parsetime(const char *data, TIME_STRUCT
int n;
int braces;
- memset(tval, 0, sizeof(*tval));
+ *tval = (TIME_STRUCT) {0};
while (space(*data))
data++;
if (sscanf(data, "{t '%hu:%hu:%hu%n",
@@ -304,7 +304,7 @@ parsetimestamp(const char *data, TIMESTA
int n;
int braces;
- memset(tsval, 0, sizeof(*tsval));
+ *tsval = (TIMESTAMP_STRUCT) {0};
while (space(*data))
data++;
if (sscanf(data, "{TS '%hd-%hu-%hu %hu:%hu:%hu%n",
@@ -526,7 +526,7 @@ parsemonthintervalstring(char **svalp,
long val1 = -1, val2 = -1;
SQLLEN leadingprecision;
- memset(ival, 0, sizeof(*ival));
+ *ival = (SQL_INTERVAL_STRUCT) {0};
if (slen < 8 || strncasecmp(sval, "interval", 8) != 0)
return SQL_ERROR;
sval += 8;
@@ -684,7 +684,7 @@ parsesecondintervalstring(char **svalp,
unsigned v1, v2, v3, v4;
int n;
- memset(ival, 0, sizeof(*ival));
+ *ival = (SQL_INTERVAL_STRUCT) {0};
if (slen < 8 || strncasecmp(sval, "interval", 8) != 0)
return SQL_ERROR;
sval += 8;
@@ -2254,10 +2254,11 @@ ODBCFetch(ODBCStmt *stmt,
nval.scale--;
nval.precision--;
}
- memset(&nmval, 0, sizeof(nmval));
- nmval.precision = nval.precision;
- nmval.scale = nval.scale;
- nmval.sign = nval.sign;
+ nmval = (SQL_NUMERIC_STRUCT) {
+ .precision = nval.precision,
+ .scale = nval.scale,
+ .sign = nval.sign,
+ };
for (i = 0; i < SQL_MAX_NUMERIC_LEN; i++) {
nmval.val[i] = (SQLCHAR) (nval.val & 0xFF);
nval.val >>= 8;
@@ -2513,10 +2514,11 @@ ODBCFetch(ODBCStmt *stmt,
addStmtError(stmt, "07006", NULL, 0);
return SQL_ERROR;
}
- memset(&ivval, 0, sizeof(ivval));
- ivval.interval_sign = ival.interval_sign;
- ivval.intval.year_month.year = 0;
- ivval.intval.year_month.month = 0;
+ ivval = (SQL_INTERVAL_STRUCT) {
+ .interval_sign = ival.interval_sign,
+ .intval.year_month.year = 0,
+ .intval.year_month.month = 0,
+ };
switch (type) {
case SQL_C_INTERVAL_YEAR:
ivval.interval_type = SQL_IS_YEAR;
@@ -2601,13 +2603,14 @@ ODBCFetch(ODBCStmt *stmt,
addStmtError(stmt, "07006", NULL, 0);
return SQL_ERROR;
}
- memset(&ivval, 0, sizeof(ivval));
- ivval.interval_sign = ival.interval_sign;
- ivval.intval.day_second.day = 0;
- ivval.intval.day_second.hour = 0;
- ivval.intval.day_second.minute = 0;
- ivval.intval.day_second.second = 0;
- ivval.intval.day_second.fraction = 0;
+ ivval = (SQL_INTERVAL_STRUCT) {
+ .interval_sign = ival.interval_sign,
+ .intval.day_second.day = 0,
+ .intval.day_second.hour = 0,
+ .intval.day_second.minute = 0,
+ .intval.day_second.second = 0,
+ .intval.day_second.fraction = 0,
+ };
switch (type) {
case SQL_C_INTERVAL_DAY:
ivval.interval_type = SQL_IS_DAY;
diff --git a/clients/odbc/driver/ODBCDesc.c b/clients/odbc/driver/ODBCDesc.c
--- a/clients/odbc/driver/ODBCDesc.c
+++ b/clients/odbc/driver/ODBCDesc.c
@@ -131,7 +131,7 @@ cleanODBCDescRec(ODBCDesc *desc, ODBCDes
free(rec->sql_desc_table_name);
if (rec->sql_desc_type_name)
free(rec->sql_desc_type_name);
- memset(rec, 0, sizeof(*rec));
+ *rec = (ODBCDescRec) {0};
if (desc) {
if (isAD(desc)) {
rec->sql_desc_concise_type = SQL_C_DEFAULT;
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -833,10 +833,11 @@ msab_getUplogInfo(sabuplog *ret, const s
memset(avg30, 0, sizeof(int) * 30);
/* clear the struct */
- memset(ret, 0, sizeof(sabuplog));
- ret->minuptime = -1;
- ret->lastcrash = -1;
- ret->laststop = -1;
+ *ret = (sabuplog) {
+ .minuptime = -1,
+ .lastcrash = -1,
+ .laststop = -1,
+ };
snprintf(log, sizeof(log), "%s/%s", db->path, UPLOGFILE);
if ((f = fopen(log, "r")) != NULL) {
diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -294,7 +294,7 @@ MT_lockf(char *filename, int mode, off_t
} *lockedfiles;
struct lockedfiles **fpp, *fp;
- memset(&ov, 0, sizeof(ov));
+ ov = (OVERLAPPED) {0};
#if defined(DUMMYSTRUCTNAME) && (defined(NONAMELESSUNION) ||
!defined(_MSC_EXTENSIONS)) /* Windows SDK v7.0 */
ov.u.s.Offset = (unsigned int) off;
#if 0
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -266,7 +266,7 @@ VIEWreset(BAT *b)
const char *nme;
/* alloc heaps */
- memset(&tail, 0, sizeof(Heap));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list