All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
Cc: outreachy@lists.linux.dev
Subject: Re: [PATCH] mbuto: add a function to find the difference of two lists
Date: Fri, 15 Apr 2022 17:10:37 +0200	[thread overview]
Message-ID: <20220415171037.0e610a6c@elisabeth> (raw)
In-Reply-To: <20220415040312.GA769838@euclid>

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


      reply	other threads:[~2022-04-15 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220415171037.0e610a6c@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=outreachy@lists.linux.dev \
    --cc=sevinj.aghayeva@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.