Hi Lichen,
On Wed, Oct 25, 2023 at 10:36 AM Lichen Liu <lichliu(a)redhat.com> wrote:
check_*_modified will be executed in order, but when the previous return value
is not 0, the remaining checks will not be executed. is_system_modified will
return immediately if the previous check returns 1, regardless of whether the
remaining checks return 2. However, if the return value is 2, it means an error
has occurred, and kdumpctl should not continue execution.
Frankly, I spend quite a while trying to understand what you want to
do. To be short, what you want to solve is, check and return any
config error prior to check config modified. So please rephrase your
commit log to make it clearer.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
kdumpctl | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 01433e2..7efaf78 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -605,6 +605,7 @@ check_fs_modified()
is_system_modified()
{
local ret
+ local max_ret=0
[[ -f $TARGET_INITRD ]] || return 1
@@ -617,9 +618,15 @@ is_system_modified()
fi
fi
- check_files_modified || return
- check_fs_modified || return
- check_drivers_modified
+ for _func in check_files_modified check_fs_modified check_drivers_modified; do
+ $_func
+ ret=$?
+ if [[ $ret -eq 2 ]]; then
+ return 2
+ fi
+ max_ret=$((max_ret > ret ? max_ret : ret))
+ done
+ return $max_ret
}
Personally I don't like "max_ret", which is misleading. 2, which
happens to be the max value to represent config error. Could this be
better?
local CONF_ERROR=2
local CONF_MODIFY=1
local CONF_NO_MODIFY=0
local conf_status=$CONF_NO_MODIFY
for _func in check_files_modified check_fs_modified
check_drivers_modified; do
$_func
ret=$?
[[ $ret -eq "$CONF_ERROR" ]] && return "$ret"
[[ $ret -eq "$CONF_MODIFY" ]] && {
conf_status="$CONF_MODIFY"; }
done
return $conf_status
# need_initrd_rebuild - check whether the initrd needs to be rebuild
--
2.41.0
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Do not reply to spam, report it:
https://pagure.io/fedora-infrastructure/new_issue