HomeClusterLabs Projects

Refactor: libcrmcommon: New pcmk__parse_ms()
fac495fafc62Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Refactor: libcrmcommon: New pcmk__parse_ms()

To replace crm_get_msec().

There are a lot of parsing improvements that would be welcome (see
T841), but we'll have to be careful about making them. We're parsing
user inputs with this function. So changing how we respond to invalid
values, values that contain some garbage at the end, etc., affects user-
facing behavior, even though the function is internal.

This function basically preserves existing behavior for now, including
that it doesn't yet allow negative values. One key difference is that we
no longer use PCMK__PARSE_INT_DEFAULT inside it in any way. The output
argument (dest) remains unchanged if there is any error besides ERANGE.

Also improve unit tests for overflow, and add a test for negative input
that doesn't overflow.

Ref T841

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mar 20 2025, 11:49 PM
Parents
rP4fc679137510: Test: libcrmcommon: Trigger overflow properly for crm_get_msec()
Branches
Unknown
Tags
Unknown

Event Timeline