connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "VAUTRIN Emmanuel (Canal Plus Prestataire)" <Emmanuel.VAUTRIN@cpexterne.org>
To: "connman@lists.linux.dev" <connman@lists.linux.dev>
Subject: [PATCH] service: service_update_preferred_order cleanup
Date: Mon, 19 Jul 2021 09:01:49 +0000	[thread overview]
Message-ID: <MRZP264MB1544B944E70E53B4B1A9287693E19@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM> (raw)

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


             reply	other threads:[~2021-07-19  9:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  9:01 VAUTRIN Emmanuel (Canal Plus Prestataire) [this message]
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)

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=MRZP264MB1544B944E70E53B4B1A9287693E19@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM \
    --to=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).