[Nagiosplug-devel] max_state logic?

Thomas Guyot-Sionnest dermoth at aei.ca
Wed Sep 19 09:13:27 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

I was trying to replicate max_state from utils.c in Perl, but the logic
there seems broken:

int
max_state (int a, int 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);
}

Given that, OK + UNKNOWN or OK + DEPENDENT will always return OK. Is
that right? IMO the OK test should be moved at the end.

Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG8MwX6dZ+Kt5BchYRAujPAJ0RXtQI9kQqaMv//OwYmOJdm7fuyQCg8pEl
gibuZDTBAx+41rBiDYPhtDQ=
=uWfB
-----END PGP SIGNATURE-----




More information about the Devel mailing list