Fix/improve logging in ef_close(), ef_extend(), ef_truncate()

Change ef_close() to log ep->file instead of ep->name, to match
ef_open().

Fix ef_extend() to log ep->name instead of ep->file, which could be
null.  Also fix ef_ensure_space()'s function comment.  Both broken in
commit 2eb8672b.

ef_truncate()'s error logging lacked detail when ef_realloc_cache()
failed, fix.
This commit is contained in:
Markus Armbruster 2008-08-31 14:24:53 -04:00
parent 0bc3cb460a
commit e438f6b4cd

View file

@ -210,7 +210,7 @@ ef_close(int type)
ep->cache = NULL;
}
if (close(ep->fd) < 0) {
logerror("Error closing %s (%s)", ep->name, strerror(errno));
logerror("Error closing %s (%s)", ep->file, strerror(errno));
retval = 0;
}
ep->fd = -1;
@ -567,12 +567,12 @@ ef_extend(int type, int count)
if (id + count > ep->csize) {
if (ep->flags & EFF_STATIC) {
logerror("Can't extend %s beyond %d elements",
ep->file, ep->csize);
ep->name, ep->csize);
return 0;
}
if (!ef_realloc_cache(ep, id + count)) {
logerror("Can't extend %s to %d elements (%s)",
ep->file, id + count, strerror(errno));
ep->name, id + count, strerror(errno));
return 0;
}
}
@ -665,7 +665,8 @@ ef_truncate(int type, int count)
if (ep->flags & EFF_MEM) {
if (!(ep->flags & EFF_STATIC)) {
if (!ef_realloc_cache(ep, count)) {
logerror("Can't shrink cache after truncate");
logerror("Can't shrink %s cache after truncate (%s)",
ep->name, strerror(errno));
/* continue with unshrunk cache */
}
}
@ -766,7 +767,7 @@ ef_check(int type)
}
/*
* Ensure file-backed table contains ID.
* Ensure table contains element ID.
* If necessary, extend it in steps of COUNT elements.
* Return non-zero on success, zero on failure.
*/