Refactor: libcrmcomon: New pcmk__xe_get_int()
To replace crm_element_value_int().
Note that, like the other recently added getter functions, this leaves
dest unchanged on error. crm_element_value_int() set dest to -1.
This should indirectly improve some of the callers, which were not
error-checking crm_element_value_int()'s return code and simply assumed
the value was valid and not -1.
And IMO, it's better not to log errors or warnings within the getter
function as crm_element_value_int() was doing. The caller has more
context and can log errors or warnings if appropriate. Sometimes, a
parse failure may be expected as a legitimate possibility.
The one case I found questionable was the getting of PCMK__XA_ST_DELAY
in create_remote_stonith_op(). If that value is set to -1, then all
delays are disabled. crm_element_value_int() sets the value to -1 upon a
parse error, and this function was not doing any error checking before
now. So I wondered if we were relying on the parse error defaulting to
-1.
However, I don't think it's a problem. It looks like that attribute is
only ever getting set by crm_xml_add_int() -- so even if it's set based
on user input, it's set to a valid integer. The -1 value seems to be
intended only for when it's set explicitly to -1. We simply haven't
error-checked the parsing before now.
See commit a0cbd527 and associated commits in PR #2027.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>