]> git.sur5r.net Git - openldap/commitdiff
Use mdb_size_t for line numbers in mdb_load
authorHallvard Furuseth <hallvard@openldap.org>
Sat, 23 Jul 2016 10:17:04 +0000 (12:17 +0200)
committerHallvard Furuseth <hallvard@openldap.org>
Sat, 23 Jul 2016 10:17:04 +0000 (12:17 +0200)
This matches the mdb_size_t entry counts.

libraries/liblmdb/mdb_load.c

index fe1d846b53e28eb6477e2bad41706b626902e705..3b55a946d1d4aa38aaa63d25f39c60b806a5ea6f 100644 (file)
@@ -25,7 +25,7 @@ static int mode;
 
 static char *subname = NULL;
 
-static size_t lineno;
+static mdb_size_t lineno;
 static int version;
 
 static int flags;
@@ -38,7 +38,6 @@ static MDB_envinfo info;
 
 static MDB_val kbuf, dbuf;
 
-#define Z      MDB_FMT_Z
 #define Y      MDB_FMT_Y
 
 #define STRLENOF(s)    (sizeof(s)-1)
@@ -70,7 +69,7 @@ static void readhdr(void)
                if (!strncmp(dbuf.mv_data, "VERSION=", STRLENOF("VERSION="))) {
                        version=atoi((char *)dbuf.mv_data+STRLENOF("VERSION="));
                        if (version > 3) {
-                               fprintf(stderr, "%s: line %" Z "d: unsupported VERSION %d\n",
+                               fprintf(stderr, "%s: line %" Y "u: unsupported VERSION %d\n",
                                        prog, lineno, version);
                                exit(EXIT_FAILURE);
                        }
@@ -80,7 +79,7 @@ static void readhdr(void)
                        if (!strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "print", STRLENOF("print")))
                                mode |= PRINT;
                        else if (strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "bytevalue", STRLENOF("bytevalue"))) {
-                               fprintf(stderr, "%s: line %" Z "d: unsupported FORMAT %s\n",
+                               fprintf(stderr, "%s: line %" Y "u: unsupported FORMAT %s\n",
                                        prog, lineno, (char *)dbuf.mv_data+STRLENOF("FORMAT="));
                                exit(EXIT_FAILURE);
                        }
@@ -91,7 +90,7 @@ static void readhdr(void)
                        subname = strdup((char *)dbuf.mv_data+STRLENOF("database="));
                } else if (!strncmp(dbuf.mv_data, "type=", STRLENOF("type="))) {
                        if (strncmp((char *)dbuf.mv_data+STRLENOF("type="), "btree", STRLENOF("btree")))  {
-                               fprintf(stderr, "%s: line %" Z "d: unsupported type %s\n",
+                               fprintf(stderr, "%s: line %" Y "u: unsupported type %s\n",
                                        prog, lineno, (char *)dbuf.mv_data+STRLENOF("type="));
                                exit(EXIT_FAILURE);
                        }
@@ -101,7 +100,7 @@ static void readhdr(void)
                        if (ptr) *ptr = '\0';
                        i = sscanf((char *)dbuf.mv_data+STRLENOF("mapaddr="), "%p", &info.me_mapaddr);
                        if (i != 1) {
-                               fprintf(stderr, "%s: line %" Z "d: invalid mapaddr %s\n",
+                               fprintf(stderr, "%s: line %" Y "u: invalid mapaddr %s\n",
                                        prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapaddr="));
                                exit(EXIT_FAILURE);
                        }
@@ -111,7 +110,7 @@ static void readhdr(void)
                        if (ptr) *ptr = '\0';
                        i = sscanf((char *)dbuf.mv_data+STRLENOF("mapsize="), "%" Y "u", &info.me_mapsize);
                        if (i != 1) {
-                               fprintf(stderr, "%s: line %" Z "d: invalid mapsize %s\n",
+                               fprintf(stderr, "%s: line %" Y "u: invalid mapsize %s\n",
                                        prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapsize="));
                                exit(EXIT_FAILURE);
                        }
@@ -121,7 +120,7 @@ static void readhdr(void)
                        if (ptr) *ptr = '\0';
                        i = sscanf((char *)dbuf.mv_data+STRLENOF("maxreaders="), "%u", &info.me_maxreaders);
                        if (i != 1) {
-                               fprintf(stderr, "%s: line %" Z "d: invalid maxreaders %s\n",
+                               fprintf(stderr, "%s: line %" Y "u: invalid maxreaders %s\n",
                                        prog, lineno, (char *)dbuf.mv_data+STRLENOF("maxreaders="));
                                exit(EXIT_FAILURE);
                        }
@@ -137,12 +136,12 @@ static void readhdr(void)
                        if (!dbflags[i].bit) {
                                ptr = memchr(dbuf.mv_data, '=', dbuf.mv_size);
                                if (!ptr) {
-                                       fprintf(stderr, "%s: line %" Z "d: unexpected format\n",
+                                       fprintf(stderr, "%s: line %" Y "u: unexpected format\n",
                                                prog, lineno);
                                        exit(EXIT_FAILURE);
                                } else {
                                        *ptr = '\0';
-                                       fprintf(stderr, "%s: line %" Z "d: unrecognized keyword ignored: %s\n",
+                                       fprintf(stderr, "%s: line %" Y "u: unrecognized keyword ignored: %s\n",
                                                prog, lineno, (char *)dbuf.mv_data);
                                }
                        }
@@ -152,7 +151,7 @@ static void readhdr(void)
 
 static void badend(void)
 {
-       fprintf(stderr, "%s: line %" Z "d: unexpected end of input\n",
+       fprintf(stderr, "%s: line %" Y "u: unexpected end of input\n",
                prog, lineno);
 }
 
@@ -210,7 +209,7 @@ badend:
                buf->mv_data = realloc(buf->mv_data, buf->mv_size*2);
                if (!buf->mv_data) {
                        Eof = 1;
-                       fprintf(stderr, "%s: line %" Z "d: out of memory, line too long\n",
+                       fprintf(stderr, "%s: line %" Y "u: out of memory, line too long\n",
                                prog, lineno);
                        return EOF;
                }
@@ -402,7 +401,7 @@ int main(int argc, char *argv[])
 
                        rc = readline(&data, &dbuf);
                        if (rc) {
-                               fprintf(stderr, "%s: line %" Z "d: failed to read key value\n", prog, lineno);
+                               fprintf(stderr, "%s: line %" Y "u: failed to read key value\n", prog, lineno);
                                goto txn_abort;
                        }
 
@@ -417,7 +416,7 @@ int main(int argc, char *argv[])
                        if (batch == 100) {
                                rc = mdb_txn_commit(txn);
                                if (rc) {
-                                       fprintf(stderr, "%s: line %" Z "d: txn_commit: %s\n",
+                                       fprintf(stderr, "%s: line %" Y "u: txn_commit: %s\n",
                                                prog, lineno, mdb_strerror(rc));
                                        goto env_close;
                                }
@@ -437,7 +436,7 @@ int main(int argc, char *argv[])
                rc = mdb_txn_commit(txn);
                txn = NULL;
                if (rc) {
-                       fprintf(stderr, "%s: line %" Z "d: txn_commit: %s\n",
+                       fprintf(stderr, "%s: line %" Y "u: txn_commit: %s\n",
                                prog, lineno, mdb_strerror(rc));
                        goto env_close;
                }