From 1305dd66ab76f56900796544e4e3af8b64d638af Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 28 Dec 2009 20:57:49 +0100 Subject: [PATCH] db: avoid use of errno field name If errno is defined, then using errno as a field name can give strange effects. --- db.1.85/hash/hash.c | 14 +++++++------- db.1.85/hash/hash.h | 2 +- db.1.85/hash/ndbm.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db.1.85/hash/hash.c b/db.1.85/hash/hash.c index 4b7b732a..72007950 100644 --- a/db.1.85/hash/hash.c +++ b/db.1.85/hash/hash.c @@ -505,7 +505,7 @@ flush_meta(hashp) else if (wsize != sizeof(HASHHDR)) { errno = EFTYPE; - hashp->errno = errno; + hashp->_errno = errno; return (-1); } for (i = 0; i < NCACHED; i++) @@ -536,7 +536,7 @@ hash_get(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag) { - hashp->errno = errno = EINVAL; + hashp->_errno = errno = EINVAL; return (ERROR); } return (hash_access(hashp, HASH_GET, (DBT *)key, data)); @@ -553,11 +553,11 @@ hash_put(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_NOOVERWRITE) { - hashp->errno = errno = EINVAL; + hashp->_errno = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->_errno = errno = EPERM; return (ERROR); } return (hash_access(hashp, flag == R_NOOVERWRITE ? @@ -574,11 +574,11 @@ hash_delete(dbp, key, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_CURSOR) { - hashp->errno = errno = EINVAL; + hashp->_errno = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->_errno = errno = EPERM; return (ERROR); } return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL)); @@ -729,7 +729,7 @@ hash_seq(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_FIRST && flag != R_NEXT) { - hashp->errno = errno = EINVAL; + hashp->_errno = errno = EINVAL; return (ERROR); } #ifdef HASH_STATISTICS diff --git a/db.1.85/hash/hash.h b/db.1.85/hash/hash.h index 913e82b4..20636413 100644 --- a/db.1.85/hash/hash.h +++ b/db.1.85/hash/hash.h @@ -103,7 +103,7 @@ typedef struct htab { /* Memory resident data structure */ BUFHEAD *cpage; /* Current page */ int cbucket; /* Current bucket */ int cndx; /* Index of next item on cpage */ - int errno; /* Error Number -- for DBM + int _errno; /* Error Number -- for DBM * compatability */ int new_file; /* Indicates if fd is backing store * or no */ diff --git a/db.1.85/hash/ndbm.c b/db.1.85/hash/ndbm.c index 2cbbe913..5963d3c1 100644 --- a/db.1.85/hash/ndbm.c +++ b/db.1.85/hash/ndbm.c @@ -180,7 +180,7 @@ dbm_error(db) HTAB *hp; hp = (HTAB *)db->internal; - return (hp->errno); + return (hp->_errno); } extern int @@ -190,7 +190,7 @@ dbm_clearerr(db) HTAB *hp; hp = (HTAB *)db->internal; - hp->errno = 0; + hp->_errno = 0; return (0); } -- 2.11.4.GIT