diff options
author | knarf <knarf@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-12-03 04:41:30 +0000 |
---|---|---|
committer | knarf <knarf@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-12-03 04:41:30 +0000 |
commit | 20d0ca7a93ffe72dd8cd23223fc08c4bac934f43 (patch) | |
tree | 9e1a53e30068033309f5b701b3aa4be9da7b0ada /src | |
parent | a8569cd218d3d9aa7c690ad71a6ee9467fa0e1d4 (diff) |
Cactus allows for negative error level
Currently, Cactus allows to set a negative error level through the command line option. This leads to CCTK_WARN(0,"") not necessarily aborting. While this is not wrong by itself, a lot of code assumes an abort at that point.
This patch changes CCTKi_SetErrorLevel() to only accept non-negative error levels and to change the command-parsing code to give an error message for that case as well.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4923 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r-- | src/main/CommandLine.c | 12 | ||||
-rw-r--r-- | src/main/WarnLevel.c | 8 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/CommandLine.c b/src/main/CommandLine.c index 6b4b1f2e..82a118e5 100644 --- a/src/main/CommandLine.c +++ b/src/main/CommandLine.c @@ -379,7 +379,17 @@ void CCTKi_CommandLineErrorLevel (const char *argument) errorlevel = strtol (argument, &endptr, 10); if (endptr && *endptr == 0) { - CCTKi_SetErrorLevel (errorlevel); + if (errorlevel < 0) + { + CCTK_VWarn (0, __LINE__, __FILE__, "Cactus", + "Error level cannot be negative, but %d was requested.", + (int)errorlevel); + CCTK_Exit (NULL, 1); + } + else + { + CCTKi_SetErrorLevel (errorlevel); + } } else { diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c index 9e1cd221..52fa0f5a 100644 --- a/src/main/WarnLevel.c +++ b/src/main/WarnLevel.c @@ -1109,7 +1109,13 @@ int CCTKi_SetErrorLevel (int level) { int retval; - if (level <= warning_level) + if (level < 0) + { + CCTK_VWarn (3, __LINE__, __FILE__, "Cactus", + "Error level cannot be negative (%d requested)", level); + retval = 0; + } + else if (level <= warning_level) { if (error_level != level) { |