* [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
* Re: [PATCH] mbuto: add a function to find the difference of two lists
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
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2022-04-15 15:10 UTC (permalink / raw)
To: Sevinj Aghayeva; +Cc: outreachy
Applied, with a couple of minor changes:
On Fri, 15 Apr 2022 00:03:12 -0400
Sevinj Aghayeva <sevinj.aghayeva@gmail.com> wrote:
> Adds a function to find the difference of two lists and use that function to
Used imperative mood ("add") for consistency (with e.g. "use").
> determine the list of missing modules.
Wrapped this to 70 columns -- somewhat arbitrary, I don't even think
there's consensus on current kernel practices, somebody uses 72 or even
76 columns.
Rationale: allow email discussion at a reasonable thread depth without
further wrapping in a "small" terminal.
> 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
Imperative mode ("return" instead of "returns") for consistency, made
it a bit shorter so that it fits on one line (for readability).
> +# but not in $2
> +# $1: list
> +# $2: list
Tabs to separate, and a slightly more informative description of the
arguments.
> +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}"
> +}
> +
> ################################################################################
>
>
--
Stefano
^ permalink raw reply [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.