connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: "VAUTRIN Emmanuel (Canal Plus Prestataire)"
	<Emmanuel.VAUTRIN@cpexterne.org>
Cc: "connman@lists.linux.dev" <connman@lists.linux.dev>
Subject: Re: [PATCH] service: service_update_preferred_order cleanup
Date: Tue, 20 Jul 2021 14:14:28 +0200	[thread overview]
Message-ID: <20210720121428.p3t54ne3emuxz3bl@beryllium.lan> (raw)
In-Reply-To: <MRZP264MB1544B944E70E53B4B1A9287693E19@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM>

Hi Emmanuel,

On Mon, Jul 19, 2021 at 09:01:49AM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> For uniformity reasons, the service_update_preferred_order shall rely
> on service_compare_preferred generic function, instead of processing
> itself the preferred service comparison.
> ---
>  src/service.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index 149b66ecfbe0..182a1905c32d 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -5917,27 +5917,15 @@ static int service_update_preferred_order(struct connman_service *default_servic
>  		struct connman_service *new_service,
>  		enum connman_service_state new_state)
>  {
> -	unsigned int *tech_array;
> -	int i;
> -
>  	if (!default_service || default_service == new_service ||
>  			default_service->state != new_state)
>  		return 0;
>  
> -	tech_array = connman_setting_get_uint_list("PreferredTechnologies");
> -	if (tech_array) {
> -
> -		for (i = 0; tech_array[i] != 0; i += 1) {
> -			if (default_service->type == tech_array[i])
> -				return -EALREADY;
> -
> -			if (new_service->type == tech_array[i]) {
> -				switch_default_service(default_service,
> -						new_service);
> -				__connman_connection_update_gateway();
> -				return 0;
> -			}
> -		}
> +	if (service_compare_preferred(default_service, new_service) > 0) {
> +		switch_default_service(default_service,
> +				new_service);
> +		__connman_connection_update_gateway();
> +		return 0;

This is not just a pure refactoring change. Because

> -			if (default_service->type == tech_array[i])
> -				return -EALREADY;

is missing. This is only relevant for service_indicate_state() when we
would ignore the new service. Hmm, not totally sure what it means. Did
you figure out why this is not needed anymore?

Thanks,
Daniel

  reply	other threads:[~2021-07-20 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  9:01 VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-07-20 12:14 ` Daniel Wagner [this message]
2021-07-20 12:31   ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-07-26  7:22     ` Daniel Wagner
2021-07-26  7:52       ` VAUTRIN Emmanuel (Canal Plus Prestataire)

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=20210720121428.p3t54ne3emuxz3bl@beryllium.lan \
    --to=wagi@monom.org \
    --cc=Emmanuel.VAUTRIN@cpexterne.org \
    --cc=connman@lists.linux.dev \
    --subject='Re: [PATCH] service: service_update_preferred_order cleanup' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).