aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
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 *