aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-05-24 08:28:51 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-05-24 08:29:47 +0300
commitf82d0b213fd2cdce80dc891906fba8d589115664 (patch)
tree9aa091d9fbe7fea183391fc9e22fc0f2f54ae28f /src
parent0665bcf0c9cdf756f9d5edc6a638c56602c42065 (diff)
downloadgdbm-f82d0b213fd2cdce80dc891906fba8d589115664.tar.gz
gdbm-f82d0b213fd2cdce80dc891906fba8d589115664.tar.bz2
Fix the use of return code from _gdbm_full_(read|write) functions
Diffstat (limited to 'src')
-rw-r--r--src/falloc.c4
-rw-r--r--src/findkey.c2
-rw-r--r--src/gdbmstore.c4
-rw-r--r--src/gdbmtool.c17
-rw-r--r--src/update.c2
5 files changed, 10 insertions, 19 deletions
diff --git a/src/falloc.c b/src/falloc.c
index 33a238a..e87a5b7 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -193,25 +193,25 @@ pop_avail_block (GDBM_FILE dbf)
__lseek (dbf, new_el.av_adr, SEEK_SET));
if (file_pos != new_el.av_adr)
{
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
rc = GDBM_DEBUG_OVERRIDE ("pop_avail_block:read-failure",
_gdbm_full_read (dbf, new_blk, new_el.av_size));
if (rc)
{
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
if (!gdbm_avail_block_valid_p (new_blk))
{
gdbm_set_errno (dbf, GDBM_BAD_AVAIL, TRUE);
_gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
/* Add the elements from the new block to the header. */
index = 0;
@@ -321,25 +321,25 @@ push_avail_block (GDBM_FILE dbf)
GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
rc = GDBM_DEBUG_OVERRIDE ("push_avail_block:write-failure",
_gdbm_full_write (dbf, temp, av_size));
if (rc)
{
GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
"%s: error writing avail data: %s",
dbf->name, gdbm_db_strerror (dbf));
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
free (temp);
return 0;
}
/* Get_elem returns an element in the AV_TABLE block which is
larger than SIZE. AV_COUNT is the number of elements in the
AV_TABLE. If an item is found, it extracts it from the AV_TABLE
and moves the other elements up to fill the space. If no block is
diff --git a/src/findkey.c b/src/findkey.c
index 211d9a9..7638b04 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -74,25 +74,25 @@ _gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
_gdbm_fatal (dbf, _("lseek error"));
return NULL;
}
rc = GDBM_DEBUG_OVERRIDE ("_gdbm_read_entry:read-failure",
_gdbm_full_read (dbf, data_ca->dptr, key_size+data_size));
if (rc)
{
GDBM_DEBUG (GDBM_DEBUG_ERR|GDBM_DEBUG_LOOKUP|GDBM_DEBUG_READ,
"%s: error reading entry: %s",
dbf->name, gdbm_db_strerror (dbf));
dbf->need_recovery = TRUE;
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return NULL;
}
return data_ca->dptr;
}
/* Find the KEY in the file and get ready to read the associated data. The
return value is the location in the current hash bucket of the KEY's
entry. If it is found, additional data are returned as follows:
If RET_DPTR is not NULL, a pointer to the actual data is stored in it.
If RET_HASH_VAL is not NULL, it is assigned the actual hash value.
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 0bcd7d7..7b2ed04 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -158,35 +158,35 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-1-failure",
_gdbm_full_write (dbf, key.dptr, key.dsize));
if (rc)
{
GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
"%s: error writing key: %s",
dbf->name, gdbm_db_strerror (dbf));
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-2-failure",
_gdbm_full_write (dbf,
content.dptr, content.dsize));
if (rc)
{
GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
"%s: error writing content: %s",
dbf->name, gdbm_db_strerror (dbf));
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
/* Current bucket has changed. */
dbf->cache_entry->ca_changed = TRUE;
dbf->bucket_changed = TRUE;
/* Write everything that is needed to the disk. */
return _gdbm_end_update (dbf);
}
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 18d0e10..33bdf93 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -186,51 +186,46 @@ print_bucket (FILE *fp, hash_bucket *bucket, const char *mesg, ...)
fprintf (fp, "%11lu%9d\n",
(unsigned long) bucket->bucket_avail[index].av_adr,
bucket->bucket_avail[index].av_size);
}
size_t
_gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
{
int temp;
int size;
avail_block *av_stk;
size_t lines;
- int rc;
lines = 4 + dbf->header->avail.count;
if (lines > min_size)
return lines;
/* Initialize the variables for a pass throught the avail stack. */
temp = dbf->header->avail.next_block;
size = (((dbf->header->avail.size * sizeof (avail_elem)) >> 1)
+ sizeof (avail_block));
av_stk = emalloc (size);
/* Traverse the stack. */
while (temp)
{
if (__lseek (dbf, temp, SEEK_SET) != temp)
{
terror ("lseek: %s", strerror (errno));
break;
}
- if ((rc = _gdbm_full_read (dbf, av_stk, size)))
+ if (_gdbm_full_read (dbf, av_stk, size))
{
- if (rc == GDBM_FILE_EOF)
- terror ("read: %s", gdbm_strerror (rc));
- else
- terror ("read: %s (%s)",
- gdbm_strerror (rc), strerror (errno));
+ terror ("read: %s", gdbm_db_strerror (dbf));
break;
}
if (gdbm_avail_block_valid_p (av_stk))
{
lines += av_stk->count;
if (lines > min_size)
break;
}
temp = av_stk->next_block;
}
free (av_stk);
@@ -247,52 +242,48 @@ av_table_display (avail_elem *av_table, int count, FILE *fp)
{
fprintf (fp, " %15d %10lu \n",
av_table[i].av_size, (unsigned long) av_table[i].av_adr);
}
}
void
_gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
{
int temp;
int size;
avail_block *av_stk;
- int rc;
/* Print the the header avail block. */
fprintf (fp, _("\nheader block\nsize = %d\ncount = %d\n"),
dbf->header->avail.size, dbf->header->avail.count);
av_table_display (dbf->header->avail.av_table, dbf->header->avail.count, fp);
/* Initialize the variables for a pass throught the avail stack. */
temp = dbf->header->avail.next_block;
size = (((dbf->header->avail.size * sizeof (avail_elem)) >> 1)
+ sizeof (avail_block));
av_stk = emalloc (size);
/* Print the stack. */
while (temp)
{
if (__lseek (dbf, temp, SEEK_SET) != temp)
{
terror ("lseek: %s", strerror (errno));
break;
}
- if ((rc = _gdbm_full_read (dbf, av_stk, size)))
+ if (_gdbm_full_read (dbf, av_stk, size))
{
- if (rc == GDBM_FILE_EOF)
- terror ("read: %s", gdbm_strerror (rc));
- else
- terror ("read: %s (%s)", gdbm_strerror (rc), strerror (errno));
+ terror ("read: %s", gdbm_db_strerror (dbf));
break;
}
/* Print the block! */
fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp,
av_stk->size, av_stk->count);
if (gdbm_avail_block_valid_p (av_stk))
av_table_display (av_stk->av_table, av_stk->count, fp);
else
terror (_("invalid avail_block"));
temp = av_stk->next_block;
}
diff --git a/src/update.c b/src/update.c
index 905ba69..63c6c95 100644
--- a/src/update.c
+++ b/src/update.c
@@ -103,25 +103,25 @@ _gdbm_end_update (GDBM_FILE dbf)
GDBM_SET_ERRNO2 (dbf, GDBM_FILE_SEEK_ERROR, TRUE, GDBM_DEBUG_STORE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
}
rc = GDBM_DEBUG_OVERRIDE ("_gdbm_end_update:write-dir-failure",
_gdbm_full_write (dbf, dbf->dir, dbf->header->dir_size));
if (rc)
{
GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
"%s: error writing directory: %s",
dbf->name, gdbm_db_strerror (dbf));
- _gdbm_fatal (dbf, gdbm_strerror (rc));
+ _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
dbf->directory_changed = FALSE;
if (!dbf->header_changed && dbf->fast_write == FALSE)
__fsync (dbf);
}
/* Final write of the header. */
if (dbf->header_changed)
{
if (write_header (dbf))

Return to:

Send suggestions and report system problems to the System administrator.