connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] service: service_update_preferred_order cleanup
@ 2021-07-19  9:01 VAUTRIN Emmanuel (Canal Plus Prestataire)
  2021-07-20 12:14 ` Daniel Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2021-07-19  9:01 UTC (permalink / raw)
  To: connman

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;
 	}
 
 	return -EALREADY;
-- 
2.25.1


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

* Re: [PATCH] service: service_update_preferred_order cleanup
  2021-07-19  9:01 [PATCH] service: service_update_preferred_order cleanup VAUTRIN Emmanuel (Canal Plus Prestataire)
@ 2021-07-20 12:14 ` Daniel Wagner
  2021-07-20 12:31   ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2021-07-20 12:14 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

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

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

* RE: [PATCH] service: service_update_preferred_order cleanup
  2021-07-20 12:14 ` Daniel Wagner
@ 2021-07-20 12:31   ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  2021-07-26  7:22     ` Daniel Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2021-07-20 12:31 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

Hi Daniel,

Great to see you back, and hoping you will  be able to check my other
pending patches, as I will generate a new release soon.

> 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?
In fact, it is not missing, I presume it is the case corresponding to:
service_compare_preferred(default_service, new_service) == -1, 
which means the return -EALREADY; after the condition block of
if (service_compare_preferred(default_service, new_service) > 0).


Best Regards,

Emmanuel

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

* Re: [PATCH] service: service_update_preferred_order cleanup
  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)
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2021-07-26  7:22 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

Hi Emmanuel,

On Tue, Jul 20, 2021 at 12:31:25PM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> Great to see you back, and hoping you will  be able to check my other
> pending patches, as I will generate a new release soon.

Thanks. A few days holiday was really necessary. Though I am still
pretty sluggish response time. Sorry about that.

> > 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?
> In fact, it is not missing, I presume it is the case corresponding to:
> service_compare_preferred(default_service, new_service) == -1, 
> which means the return -EALREADY; after the condition block of
> if (service_compare_preferred(default_service, new_service) > 0).

Ah, right. I'll apply the patch.

Thanks,
Daniel

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

* RE: [PATCH] service: service_update_preferred_order cleanup
  2021-07-26  7:22     ` Daniel Wagner
@ 2021-07-26  7:52       ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  0 siblings, 0 replies; 5+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2021-07-26  7:52 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

> Ah, right. I'll apply the patch.
Great news, thank you Daniel.

> Thanks. A few days holiday was really necessary. Though I am still
> pretty sluggish response time. Sorry about that.
Indeed, this is important to slow down, moreover for those special times.

Emmanuel

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

end of thread, other threads:[~2021-07-26  7:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  9:01 [PATCH] service: service_update_preferred_order cleanup VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-07-20 12:14 ` Daniel Wagner
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)

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).