Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 55552 invoked by uid 500); 1 May 2001 05:37:07 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 55525 invoked by uid 500); 1 May 2001 05:37:06 -0000 Delivered-To: apmail-apr-util-cvs@apache.org Date: 1 May 2001 05:37:06 -0000 Message-ID: <20010501053706.55520.qmail@apache.org> From: gstein@apache.org To: apr-util-cvs@apache.org Subject: cvs commit: apr-util/dbm/sdbm sdbm.c gstein 01/04/30 22:37:06 Modified: dbm/sdbm sdbm.c Log: *) fix bug in getnext(): it was possible for a chkpage() failure to drop out of the loop with "status" set to APR_SUCCESS. Rather than breaking from the loop, we just return the error condition immediately. *) tweak the ioerr() macro for proper binding precedence. *) remove some superfluous parens from the rdonly, error_get, and error_clear functions. change the return type of error_clear to void. fix the error_get declaration to return apr_status_t (rather than int). Revision Changes Path 1.16 +10 -11 apr-util/dbm/sdbm/sdbm.c Index: sdbm.c =================================================================== RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -u -r1.15 -r1.16 --- sdbm.c 2001/04/30 23:21:16 1.15 +++ sdbm.c 2001/05/01 05:37:05 1.16 @@ -89,7 +89,7 @@ #define bad(x) ((x).dptr == NULL || (x).dsize <= 0) #define exhash(item) sdbm_hash((item).dptr, (item).dsize) -#define ioerr(db,stat) ((db)->status = stat) +#define ioerr(db,stat) ((db)->status = (stat)) /* ### Does anything need these externally? */ #define sdbm_dirfno(db) ((db)->dirf) @@ -641,34 +641,33 @@ apr_off_t off = OFF_PAG(db->blkptr); if ((status = apr_file_seek(db->pagf, APR_SET, &off) != APR_SUCCESS)) - break; + return ioerr(db, status); } db->pagbno = db->blkptr; /* ### EOF acceptable here too? */ if ((status = apr_file_read_full(db->pagf, db->pagbuf, PBLKSIZ, NULL)) != APR_SUCCESS) - break; + return ioerr(db, status); if (!chkpage(db->pagbuf)) - break; + return ioerr(db, APR_EGENERAL); /* ### need better error */ } - - ioerr(db, status); - return status; + + /* NOTREACHED */ } int apr_sdbm_rdonly(apr_sdbm_t *db) { - return ((db)->flags & SDBM_RDONLY); + return (db->flags & SDBM_RDONLY) != 0; } apr_status_t apr_sdbm_error_get(apr_sdbm_t *db) { - return ((db)->status); + return db->status; } -int apr_sdbm_error_clear(apr_sdbm_t *db) +void apr_sdbm_error_clear(apr_sdbm_t *db) { - return ((db)->status = APR_SUCCESS); + db->status = APR_SUCCESS; }