Changeset: 75695bfc3d01 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=75695bfc3d01
Modified Files:
        gdk/gdk_logger.c
        monetdb5/modules/kernel/batstr.c
        sql/backends/monet5/sql_statement.c
        tools/mserver/shutdowntest.c
Branch: default
Log Message:

Merge with Oct2020 branch.


diffs (truncated from 1115 to 300 lines):

diff --git a/clients/examples/C/streamcat.c b/clients/examples/C/streamcat.c
--- a/clients/examples/C/streamcat.c
+++ b/clients/examples/C/streamcat.c
@@ -207,6 +207,8 @@ int cmd_read(char *argv[])
 
        copy_stream_to_file(s, out, bufsize);
        close_stream(s);
+       if (out != stdout)
+               fclose(out);
 
        return 0;
 }
@@ -318,6 +320,9 @@ int cmd_write(char *argv[])
        copy_file_to_stream(in, s, bufsize, do_flush, flush_level);
        close_stream(s);
 
+       if (in != stdin)
+               fclose(in);
+
        return 0;
 }
 
@@ -557,13 +562,13 @@ int cmd_bstream(char *argv[])
                        fclose(f);
                        mnstr_flush(bs, MNSTR_FLUSH_DATA);
                }
-               mnstr_destroy(bs);
-               if (additional) {
-                       mnstr_printf(s, "%s", additional);
-               }
-               mnstr_close(s);
        }
 
+       mnstr_destroy(bs);
+       if (additional) {
+               mnstr_printf(s, "%s", additional);
+       }
+       mnstr_close(s);
 
        return 0;
 }
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -75,7 +75,7 @@ getFarmPath(char *pathbuf, size_t size, 
                snprintf(pathbuf, size, "%s", _sabaoth_internal_dbfarm);
        } else {
                snprintf(pathbuf, size, "%s%c%s",
-                               _sabaoth_internal_dbfarm, DIR_SEP, extra);
+                                _sabaoth_internal_dbfarm, DIR_SEP, extra);
        }
 
        return(NULL);
@@ -95,11 +95,11 @@ getDBPath(char *pathbuf, size_t size, co
 
        if (extra == NULL) {
                snprintf(pathbuf, size, "%s%c%s",
-                               _sabaoth_internal_dbfarm, DIR_SEP, 
_sabaoth_internal_dbname);
+                                _sabaoth_internal_dbfarm, DIR_SEP, 
_sabaoth_internal_dbname);
        } else {
                snprintf(pathbuf, size, "%s%c%s%c%s",
-                               _sabaoth_internal_dbfarm, DIR_SEP,
-                               _sabaoth_internal_dbname, DIR_SEP, extra);
+                                _sabaoth_internal_dbfarm, DIR_SEP,
+                                _sabaoth_internal_dbname, DIR_SEP, extra);
        }
 
        return(NULL);
@@ -174,10 +174,9 @@ msab_init(const char *dbfarm, const char
        /* remove trailing slashes, newlines and spaces */
        len--;
        while (len > 0 && (
-                               _sabaoth_internal_dbfarm[len] == '/' ||
-                               _sabaoth_internal_dbfarm[len] == '\n' ||
-                               _sabaoth_internal_dbfarm[len] == ' '))
-       {
+                          _sabaoth_internal_dbfarm[len] == '/' ||
+                          _sabaoth_internal_dbfarm[len] == '\n' ||
+                          _sabaoth_internal_dbfarm[len] == ' ')) {
                _sabaoth_internal_dbfarm[len] = '\0';
                len--;
        }
@@ -314,7 +313,7 @@ msab_marchScenario(const char *lang)
                return(NULL);
        }
        snprintf(buf, sizeof(buf), "failed to open file: %s (%s)",
-                       strerror(errno), pathbuf);
+                        strerror(errno), pathbuf);
        return(strdup(buf));
 }
 
@@ -358,7 +357,7 @@ msab_retreatScenario(const char *lang)
                                len = strlen(buf) + 1;
                                if (fwrite(buf, 1, len, f) < len) {
                                        snprintf(buf, sizeof(buf), "failed to 
write: %s (%s)",
-                                                       strerror(errno), 
pathbuf);
+                                                        strerror(errno), 
pathbuf);
                                        (void)fclose(f);
                                        return(strdup(buf));
                                }
@@ -373,7 +372,7 @@ msab_retreatScenario(const char *lang)
                        if (ferror(f)) {
                                /* some error */
                                snprintf(buf, sizeof(buf), "failed to write: %s 
(%s)",
-                                        strerror(errno), pathbuf);
+                                                strerror(errno), pathbuf);
                                (void)fclose(f);
                                return strdup(buf);
                        }
@@ -383,7 +382,7 @@ msab_retreatScenario(const char *lang)
                }
        }
        snprintf(buf, sizeof(buf), "failed to open file: %s (%s)",
-                       strerror(errno), pathbuf);
+                        strerror(errno), pathbuf);
        return(strdup(buf));
 }
 
@@ -407,7 +406,7 @@ msab_marchConnection(const char *host, c
 
        if (port <= 0 && host[0] != '/')
                return(strdup("UNIX domain connections should be given as "
-                                       "absolute path"));
+                                         "absolute path"));
 
        if ((f = fopen(pathbuf, "a")) != NULL) {
                /* append to the file */
@@ -422,7 +421,7 @@ msab_marchConnection(const char *host, c
        } else {
                char buf[FILENAME_MAX + 1024];
                snprintf(buf, sizeof(buf), "failed to open file: %s (%s)",
-                               strerror(errno), pathbuf);
+                                strerror(errno), pathbuf);
                return(strdup(buf));
        }
 }
@@ -489,7 +488,7 @@ msab_registerStarting(void)
        } else {
                char buf[2*FILENAME_MAX];
                snprintf(buf, sizeof(buf), "failed to open file: %s (%s)",
-                               strerror(errno), pathbuf);
+                                strerror(errno), pathbuf);
                return(strdup(buf));
        }
 
@@ -559,7 +558,7 @@ msab_registerStop(void)
        } else {
                char buf[2*FILENAME_MAX];
                snprintf(buf, sizeof(buf), "failed to open file: %s (%s)",
-                               strerror(errno), pathbuf);
+                                strerror(errno), pathbuf);
                return(strdup(buf));
        }
 
@@ -588,7 +587,7 @@ msab_pickSecret(char **generated_secret)
        if (remove(pathbuf) < 0 && errno != ENOENT) {
                char err[FILENAME_MAX + 512];
                snprintf(err, sizeof(err), "unable to remove '%s': %s",
-                       pathbuf, strerror(errno));
+                                pathbuf, strerror(errno));
                return strdup(err);
        }
 
@@ -609,7 +608,7 @@ msab_pickSecret(char **generated_secret)
 #else
        (void)bin_secret;
        if (generated_secret)
-       // do not return an error, just continue without a secret
+               // do not return an error, just continue without a secret
                *generated_secret = NULL;
        free(secret);
        return NULL;
@@ -623,30 +622,32 @@ msab_pickSecret(char **generated_secret)
                        secret + 2 * i, 3,
                        "%02x",
                        bin_secret[i]
-               );
+                       );
        }
 
        if ((fd = open(pathbuf, O_CREAT | O_WRONLY | O_CLOEXEC, S_IRUSR | 
S_IWUSR)) == -1) {
                char err[512];
                snprintf(err, sizeof(err), "unable to open '%s': %s",
-                               pathbuf, strerror(errno));
+                                pathbuf, strerror(errno));
                free(secret);
                return strdup(err);
        }
        if ((f = fdopen(fd, "w")) == NULL) {
                char err[512];
                snprintf(err, sizeof(err), "unable to open '%s': %s",
-                               pathbuf, strerror(errno));
+                                pathbuf, strerror(errno));
                close(fd);
                (void)remove(pathbuf);
                free(secret);
                return strdup(err);
        }
-       if (fwrite(secret, 1, SECRET_LENGTH, f) < SECRET_LENGTH || fclose(f) < 
0) {
+       bool error;
+       error = fwrite(secret, 1, SECRET_LENGTH, f) < SECRET_LENGTH;
+       error |= fclose(f) < 0;
+       if (error) {
                char err[512];
                snprintf(err, sizeof(err), "cannot write secret: %s",
-                               strerror(errno));
-               fclose(f);
+                                strerror(errno));
                (void)remove(pathbuf);
                free(secret);
                return strdup(err);
@@ -904,7 +905,7 @@ msab_getStatus(sabdb** ret, const char *
        d = opendir(pathbuf);
        if (d == NULL) {
                snprintf(data, sizeof(data), "failed to open directory %s: %s",
-                               pathbuf, strerror(errno));
+                                pathbuf, strerror(errno));
                return(strdup(data));
        }
        while ((e = readdir(d)) != NULL) {
@@ -995,36 +996,36 @@ msab_getUplogInfo(sabuplog *ret, const s
                p = data;
                while ((c = getc(f)) != EOF) {
                        switch (c) {
-                               case '\t':
-                                       /* start attempt */
-                                       ret->startcntr++;
-                                       if (start != 0)
-                                               ret->lastcrash = start;
-                                       memmove(&avg10[0], &avg10[1], 
sizeof(int) * 9);
-                                       memmove(&avg30[0], &avg30[1], 
sizeof(int) * 29);
-                                       avg10[9] = avg30[29] = ret->crashavg1 =
-                                               (start != 0);
-                                       *p = '\0';
-                                       ret->laststart = start = 
(time_t)atol(data);
-                                       p = data;
+                       case '\t':
+                               /* start attempt */
+                               ret->startcntr++;
+                               if (start != 0)
+                                       ret->lastcrash = start;
+                               memmove(&avg10[0], &avg10[1], sizeof(int) * 9);
+                               memmove(&avg30[0], &avg30[1], sizeof(int) * 29);
+                               avg10[9] = avg30[29] = ret->crashavg1 =
+                                       (start != 0);
+                               *p = '\0';
+                               ret->laststart = start = (time_t)atol(data);
+                               p = data;
                                break;
-                               case '\n':
-                                       /* successful stop */
-                                       ret->stopcntr++;
-                                       *p = '\0';
-                                       ret->laststop = stop = 
(time_t)atol(data);
-                                       p = data;
-                                       i = (int) (stop - start);
-                                       if (i > ret->maxuptime)
-                                               ret->maxuptime = i;
-                                       if (ret->minuptime == -1 || 
ret->minuptime > stop - start)
-                                               ret->minuptime = stop - start;
-                                       up += i;
-                                       start = 0;
+                       case '\n':
+                               /* successful stop */
+                               ret->stopcntr++;
+                               *p = '\0';
+                               ret->laststop = stop = (time_t)atol(data);
+                               p = data;
+                               i = (int) (stop - start);
+                               if (i > ret->maxuptime)
+                                       ret->maxuptime = i;
+                               if (ret->minuptime == -1 || ret->minuptime > 
stop - start)
+                                       ret->minuptime = stop - start;
+                               up += i;
+                               start = 0;
                                break;
-                               default:
-                                       /* timestamp */
-                                       *p++ = c;
+                       default:
+                               /* timestamp */
+                               *p++ = c;
                                break;
                        }
                }
@@ -1055,7 +1056,7 @@ msab_getUplogInfo(sabuplog *ret, const s
        } else {
                char buf[2*FILENAME_MAX];
                snprintf(buf, sizeof(buf), "could not open file %s: %s",
-                               log, strerror(errno));
+                                log, strerror(errno));
                return(strdup(buf));
        }
 
@@ -1137,7 +1138,7 @@ msab_deserialise(sabdb **ret, const char
 
        if (strncmp(sdb, "sabdb:", 6) != 0) {
                snprintf(buf, sizeof(buf),
-                               "string is not a sabdb struct: %s", sdb);
+                                "string is not a sabdb struct: %s", sdb);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to