ConnMan network manager
 help / color / mirror / Atom feed
From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Subject: [PATCH] Const-qualify service comparison functions.
Date: Thu, 2 Nov 2023 15:51:59 -0700	[thread overview]
Message-ID: <EBAC877C-BD4C-46DD-A58F-452AC8CBEF7B@nuovations.com> (raw)

Const-qualify the network service arguments in service comparison
functions to make it clear to the compiler, static analyzers, and
human readers that the functions are strictly observers of service
state with no network service mutation side effects.
---
 src/service.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/service.c b/src/service.c
index 1a674924..9c77be08 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5411,11 +5411,11 @@ void connman_service_unref_debug(struct connman_service *service,
 
 static gint service_compare(gconstpointer a, gconstpointer b);
 
-static gint service_compare_vpn(struct connman_service *a,
-						struct connman_service *b)
+static gint service_compare_vpn(const struct connman_service *a,
+						const struct connman_service *b)
 {
 	struct connman_provider *provider;
-	struct connman_service *service;
+	const struct connman_service *service;
 	struct connman_service *transport;
 	const char *ident;
 	bool reverse;
@@ -5443,8 +5443,8 @@ static gint service_compare_vpn(struct connman_service *a,
 	return service_compare(transport, service);
 }
 
-static gint service_compare_preferred(struct connman_service *service_a,
-					struct connman_service *service_b)
+static gint service_compare_preferred(const struct connman_service *service_a,
+					const struct connman_service *service_b)
 {
 	unsigned int *tech_array;
 	int i;
@@ -5464,8 +5464,8 @@ static gint service_compare_preferred(struct connman_service *service_a,
 
 static gint service_compare(gconstpointer a, gconstpointer b)
 {
-	struct connman_service *service_a = (void *) a;
-	struct connman_service *service_b = (void *) b;
+	const struct connman_service *service_a = (const void *) a;
+	const struct connman_service *service_b = (const void *) b;
 	enum connman_service_state state_a, state_b;
 	bool a_connected, b_connected;
 	gint strength;
-- 
2.42.0



             reply	other threads:[~2023-11-02 22:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 22:51 Grant Erickson [this message]
2023-11-07 16:05 ` [PATCH] Const-qualify service comparison functions Marcel Holtmann

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=EBAC877C-BD4C-46DD-A58F-452AC8CBEF7B@nuovations.com \
    --to=gerickson@nuovations.com \
    --cc=connman@lists.linux.dev \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).