Skip to content

Commit 6f791c6

Browse files
committed
Refactor: libcrmcommon: Unindent decode_transition_magic()
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent f27b8fd commit 6f791c6

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

lib/common/actions.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,11 @@ decode_transition_magic(const char *magic, char **uuid, int *transition_id, int
391391
{
392392
int res = 0;
393393
char *key = NULL;
394-
gboolean result = TRUE;
394+
bool result = false;
395395
int local_op_status = -1;
396396
int local_op_rc = -1;
397397

398-
CRM_CHECK(magic != NULL, return FALSE);
398+
CRM_CHECK(magic != NULL, goto done);
399399

400400
#ifdef HAVE_SSCANF_M
401401
res = sscanf(magic, "%d:%d;%ms", &local_op_status, &local_op_rc, &key);
@@ -407,22 +407,28 @@ decode_transition_magic(const char *magic, char **uuid, int *transition_id, int
407407
if (res == EOF) {
408408
pcmk__err("Could not decode transition information '%s': %s", magic,
409409
pcmk_rc_str(errno));
410-
result = FALSE;
411-
} else if (res < 3) {
410+
goto done;
411+
}
412+
413+
if (res < 3) {
412414
pcmk__warn("Transition information '%s' incomplete (%d of 3 expected "
413415
"items)",
414416
magic, res);
415-
result = FALSE;
416-
} else {
417-
if (op_status) {
418-
*op_status = local_op_status;
419-
}
420-
if (op_rc) {
421-
*op_rc = local_op_rc;
422-
}
423-
result = decode_transition_key(key, uuid, transition_id, action_id,
424-
target_rc);
417+
goto done;
418+
}
419+
420+
if (op_status != NULL) {
421+
*op_status = local_op_status;
422+
}
423+
424+
if (op_rc != NULL) {
425+
*op_rc = local_op_rc;
425426
}
427+
428+
result = decode_transition_key(key, uuid, transition_id, action_id,
429+
target_rc);
430+
431+
done:
426432
free(key);
427433
return result;
428434
}

0 commit comments

Comments
 (0)