chk.flags   [plain text]


#!/bin/sh -
#
# $Id: chk.flags,v 1.2 2004/03/30 01:24:43 jtownsen Exp $
#
# Check flag name-spaces.

d=../..

t1=__1

echo ===============================================
echo Checking for DB_ENV flags.
echo ===============================================
# Check for DB_ENV flags.
(grep 'F_ISSET([^ ]*dbenv,' $d/*/*.[chys];
 grep 'F_SET([^ ]*dbenv,' $d/*/*.[chys];
 grep 'F_CLR([^ ]*dbenv,' $d/*/*.[chys]) |
 sed -e '/DB_ENV_/d' \
     -e '/env_method.c.*mapped_flag/d' \
     -e '/F_SET([^ ]*dbenv, db_env_reset)/d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

grep 'DB_ENV_' $d/*/*.c |
sed -e '/F_.*dbenv,/d' \
    -e '/env_method.c.*outflagsp,/d' \
    -e '/DB_ENV_TEST_RECOVERY(.*DB_TEST_/d' \
    -e '/\/libdb_java\//d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

echo ===============================================
echo Checking for DB flags.
echo ===============================================
# Check for DB flags.
(grep 'F_ISSET([^ ]*dbp,' $d/*/*.[chys];
 grep 'F_SET([^ ]*dbp,' $d/*/*.[chys];
 grep 'F_CLR([^ ]*dbp,' $d/*/*.[chys]) |
 sed -e '/DB_AM_/d' \
     -e '/db_method.c.*mapped_flag/d' \
     -e '/db.c:.*F_SET.*F_ISSET(subdbp,/d' \
     -e '/db.c:.*F_ISSET(dbp,/d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

grep 'DB_AM_' $d/*/*.c |
sed -e '/F_.*dbp/d' \
    -e '/F_.*db_rep->rep_db,/d' \
    -e '/"DB->open", dbp->flags, DB_AM_DUP,/d' \
    -e '/"DB_NODUPDATA" behavior for databases with/d' \
    -e '/If DB_AM_OPEN_CALLED is not set, then we/d' \
    -e '/This was checked in set_flags when DB_AM_ENCRYPT/d' \
    -e '/XA_ABORT, we can safely set DB_AM_RECOVER/d' \
    -e '/ DB_AM_RECNUM\./d' \
    -e '/ DB_AM_RECOVER set\./d' \
    -e '/isdup = dbp->flags & DB_AM_DUP/d' \
    -e '/otherwise we simply do/d' \
    -e '/pginfo/d' \
    -e '/_method.c.*outflagsp,/d' \
    -e '/setting DB_AM_RECOVER, we guarantee that we don/d' \
    -e '/the DB_AM_SWAP flag.  However, we use/d' \
    -e '/DB_AM_RECOVER bit in this handle, so that the/d' \
    -e '/:[	 {]*DB_AM_/d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

echo ===============================================
echo Checking for DBC flags.
echo ===============================================
# Check for DBC flags.
(grep 'F_ISSET([^ ]*dbc,' $d/*/*.[chys];
 grep 'F_SET([^ ]*dbc,' $d/*/*.[chys];
 grep 'F_CLR([^ ]*dbc,' $d/*/*.[chys]) |
 sed -e '/DBC_/d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

grep 'DBC_' $d/*/*.c |
sed -e '/F_.*dbc/d' \
    -e '/DBC_INTERNAL/d' \
    -e '/DBC_LOGGING/d' \
    -e '/Do the actual get.  Set DBC_TRANSIENT/d' \
    -e '/If DBC_WRITEDUP is set, the cursor is an in/d' \
    -e '/The DBC_TRANSIENT flag indicates that we/d' \
    -e '/This function replaces the DBC_CONTINUE and DBC_KEYSET/d' \
    -e '/dbc_n->flags .. dbc_orig->flags . .DBC_OWN_LID/d' \
    -e '/db_cam.c:.*F_CLR(opd, DBC_ACTIVE);/d' \
    -e '/{ DBC_/d' > $t1
[ -s $t1 ] && {
	cat $t1
	exit 1
}

echo ===============================================
echo Checking macros.
echo ===============================================
# Check for bad use of macros.
egrep 'case .*F_SET\(|case .*F_CLR\(' $d/*/*.c > $t1
egrep 'for .*F_SET\(|for .*F_CLR\(' $d/*/*.c >> $t1
egrep 'if .*F_SET\(|if .*F_CLR\(' $d/*/*.c >> $t1
egrep 'switch .*F_SET\(|switch .*F_CLR\(' $d/*/*.c >> $t1
egrep 'while .*F_SET\(|while .*F_CLR\(' $d/*/*.c >> $t1
[ -s $t1 ] && {
	echo 'if statement followed by non-test macro'
	cat $t1
	exit 1
}

exit 0