Changeset: 3ae6579485bd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ae6579485bd
Modified Files:
        common/utils/matomic.h
        gdk/gdk_posix.c
        monetdb5/mal/mal_import.c
Branch: default
Log Message:

Use size_t instead of int for strlen.


diffs (92 lines):

diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -279,6 +279,8 @@ typedef volatile char ATOMIC_FLAG;
 
 /* emulate using mutexes */
 
+#include <pthread.h> /* required for pthread_mutex_t */
+
 typedef size_t ATOMIC_BASE_TYPE;
 typedef struct {
        ATOMIC_BASE_TYPE val;
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -629,12 +629,13 @@ MT_mremap(const char *path, int mode, vo
 #endif
 #endif
                                                ) {
-                                               int err = errno;
+                                               int err = errno, other;
                                                /* extending failed:
                                                 * free any disk space
                                                 * allocated in the
                                                 * process */
-                                               (void) ftruncate(fd, (off_t) 
old_size);
+                                               other = ftruncate(fd, (off_t) 
old_size);
+                                               (void) other; /* silence 
compiler warning for ignoring result of ftruncate */
                                                errno = err; /* restore for 
error message */
                                                GDKsyserror("MT_mremap: growing 
file failed\n");
                                                close(fd);
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -296,13 +296,14 @@ evalFile(str fname, int listing)
 }
 
 /* patch a newline character if needed */
-static str mal_cmdline(char *s, int *len)
+static str
+mal_cmdline(char *s, size_t *len)
 {
-       if (s[*len - 1] != '\n') {
-               char *n = GDKmalloc(*len + 1 + 1);
+       if (*len && s[*len - 1] != '\n') {
+               char *n = GDKmalloc(*len + 2);
                if (n == NULL)
                        return s;
-               strncpy(n, s, *len);
+               memcpy(n, s, *len);
                n[*len] = '\n';
                n[*len + 1] = 0;
                (*len)++;
@@ -313,9 +314,9 @@ static str mal_cmdline(char *s, int *len
 
 str
 compileString(Symbol *fcn, Client cntxt, str s)
-{      
+{
        Client c;
-       int len = (int) strlen(s);
+       size_t len = strlen(s);
        buffer *b;
        str msg = MAL_SUCCEED;
        str qry;
@@ -323,6 +324,7 @@ compileString(Symbol *fcn, Client cntxt,
        stream *bs;
        bstream *fdin = NULL;
 
+       assert(s);
        s = mal_cmdline(s, &len);
        qry = s;
        if (old == s) {
@@ -390,13 +392,16 @@ compileString(Symbol *fcn, Client cntxt,
 
 str
 callString(Client cntxt, str s, int listing)
-{      Client c;
-       int i, len = (int) strlen(s);
+{
+       Client c;
+       int i;
+       size_t len = strlen(s);
        buffer *b;
        str old =s;
        str msg = MAL_SUCCEED, qry;
        bstream *bs;
 
+       assert(s);
        s = mal_cmdline(s, &len);
        qry = s;
        if (old == s) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to