Commit 8045b027 authored by miller86's avatar miller86

Adding a hook to check code for calls to abort, exit and/or assert.

Only gets triggered for files committed to trunk.

Qualified a number of uses of abort, exit and/or assert that are
considered 'ok'.

Removing hook to check autoconf version number.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@15183 18c085ea-50e0-402c-830e-de6fd14e8384
parent 15bcac98
......@@ -137,7 +137,7 @@ static map<int, bool> childDied;
static void
catch_dead_child(int sig)
{
// assert (sig == SIGCHLD);
// assert (sig == SIGCHLD); HOOKS_IGNORE
int status;
int pid;
pid = wait(&status);
......@@ -2140,7 +2140,7 @@ RemoteProcess::LaunchRemote(bool useGateway, const std::string &gatewayHost,
{
case -1:
// Could not fork.
exit(-1);
exit(-1); // HOOKS_IGNORE
break;
case 0:
// Do not close stdout, stderr, because ssh will fail if
......@@ -2152,7 +2152,7 @@ RemoteProcess::LaunchRemote(bool useGateway, const std::string &gatewayHost,
}
execvp(SecureShell(), argv);
close(0); close(1); close(2);
exit(-1);
exit(-1); // HOOKS_IGNORE
break; // OCD
default:
break;
......@@ -2270,7 +2270,7 @@ RemoteProcess::LaunchLocal(const stringVector &args)
{
case -1:
// Could not fork.
exit(-1);
exit(-1); // HOOKS_IGNORE
break;
case 0:
// Close stdin and any other file descriptors.
......@@ -2289,7 +2289,7 @@ RemoteProcess::LaunchLocal(const stringVector &args)
cerr << argv[i] << " ";
cerr << endl;
}
exit(-1);
exit(-1); // HOOKS_IGNORE
break; // OCD
default:
break;
......
......@@ -74,7 +74,7 @@ ExprParser::ExprParser(ExprNodeFactory *f) : Parser(), factory(f)
if (!G->Initialize())
{
cerr << "Error in initializion of Expression Grammar!\n";
exit(-1);
exit(-1); // HOOKS_IGNORE
}
SetGrammar(G);
......
......@@ -59,7 +59,7 @@
int
main(int argc, char *argv[])
{
if (argc<2) {cerr<<"needs an argument\n"; exit(-1);}
if (argc<2) {cerr<<"needs an argument\n"; exit(-1);} // HOOKS_IGNORE
Parser *parser = new ExprParser(new ExprNodeFactory());
ExprParser::SetErrorMessageTarget(ExprParser::EMT_CONSOLE);
......
......@@ -160,36 +160,36 @@ signalhandler_core(int sig)
{
case SIGILL:
debug1 << "signalhandler_core: SIG!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGABRT:
debug1 << "signalhandler_core: SIGBRT!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGFPE:
debug1 << "signalhandler_core: SIGFPE!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGSEGV:
debug1 << "signalhandler_core: SIGSEGV!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
#if !defined(_WIN32)
case SIGBUS:
debug1 << "signalhandler_core: SIGBUS!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGQUIT:
debug1 << "signalhandler_core: SIGQUIT!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGTRAP:
debug1 << "signalhandler_core: SIGTRAP!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
case SIGSYS:
debug1 << "signalhandler_core: SIGSYS!" << endl;
close_streams(); abort();
close_streams(); abort(); // HOOKS_IGNORE
break;
#endif
}
......@@ -228,11 +228,11 @@ signalhandler_exit(int sig)
{
case SIGTERM:
debug1 << "signalhandler_exit: SIGTERM!" << endl;
close_streams(); exit(-1);
close_streams(); exit(-1); // HOOKS_IGNORE
break;
case SIGINT:
debug1 << "signalhandler_exit: SIGINT!" << endl;
close_streams(); exit(-1);
close_streams(); exit(-1); // HOOKS_IGNORE
break;
}
}
......
......@@ -134,7 +134,7 @@ static void
NewHandler(void)
{
debug1 << "This component has run out of memory." << endl;
abort();
abort(); // HOOKS_IGNORE
}
// ****************************************************************************
......@@ -352,7 +352,7 @@ VisItInit::Initialize(int &argc, char *argv[], int r, int n, bool strip, bool si
cerr << "SVN revision is unknown!" << endl;
else
cerr << "Built from revision " << visitcommon::SVNVersion() << endl;
exit(0);
exit(0); // HOOKS_IGNORE
}
}
......
......@@ -77,7 +77,7 @@ Dictionary::AddTerminal(Symbol *s)
if (nsymbols > MAXSYMBOLS)
{
cerr << "Too many symbols! Increase MAXSYMBOLS" << endl;
exit(-1);
exit(-1); // HOOKS_IGNORE
}
allterminals[s->GetTerminalType()] = s;
return index;
......@@ -103,7 +103,7 @@ Dictionary::AddNonTerminal(Symbol *s)
if (nsymbols > MAXSYMBOLS)
{
cerr << "Too many symbols! Increase MAXSYMBOLS" << endl;
exit(-1);
exit(-1); // HOOKS_IGNORE
}
allnonterminals[s->GetDisplayString()] = s;
return index;
......
......@@ -325,7 +325,7 @@ class TestParser : public Parser
int
main(int argc, char *argv[])
{
if (argc<2) {cerr<<"needs an argument\n"; exit(-1);}
if (argc<2) {cerr<<"needs an argument\n"; exit(-1);} // HOOKS_IGNORE
Parser *parser = new TestParser();
......
......@@ -78,7 +78,7 @@ TestUtil::TestUtil(int argc, char *argv[],
cout << "usage: " << argv[0] << " [-v] [-help]" << endl;
cout << " -v = print verbose output" << endl;
cout << " -help = print usage and exit" << endl;
exit(0);
exit(0); // HOOKS_IGNORE
}
}
......
......@@ -102,7 +102,7 @@ int main(int argc, char **argv)
const std::string spaces = "/spaces/in the/path";
std::string s = lgl_one + ":" + lgl + ":" + abs + ":" + spaces;
std::vector<std::string> splitstr = split(s, ':');
assert(splitstr.size() == 4);
assert(splitstr.size() == 4); // HOOKS_IGNORE
if(splitstr[0] != lgl_one) { falseNegatives.push_back(__LINE__); }
if(splitstr[1] != lgl) { falseNegatives.push_back(__LINE__); }
if(splitstr[2] != abs) { falseNegatives.push_back(__LINE__); }
......@@ -115,12 +115,12 @@ int main(int argc, char **argv)
{
std::string s = "::::";
std::vector<std::string> splitstr = split(s, ':');
assert(splitstr.size() == 4);
assert(splitstr.size() == 4); // HOOKS_IGNORE
}
{
std::string s = "a:b:c:";
std::vector<std::string> splitstr = split(s, ':');
assert(splitstr.size() == 3);
assert(splitstr.size() == 3); // HOOKS_IGNORE
if(splitstr[0] != "a") { falsePositives.push_back(__LINE__); }
if(splitstr[1] != "b") { falsePositives.push_back(__LINE__); }
if(splitstr[2] != "c") { falsePositives.push_back(__LINE__); }
......@@ -128,7 +128,7 @@ int main(int argc, char **argv)
{
std::string no_colon = "test";
std::vector<std::string> splitstr = split(no_colon, ':');
assert(splitstr.size() == 1);
assert(splitstr.size() == 1); // HOOKS_IGNORE
if(splitstr[0] != no_colon) { falsePositives.push_back(__LINE__); }
}
......
......@@ -65,11 +65,11 @@ int main( int argc, char **argv )
catch (const char *s)
{
cerr << "ERROR: " << s << endl;
exit(-1);
exit(-1); // HOOKS_IGNORE
}
catch (const QString &s)
{
cerr << "ERROR: " << s << endl;
exit(-1);
exit(-1); // HOOKS_IGNORE
}
}
......@@ -2249,7 +2249,7 @@ Engine::AlarmHandler(int signal)
#ifdef PARALLEL
PAR_Exit();
#endif
exit(0);
exit(0); // HOOKS_IGNORE
}
// ****************************************************************************
......@@ -2281,9 +2281,8 @@ Engine::NewHandler(void)
#ifdef PARALLEL
MPI_Abort(VISIT_MPI_COMM, 18);
#else
abort();
abort(); // HOOKS_IGNORE
#endif
}
// ****************************************************************************
......
......@@ -420,7 +420,7 @@ GUI_LogQtMessages(QtMsgType type, const char *msg)
break;
case QtFatalMsg:
debug1 << "Qt: Fatal: " << msg << endl;
abort();
abort(); // HOOKS_IGNORE
break;
}
}
......
......@@ -522,7 +522,7 @@ LauncherApplication::AlarmHandler(int)
{
debug1 << "Launcher exited due to an inactivity timeout of "
<< LauncherApplication::Instance()->timeout << " minutes." << endl;
exit(0);
exit(0); // HOOKS_IGNORE
}
// ****************************************************************************
......@@ -821,7 +821,7 @@ LauncherApplication::SetupGatewaySocketBridgeIfNeeded(stringVector &launchArgs,
{
case -1:
// Could not fork.
exit(-1);
exit(-1); // HOOKS_IGNORE
break;
case 0:
{
......@@ -833,7 +833,7 @@ LauncherApplication::SetupGatewaySocketBridgeIfNeeded(stringVector &launchArgs,
close(k);
}
CreateSocketBridge((void*)ports);
exit(0);
exit(0); // HOOKS_IGNORE
break;
}
default:
......@@ -947,14 +947,14 @@ LauncherApplication::LaunchProcess(const stringVector &origLaunchArgs)
// Create a pipe.
int f_des[2];
if(pipe(f_des) == -1)
exit(-1);
exit(-1); // HOOKS_IGNORE
#endif
switch (remoteProgramPid = fork())
{
case -1:
// Could not fork.
exit(-1);
exit(-1); // HOOKS_IGNORE
break;
case 0:
// Close stdin and any other file descriptors.
......@@ -974,7 +974,7 @@ LauncherApplication::LaunchProcess(const stringVector &origLaunchArgs)
if (remoteProgram.size() > 0 && remoteProgram[0] == '~')
remoteProgram = ExpandUserPath(remoteProgram);
execvp(remoteProgram.c_str(), args);
exit(-1);
exit(-1); // HOOKS_IGNORE
break; // OCD
default:
#ifdef CAPTURE_CHILD_OUTPUT
......
......@@ -63,7 +63,7 @@ int main(int argc, const char* argv[])
if (argc != 3)
{
std::cerr << "Error: Usage " << argv[0] << " <remoteHost> <remotePort>" << std::endl;
exit(1);
exit(1); // HOOKS_IGNORE
}
const char *remoteHost = argv[1];
......@@ -82,7 +82,7 @@ int main(int argc, const char* argv[])
{
case -1:
// Could not fork.
exit(-1);
exit(-1); // HOOKS_IGNORE
break;
case 0:
{
......@@ -95,7 +95,7 @@ int main(int argc, const char* argv[])
}
SocketBridge bridge(newlocalport, remotePort, remoteHost);
bridge.Bridge();
exit(0);
exit(0); // HOOKS_IGNORE
break;
}
default:
......
......@@ -151,7 +151,7 @@ MDServerApplication::AlarmHandler(int signal)
{
debug1 << "MDSERVER exited due to an inactivity timeout of "
<< MDServerApplication::Instance()->timeout << " minutes." << endl;
exit(0);
exit(0); // HOOKS_IGNORE
}
// ****************************************************************************
......
......@@ -135,7 +135,7 @@ InitialConnectionHandler(int)
debug1 << "MDSERVER: Could not connect to client in allotted time. "
"The client may no longer wish to connect so this program "
"will exit." << endl;
exit(0);
exit(0); // HOOKS_IGNORE
}
#endif
......
#!/bin/sh
##############################################################################
#
# Purpose: Check for existence of abort and the like in source files
#
# Programmer: Mark C. Miller
# Created: Wed Jun 22 09:57:42 PDT 2011
#
##############################################################################
REPOS="$1"
TXN="$2"
FLIST="$3"
while read fline; do
#
# Get file 'svnlook' status and name
#
fstat=`echo $fline | tr -s ' ' | cut -d' ' -f1`
fname=`echo $fline | tr -s ' ' | cut -d' ' -f2`
#
# Skip common cases of deletions, dirs, non-text files
#
if `HandleCommonSkipCases $fstat $fname`; then
continue
fi
#
# Note to developers: Before adding skip cases to this case statement,
# which have the effect of eliminating the whole file from consideration,
# consider qualifying calls my modifying the source code with
# '// HOOKS_IGNORE' comment immediately following a call you think should
# be permitted. The grep, below, eliminates those cases from consideration.
#
case $fname in
trunk/*)
# Do not skip (continue) these
;;
*/tools/*)
# Skip anything in tools directory
continue
;;
*)
# Skip anything not on trunk
continue
;;
esac
svnlook cat -t $TXN $REPOS $fname | grep -v '^#[[:space:]]*include' | grep -v HOOKS_IGNORE | cpp - 2>&1 | grep -q '[[:space:]]\(assert\|abort\|exit\)[[:space:]]*(' 1>/dev/null 2>&1
commitFileAbortCalls=$?
# If the file we're committing has #warnings, reject it
if test $commitFileAbortCalls -eq 0; then
log "File \"$fname\" appears to contain assert()/abort()/exit() calls"
log " outside of a conditional #ifdef DEBUG block."
log "Please remove them before committing."
exit 1
fi
done < $FLIST
# all is well!
exit 0
#!/bin/sh
##############################################################################
#
# Purpose: Check that configure.in/configure always get updated together.
# Also, check that correct version of autoconf was used to
# generate configure.
#
# Programmer: Mark C. Miller
# Created: Mon Apr 7 18:16:51 PDT 2008
#
# Modifications:
#
# Tom Fogal, Tue Jun 24 11:55:51 EDT 2008
# Added a bypass/allow for modifying configure if you've modified any m4
# files. Also, 's/\t/\ \ \ \ /g'
#
# Mark C. Miller, Tue Nov 18 18:22:40 PST 2008
# Fixed typo in logic involving || for $m4_file
#
# Mark C. Miller, Mon Dec 8 12:51:21 PST 2008
# Fixed typo in logic involving && for $m4_file
#
# Mark C. Miller, Tue Dec 9 00:19:04 PST 2008
# Obtain list of changed files via FLIST ($3) argument and loop
# over them via 'read' sh builtin method.
#
# Mark C. Miller, Tue Dec 9 23:08:23 PST 2008
# Adjusted file loop to deal with fact that FLIST file now contains
# both status chars and filename. Replaced ${<VARNAME>} command refs
# with just the commands themselves.
#
# Mark C. Miller, Tue Mar 24 22:02:44 PDT 2009
# Changed logic to simply record the configure file in one variable
# and all other files that serve as input to configure in another
# variable.
#
# Tom Fogal, Sat Aug 22 16:21:30 MDT 2009
# Ignore the check on any of my branches.
#
##############################################################################
REPOS="$1"
TXN="$2"
FLIST="$3"
theConfigureFile=""
configureInputFiles=""
while read fline; do
#
# Get file 'svnlook' status and name
#
fstat=`echo $fline | tr -s ' ' | cut -d' ' -f1`
fname=`echo $fline | tr -s ' ' | cut -d' ' -f2`
#
# We're looking for only these specific files
# for this hook.
case $fname in
*fogal1*)
# nothing.
;;
*src/configure)
theConfigureFile=$fname
;;
*src/configure.in|*src/*m4|*src/ac/*)
configureInputFiles="$configureInputFiles $fname"
;;
esac
done < $FLIST
# Check that if any files that serve as input to configure are getting
# updated, then configure itself is also getting updated.
if test -n "$configureInputFiles" && test -z "$theConfigureFile"; then
log "Attempt to commit changes to $configureInputFiles"
log "without also committing changes to \"configure\""
exit 1
fi
# Check that if configure itself is getting updated, then at least
# one of the files it depends on is also getting updated.
if test -z "$configureInputFiles" && test -n "$theConfigureFile"; then
log "Attempt to commit changes to $theConfigureFile"
log "without also committing changes to any of its input files."
exit 1
fi
# get and check autoconf version number
if test -n "$theConfigureFile"; then
acVno=`svnlook cat -t $TXN $REPOS $theConfigureFile | grep 'Generated by GNU Autoconf' | tr -s ' ' | cut -d' ' -f6 | cut -d'.' -f1,2`
if test "$acVno" != "$AUTOCONF_VERSION_NUMBER"; then
log "You must use autoconf version $AUTOCONF_VERSION_NUMBER to re-generate configure."
log "You have used $acVno"
exit 1
fi
fi
# all is well!
exit 0
......@@ -18,7 +18,6 @@
export PATH=/bin:/usr/bin
export AUTOCONF_VERSION_NUMBER=2.59
export VISIT_GROUP_NAME=visitdev
export hadError=0
......
......@@ -88,9 +88,6 @@ svnlook changed -t $TXN $REPOS > ${FLIST}
# Until we have time to make it a bit smarter, we're disabling that test.
#runhook_py "exceptions.py"
# Check that we're using correct versin of autoconf
runhook_sh "check_autoconf_version.sh"
# Check that we're not adding tabs to files
runhook_sh "count_tabs.sh"
......@@ -100,6 +97,9 @@ runhook_sh "check_dos.sh"
# Check for #warning compiler directives
runhook_sh "check_pound_warning.sh"
# Check for assert/abort/exit calls
runhook_sh "check_abort_calls.sh"
# Clean up
rm -f ${FLIST}
......
......@@ -6624,12 +6624,12 @@ PthreadCreate(pthread_t *new_thread_ID, const pthread_attr_t *attr,
if (!new_thread_ID)
{
printf("TID cannot be NULL.\n");
abort();
abort(); // ABORT_HOOK_OK
}
if (err = pthread_create(new_thread_ID, attr, start_func, arg))
{
printf("%s\n", strerror(err));
abort();
abort(); // ABORT_HOOK_OK
}
}
#endif
......@@ -6657,7 +6657,7 @@ PthreadAttrInit(pthread_attr_t *attr)
if (err = pthread_attr_init(attr))
{
printf("%s\n", strerror(err));
abort();
abort(); // ABORT_HOOK_OK
}
}
#endif
......
......@@ -84,7 +84,7 @@ Viewer_LogQtMessages(QtMsgType type, const char *msg)
break;
case QtFatalMsg:
debug1 << "Qt: Fatal: " << msg << endl;
abort();
abort(); // HOOKS_IGNORE
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment