HomeClusterLabs Projects

Fix: crm_error: Handle negative return code arguments

Description

Fix: crm_error: Handle negative return code arguments

pcmkcmdlinepreproc() leaves "--" in the arg list. So does
g_option_context_parse_strv(), if a later argument starts with '-'.
So if a negative return code is passed as an argument, we get two
outputs: an "unknown error" from trying to parse the "--" as a return
code, and the real return code information.

$ crm_error -nr -- -1010
Unknown - Error
pcmk_rc_cib_modified - On-disk configuration was manually modified

Compare this to using a positive argument:

$ crm_error -nr -- 10
ECHILD - No child processes

The simple solution is to just skip the "--" if found.

This fixes a regression introduced by commit 3ae13d8.

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

Details

Provenance
nrwahl2Authored on Aug 27 2022, 6:05 AM
Parents
rP668597145605: Doc: libcrmcommon: Note pcmk__str_none in pcmk__strcmp doxygen comment
Branches
Unknown
Tags
Unknown