From 1cc97f6c01e0d1cb8006fce4198c82ec0efb763e Mon Sep 17 00:00:00 2001 From: Sevinj Aghayeva Date: Fri, 15 Apr 2022 00:03:12 -0400 Subject: mbuto: add a function to find the difference of two lists Add a function to find the difference of two lists and use that function to determine the list of missing modules. Signed-off-by: Sevinj Aghayeva --- mbuto | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/mbuto b/mbuto index 2c39942..a7babfd 100755 --- a/mbuto +++ b/mbuto @@ -245,15 +245,8 @@ profile_kselftests() { KMODS="$(${BASENAME} -a -s .ko ${KMODS})" - __kmods_missing= - for __n in ${__kmods_needed}; do - __found=0 - for __f in ${KMODS}; do - [ ${__n} = ${__f} ] && __found=1 - done - [ ${__found} -eq 0 ] && \ - __kmods_missing="${__n} ${__kmods_missing}" - done + __kmods_missing=$(list_diff "${__kmods_needed}" "${KMODS}") + if [ ! -z "${__kmods_missing}" ]; then notice "WARNING: missing modules: ${__kmods_missing}" fi @@ -426,6 +419,21 @@ workers() { while ! ${RMDIR} "${__sync_dir}" 2>/dev/null; do ${SLEEP} 1; done } +# list_diff() - Given two lists, $1 and $2, print tokens from $1 not in $2 +# $1: List with elements to be checked +# $2: List to check against +list_diff() { + __diff= + for __e1 in ${1}; do + __found=0 + for __e2 in ${2}; do + [ ${__e1} = ${__e2} ] && __found=1 + done + [ ${__found} -eq 0 ] && __diff="${__e1} ${__diff}" + done + printf '%s' "${__diff}" +} + ################################################################################ -- cgit v1.2.3