Commit e3aaec8e authored by Yoni Fogel's avatar Yoni Fogel

Used PRI macros to remove warnings in printf statements

Addresses #172

git-svn-id: file:///svn/tokudb@1082 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0717950e
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include <limits.h> #include <limits.h>
#include <db.h> #include <db.h>
#include <inttypes.h>
#include <signal.h> #include <signal.h>
typedef uint8_t bool; typedef uint8_t bool;
......
...@@ -78,10 +78,10 @@ error: \ ...@@ -78,10 +78,10 @@ error: \
return errno; \ return errno; \
} }
DEF_STR_TO(strtoint32, int32_t, int64_t, strtoll, "d"); DEF_STR_TO(strtoint32, int32_t, int64_t, strtoll, PRId32);
DEF_STR_TO(strtouint32, uint32_t, uint64_t, strtoull, "u"); DEF_STR_TO(strtouint32, uint32_t, uint64_t, strtoull, PRIu32);
DEF_STR_TO(strtoint64, int64_t, int64_t, strtoll, "lld"); DEF_STR_TO(strtoint64, int64_t, int64_t, strtoll, PRId64);
DEF_STR_TO(strtouint64, uint64_t, uint64_t, strtoull, "llu"); DEF_STR_TO(strtouint64, uint64_t, uint64_t, strtoull, PRIu64);
void outputbyte(uint8_t ch) void outputbyte(uint8_t ch)
{ {
......
...@@ -259,7 +259,7 @@ int usage() ...@@ -259,7 +259,7 @@ int usage()
fprintf(stderr, fprintf(stderr,
"usage: %s [-PpTuVhHfF] [-o output] [-r seed] [-m minsize] [-M limitsize]\n" "usage: %s [-PpTuVhHfF] [-o output] [-r seed] [-m minsize] [-M limitsize]\n"
" %*s[-n numpairs] [-d delimiter] [-s delimiter]\n", " %*s[-n numpairs] [-d delimiter] [-s delimiter]\n",
g.progname, strlen(g.progname) + 1, ""); g.progname, (int)strlen(g.progname) + 1, "");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
...@@ -319,7 +319,7 @@ void generate_keys() ...@@ -319,7 +319,7 @@ void generate_keys()
if (length == 0 && !usedemptykey) usedemptykey = true; if (length == 0 && !usedemptykey) usedemptykey = true;
else { else {
/* Append identifier to ensure uniqueness. */ /* Append identifier to ensure uniqueness. */
sprintf(identifier, "x%llx", numgenerated); sprintf(identifier, "x%" PRIx64, numgenerated);
outputstring(identifier); outputstring(identifier);
totalsize += strlen(identifier); totalsize += strlen(identifier);
} }
......
...@@ -433,7 +433,7 @@ int read_header() ...@@ -433,7 +433,7 @@ int read_header()
if (!strcmp(field, "VERSION")) { if (!strcmp(field, "VERSION")) {
if (strtoint32(value, &g.version, 1, INT32_MAX, 10)) goto error; if (strtoint32(value, &g.version, 1, INT32_MAX, 10)) goto error;
if (g.version != 3) { if (g.version != 3) {
ERRORX("line %llu: VERSION %d is unsupported", g.linenumber, g.version); ERRORX("line %"PRIu64": VERSION %d is unsupported", g.linenumber, g.version);
goto error; goto error;
} }
continue; continue;
...@@ -458,7 +458,7 @@ int read_header() ...@@ -458,7 +458,7 @@ int read_header()
ERRORX("db type %s not supported.\n", value); ERRORX("db type %s not supported.\n", value);
goto error; goto error;
} }
ERRORX("line %llu: unknown type %s", g.linenumber, value); ERRORX("line %"PRIu64": unknown type %s", g.linenumber, value);
goto error; goto error;
} }
if (!strcmp(field, "database") || !strcmp(field, "subdatabase")) { if (!strcmp(field, "database") || !strcmp(field, "subdatabase")) {
...@@ -501,7 +501,7 @@ int read_header() ...@@ -501,7 +501,7 @@ int read_header()
} }
if (false) { if (false) {
formaterror: formaterror:
ERRORX("line %llu: unexpected format", g.linenumber); ERRORX("line %"PRIu64": unexpected format", g.linenumber);
} }
error: error:
return EXIT_FAILURE; return EXIT_FAILURE;
...@@ -648,7 +648,7 @@ int doublechararray(char** pmem, uint64_t* size) ...@@ -648,7 +648,7 @@ int doublechararray(char** pmem, uint64_t* size)
*size <<= 1; *size <<= 1;
if (*size == 0) { if (*size == 0) {
/* Overflowed uint64_t. */ /* Overflowed uint64_t. */
ERRORX("Line %llu: Line too long.\n", g.linenumber); ERRORX("Line %"PRIu64": Line too long.\n", g.linenumber);
goto error; goto error;
} }
if ((*pmem = (char*)realloc(*pmem, *size)) == NULL) { if ((*pmem = (char*)realloc(*pmem, *size)) == NULL) {
...@@ -703,22 +703,22 @@ int get_dbt(DBT* pdbt) ...@@ -703,22 +703,22 @@ int get_dbt(DBT* pdbt)
} }
else if (highch == EOF) { else if (highch == EOF) {
g.eof = true; g.eof = true;
ERRORX("Line %llu: Unexpected end of file (2 hex digits per byte).\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected end of file (2 hex digits per byte).\n", g.linenumber);
goto error; goto error;
} }
else if (!isxdigit(highch)) { else if (!isxdigit(highch)) {
ERRORX("Line %llu: Unexpected '%c' (non-hex) input.\n", g.linenumber, highch); ERRORX("Line %"PRIu64": Unexpected '%c' (non-hex) input.\n", g.linenumber, highch);
goto error; goto error;
} }
lowch = getchar(); lowch = getchar();
if (lowch == EOF) { if (lowch == EOF) {
g.eof = true; g.eof = true;
ERRORX("Line %llu: Unexpected end of file (2 hex digits per byte).\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected end of file (2 hex digits per byte).\n", g.linenumber);
goto error; goto error;
} }
else if (!isxdigit(lowch)) { else if (!isxdigit(lowch)) {
ERRORX("Line %llu: Unexpected '%c' (non-hex) input.\n", g.linenumber, lowch); ERRORX("Line %"PRIu64": Unexpected '%c' (non-hex) input.\n", g.linenumber, lowch);
goto error; goto error;
} }
...@@ -730,7 +730,7 @@ int get_dbt(DBT* pdbt) ...@@ -730,7 +730,7 @@ int get_dbt(DBT* pdbt)
nextch = firstch; nextch = firstch;
break; break;
} }
ERRORX("Line %llu: Nonprintable character found.", g.linenumber); ERRORX("Line %"PRIu64": Nonprintable character found.", g.linenumber);
goto error; goto error;
} }
} }
...@@ -757,15 +757,15 @@ int get_dbt(DBT* pdbt) ...@@ -757,15 +757,15 @@ int get_dbt(DBT* pdbt)
lowch = getchar(); lowch = getchar();
if (lowch == EOF) { if (lowch == EOF) {
g.eof = true; g.eof = true;
ERRORX("Line %llu: Unexpected end of file (2 hex digits per byte).\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected end of file (2 hex digits per byte).\n", g.linenumber);
goto error; goto error;
} }
if (!isxdigit(highch)) { if (!isxdigit(highch)) {
ERRORX("Line %llu: Unexpected '%c' (non-hex) input.\n", g.linenumber, highch); ERRORX("Line %"PRIu64": Unexpected '%c' (non-hex) input.\n", g.linenumber, highch);
goto error; goto error;
} }
if (!isxdigit(lowch)) { if (!isxdigit(lowch)) {
ERRORX("Line %llu: Unexpected '%c' (non-hex) input.\n", g.linenumber, lowch); ERRORX("Line %"PRIu64": Unexpected '%c' (non-hex) input.\n", g.linenumber, lowch);
goto error; goto error;
} }
if (index == datasize[which]) { if (index == datasize[which]) {
...@@ -828,7 +828,7 @@ int read_keys() ...@@ -828,7 +828,7 @@ int read_keys()
g.linenumber++; g.linenumber++;
if (get_dbt(&key) != 0) goto error; if (get_dbt(&key) != 0) goto error;
if (g.eof) { if (g.eof) {
ERRORX("Line %llu: Key exists but value missing.", g.linenumber); ERRORX("Line %"PRIu64": Key exists but value missing.", g.linenumber);
goto error; goto error;
} }
g.linenumber++; g.linenumber++;
...@@ -861,13 +861,13 @@ int read_keys() ...@@ -861,13 +861,13 @@ int read_keys()
} }
default: { default: {
unexpectedinput: unexpectedinput:
ERRORX("Line %llu: Unexpected input while reading key.\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected input while reading key.\n", g.linenumber);
goto error; goto error;
} }
} }
if (g.eof) { if (g.eof) {
ERRORX("Line %llu: Key exists but value missing.", g.linenumber); ERRORX("Line %"PRIu64": Key exists but value missing.", g.linenumber);
goto error; goto error;
} }
g.linenumber++; g.linenumber++;
...@@ -875,7 +875,7 @@ int read_keys() ...@@ -875,7 +875,7 @@ int read_keys()
switch (spacech) { switch (spacech) {
case (EOF): { case (EOF): {
g.eof = true; g.eof = true;
ERRORX("Line %llu: Unexpected end of file while reading value.\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected end of file while reading value.\n", g.linenumber);
goto error; goto error;
} }
case (' '): { case (' '): {
...@@ -884,7 +884,7 @@ int read_keys() ...@@ -884,7 +884,7 @@ int read_keys()
break; break;
} }
default: { default: {
ERRORX("Line %llu: Unexpected input while reading value.\n", g.linenumber); ERRORX("Line %"PRIu64": Unexpected input while reading value.\n", g.linenumber);
goto error; goto error;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment