summaryrefslogtreecommitdiff
path: root/lib/tdb/common/io.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2013-05-28 16:53:56 +0930
committerAndrew Bartlett <abartlet@samba.org>2013-05-28 11:22:14 +0200
commit3bd686c5ad4756af1033ac14ba09a40156cc6d47 (patch)
tree55d7d61637fa477e542f2d8c291835be0f8a415c /lib/tdb/common/io.c
parent5a633dd6bb5be817c6b421df0c098e3428a20773 (diff)
downloadsamba-3bd686c5ad4756af1033ac14ba09a40156cc6d47.tar.gz
samba-3bd686c5ad4756af1033ac14ba09a40156cc6d47.tar.bz2
samba-3bd686c5ad4756af1033ac14ba09a40156cc6d47.zip
tdb: fix logging of offets and lengths.
We can have offsets > 2G, so use unsigned values. Fixes other prints to be native types rather than casts, too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue May 28 11:22:14 CEST 2013 on sn-devel-104
Diffstat (limited to 'lib/tdb/common/io.c')
-rw-r--r--lib/tdb/common/io.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 7e29c38440..a477fb55e4 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -40,8 +40,8 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len,
if (!probe) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob off %d len %d wrap\n",
- (int)off, (int)len));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob off %u len %u wrap\n",
+ off, len));
}
return -1;
}
@@ -127,8 +127,8 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
/* try once more */
tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
- "%d of %d bytes at %d, trying once more\n",
- (int)written, len, off));
+ "%zi of %u bytes at %u, trying once more\n",
+ written, len, off));
written = pwrite(tdb->fd, (const char *)buf+written,
len-written,
off+written);
@@ -136,13 +136,13 @@ static int tdb_write(struct tdb_context *tdb, tdb_off_t off,
if (written == -1) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
- "len=%d (%s)\n", off, len, strerror(errno)));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %u "
+ "len=%u (%s)\n", off, len, strerror(errno)));
return -1;
} else if (written != (ssize_t)len) {
tdb->ecode = TDB_ERR_IO;
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: failed to "
- "write %d bytes at %d in two attempts\n",
+ "write %u bytes at %u in two attempts\n",
len, off));
return -1;
}
@@ -180,10 +180,10 @@ static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf,
if (ret != (ssize_t)len) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_IO;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_read failed at %d "
- "len=%d ret=%d (%s) map_size=%d\n",
- (int)off, (int)len, (int)ret, strerror(errno),
- (int)tdb->map_size));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_read failed at %u "
+ "len=%u ret=%zi (%s) map_size=%u\n",
+ off, len, ret, strerror(errno),
+ tdb->map_size));
return -1;
}
#endif
@@ -266,7 +266,7 @@ int tdb_mmap(struct tdb_context *tdb)
if (tdb->map_ptr == MAP_FAILED) {
tdb->map_ptr = NULL;
- TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n",
+ TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %u (%s)\n",
tdb->map_size, strerror(errno)));
#ifdef HAVE_INCOHERENT_MMAP
tdb->ecode = TDB_ERR_IO;
@@ -305,7 +305,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
errno = ENOSPC;
}
if (written != 1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n",
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %u failed (%s)\n",
size+addition, strerror(errno)));
return -1;
}
@@ -331,14 +331,14 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad
}
if (written == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of "
- "%d bytes failed (%s)\n", (int)n,
+ "%u bytes failed (%s)\n", (int)n,
strerror(errno)));
return -1;
}
if (written != n) {
TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: wrote "
- "only %d of %d bytes - retrying\n", (int)written,
- (int)n));
+ "only %zu of %zi bytes - retrying\n", written,
+ n));
}
addition -= written;
size += written;
@@ -454,7 +454,7 @@ unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len
if (!(buf = (unsigned char *)malloc(len ? len : 1))) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_OOM;
- TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n",
+ TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%u (%s)\n",
len, strerror(errno)));
return NULL;
}
@@ -507,7 +507,7 @@ int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *r
if (TDB_BAD_MAGIC(rec)) {
/* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_CORRUPT;
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_rec_read bad magic 0x%x at offset=%d\n", rec->magic, offset));
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_rec_read bad magic 0x%x at offset=%u\n", rec->magic, offset));
return -1;
}
return tdb->methods->tdb_oob(tdb, rec->next, sizeof(*rec), 0);