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

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