aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-18 07:22:28 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-18 07:22:28 +0000
commit57c32f34730554dcd7ccd8e0e1f9c9e40bfb325a (patch)
tree90b4133b278d178fde5eeb7a41e31a5afcfa8ef1 /plugins/utils.c
parentc953de7d1c4775d73e4798a09d6bc40a3e2b2815 (diff)
downloadmonitoring-plugins-57c32f34730554dcd7ccd8e0e1f9c9e40bfb325a.tar.gz
more readable max_state() code
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@207 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 10d544c4..da9ccedd 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -60,8 +60,8 @@ char *strpcat (char *dest, const char *src, const char *str);
#define max(a,b) ((a)>(b))?(a):(b)
/* **************************************************************************
- * max_state(result, STATE_x)
- * compares STATE_x to result and returns result if STATE_x is less than a based on the following
+ * max_state(STATE_x, STATE_y)
+ * compares STATE_x to STATE_y and returns result based on the following
* STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL
*
* Note that numerically the above does not hold
@@ -70,31 +70,18 @@ char *strpcat (char *dest, const char *src, const char *str);
int
max_state(int a, int b)
{
- if(a == STATE_CRITICAL){
- return a;
- }
- else if (a == STATE_WARNING) {
-
- if (b == STATE_CRITICAL){
- return b;
- }else {
- return a;
- }
- }
- else if (a == STATE_OK) {
-
- if ( b== STATE_CRITICAL || b == STATE_WARNING) {
- return b;
- }else{
- return a;
- }
- }
- else {
- /* a == UNKNOWN */
- return b;
- }
-
-
+ if (a == STATE_CRITICAL || b == STATE_CRITICAL)
+ return STATE_CRITICAL;
+ else if (a == STATE_WARNING || b == STATE_WARNING)
+ return STATE_WARNING;
+ else if (a == STATE_OK || b == STATE_OK)
+ return STATE_OK;
+ else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
+ return STATE_UNKNOWN;
+ else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
+ return STATE_DEPENDENT;
+ else
+ return max (a, b);
}
char *