All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mbuto: add a function to find the difference of two lists
@ 2022-04-15  4:03 Sevinj Aghayeva
  2022-04-15 15:10 ` Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: Sevinj Aghayeva @ 2022-04-15  4:03 UTC (permalink / raw)
  To: sbrivio; +Cc: outreachy

Adds 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 <sevinj.aghayeva@gmail.com>
---
 mbuto | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/mbuto b/mbuto
index 74c81eb..14176c3 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,22 @@ workers() {
 	while ! ${RMDIR} "${__sync_dir}" 2>/dev/null; do ${SLEEP} 1; done
 }
 
+# list_diff() - Given two lists, $1 and $2, returns the tokens that exist in $1
+# but not in $2
+# $1: list
+# $2: list
+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}"
+}
+
 ################################################################################
 
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-15 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-15  4:03 [PATCH] mbuto: add a function to find the difference of two lists Sevinj Aghayeva
2022-04-15 15:10 ` Stefano Brivio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.