kdumpctl: cleanup 'start'

The function has many block of the kind

if ! cmd; then
  derror "Starting kdump: [FAILED]"
  return 1
fi

This duplicates code and makes the function hard to read. Thus move the
block to the calling function.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
Reviewed-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Philipp Rudo 2023-01-12 16:31:08 +01:00 committed by Coiby Xu
parent 0f6ad91be8
commit 33b307af20

View File

@ -986,46 +986,26 @@ check_final_action_config()
start() start()
{ {
if ! check_dump_feasibility; then check_dump_feasibility || return
derror "Starting kdump: [FAILED]" parse_config || return
return 1
fi
if ! parse_config; then
derror "Starting kdump: [FAILED]"
return 1
fi
if sestatus 2> /dev/null | grep -q "SELinux status.*enabled"; then if sestatus 2> /dev/null | grep -q "SELinux status.*enabled"; then
selinux_relabel selinux_relabel
fi fi
if ! save_raw; then save_raw || return
derror "Starting kdump: [FAILED]"
return 1
fi
if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && is_kernel_loaded "kdump"; then if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && is_kernel_loaded "kdump"; then
dwarn "Kdump already running: [WARNING]" dwarn "Kdump already running: [WARNING]"
return 0 return 0
fi fi
if ! check_and_wait_network_ready; then check_and_wait_network_ready || return
derror "Starting kdump: [FAILED]" check_rebuild || return
return 1 start_dump || return
fi
if ! check_rebuild; then
derror "Starting kdump: [FAILED]"
return 1
fi
if ! start_dump; then
derror "Starting kdump: [FAILED]"
return 1
fi
dinfo "Starting kdump: [OK]" dinfo "Starting kdump: [OK]"
return 0
} }
reload() reload()
@ -1697,7 +1677,10 @@ main()
case "$1" in case "$1" in
start) start)
start if ! start; then
derror "Starting kdump: [FAILED]"
exit 1
fi
;; ;;
stop) stop)
stop stop
@ -1722,7 +1705,10 @@ main()
;; ;;
restart) restart)
stop stop
start if ! start; then
derror "Starting kdump: [FAILED]"
exit 1
fi
;; ;;
rebuild) rebuild)
rebuild rebuild