aboutsummaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-09 11:40:19 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-09 12:11:20 +0300
commite8cad816f36b1cad11bb67c96f0ce878cf30844e (patch)
treec971d9de6369f9e340a3764d848c24d4a2ce96e8 /compat
parent0eafbb93c82a489204f54259593f2aaeb9cdbfc4 (diff)
downloadgdbm-e8cad816f36b1cad11bb67c96f0ce878cf30844e.tar.gz
gdbm-e8cad816f36b1cad11bb67c96f0ce878cf30844e.tar.bz2
Don't bail out on fatal errors, unless the user defines the fatal_err function
* src/bucket.c (_gdbm_get_bucket) (_gdbm_split_bucket, _gdbm_write_bucket): Return error code. All callers updated. * src/proto.h (_gdbm_get_bucket) (_gdbm_split_bucket, _gdbm_write_bucket): Update declarations * src/falloc.c (push_avail_block) (pop_avail_block): Return error code. All callers updated. * src/update.c (_gdbm_fatal): Exit only if the user defined fatal_err function. * src/gdbmerrno.c (gdbm_needs_recovery): New function. * src/gdbm.h.in (gdbm_needs_recovery): New proto. * compat/dbminit.c: Set gdbm_errno on fatal errors. * compat/dbmopen.c: Likewise. * src/findkey.c: Likewise. * src/gdbm_load.c: Likewise. * src/gdbmcount.c: Likewise. * src/gdbmdefs.h: Likewise. * src/gdbmdelete.c: Likewise. * src/gdbmdump.c: Likewise. * src/gdbmexists.c: Likewise. * src/gdbmexp.c: Likewise. * src/gdbmfetch.c: Likewise. * src/gdbmimp.c: Likewise. * src/gdbmload.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmreorg.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmsetopt.c: Likewise. * src/gdbmstore.c: Likewise. * src/gdbmsync.c: Likewise. * src/mmap.c: Likewise.
Diffstat (limited to 'compat')
-rw-r--r--compat/dbminit.c2
-rw-r--r--compat/dbmopen.c24
2 files changed, 13 insertions, 13 deletions
diff --git a/compat/dbminit.c b/compat/dbminit.c
index f5203d1..526410d 100644
--- a/compat/dbminit.c
+++ b/compat/dbminit.c
@@ -48,7 +48,7 @@ dbminit (char *file)
/* Did we successfully open the file? */
if (_gdbm_file == NULL)
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
return -1;
}
}
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
index af423df..f576b37 100644
--- a/compat/dbmopen.c
+++ b/compat/dbmopen.c
@@ -71,7 +71,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
if (fstat (pagfd, &pagst))
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1); /* FIXME: special code? */
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE); /* FIXME: special code? */
return -1;
}
@@ -89,14 +89,14 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
return pagfd;
else
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
return -1;
}
}
}
else
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, FALSE);
return -1;
}
}
@@ -104,7 +104,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
/* ok */;
else if (st.st_size != DEF_DIR_SIZE)
{
- gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, 1);
+ gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, FALSE);
return -1;
}
else
@@ -112,13 +112,13 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
fd = open (file_name, flags);
if (fd == -1)
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, FALSE);
return fd;
}
if (read (fd, dirbuf, sizeof (dirbuf)) != sizeof (dirbuf))
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, FALSE);
close (fd);
return -1;
}
@@ -135,7 +135,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
return fd;
}
close (fd);
- gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, 1);
+ gdbm_set_errno (NULL, GDBM_BAD_MAGIC_NUMBER, FALSE);
return -1;
}
}
@@ -151,7 +151,7 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
if (write (fd, dirbuf, sizeof (dirbuf)) != sizeof (dirbuf))
{
- gdbm_set_errno (NULL, GDBM_FILE_WRITE_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_WRITE_ERROR, FALSE);
close (fd);
fd = -1;
}
@@ -168,7 +168,7 @@ ndbm_open_dir_file (const char *base, int pagfd, int mode)
if (!file_name)
{
- gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, FALSE);
return -1;
}
fd = ndbm_open_dir_file0 (strcat (strcpy (file_name, base), DIRSUF),
@@ -212,7 +212,7 @@ dbm_open (char *file, int flags, int mode)
pag_file = (char *) malloc (strlen (file) + 5);
if (!pag_file)
{
- gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1); /* For the hell of it. */
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, FALSE); /* For the hell of it. */
return NULL;
}
@@ -250,7 +250,7 @@ dbm_open (char *file, int flags, int mode)
if (!dbm)
{
free (pag_file);
- gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, 1); /* For the hell of it. */
+ gdbm_set_errno (NULL, GDBM_MALLOC_ERROR, FALSE); /* For the hell of it. */
return NULL;
}
@@ -259,7 +259,7 @@ dbm_open (char *file, int flags, int mode)
/* Did we successfully open the file? */
if (dbm->file == NULL)
{
- gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, 1);
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, FALSE);
free (dbm);
dbm = NULL;
}

Return to:

Send suggestions and report system problems to the System administrator.