ConnMan network manager
 help / color / mirror / Atom feed
From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Subject: [PATCH] Const-qualify 'connman_{network,provider}_get_index'.
Date: Thu, 19 Oct 2023 14:30:35 -0700	[thread overview]
Message-ID: <F5EB01CB-FAAC-4370-A256-D3920ABFF56C@nuovations.com> (raw)

Const-qualify the network and provider arguments to make it clear to
the compiler, static analyzers, and human readers that the function
is strictly a getter with no network or provider mutation side effects.

---
 include/network.h  | 2 +-
 include/provider.h | 2 +-
 src/network.c      | 2 +-
 src/provider.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/network.h b/include/network.h
index 5bca62ad..b0c314fb 100644
--- a/include/network.h
+++ b/include/network.h
@@ -85,7 +85,7 @@ enum connman_network_type connman_network_get_type(struct connman_network *netwo
 const char *connman_network_get_identifier(struct connman_network *network);
 
 void connman_network_set_index(struct connman_network *network, int index);
-int connman_network_get_index(struct connman_network *network);
+int connman_network_get_index(const struct connman_network *network);
 
 void connman_network_set_group(struct connman_network *network,
 						const char *group);
diff --git a/include/provider.h b/include/provider.h
index 1f120990..3f2e36ad 100644
--- a/include/provider.h
+++ b/include/provider.h
@@ -94,7 +94,7 @@ int connman_provider_indicate_error(struct connman_provider *provider,
 					enum connman_provider_error error);
 
 void connman_provider_set_index(struct connman_provider *provider, int index);
-int connman_provider_get_index(struct connman_provider *provider);
+int connman_provider_get_index(const struct connman_provider *provider);
 
 void connman_provider_set_data(struct connman_provider *provider, void *data);
 void *connman_provider_get_data(struct connman_provider *provider);
diff --git a/src/network.c b/src/network.c
index e3e02d16..d0ecec2e 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1404,7 +1404,7 @@ done:
  *
  * Get index number of network
  */
-int connman_network_get_index(struct connman_network *network)
+int connman_network_get_index(const struct connman_network *network)
 {
 	return network->index;
 }
diff --git a/src/provider.c b/src/provider.c
index e2091846..e3d34d8f 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -535,7 +535,7 @@ done:
 	provider->index = index;
 }
 
-int connman_provider_get_index(struct connman_provider *provider)
+int connman_provider_get_index(const struct connman_provider *provider)
 {
 	return provider->index;
 }
-- 
2.32.0


             reply	other threads:[~2023-10-19 21:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 21:30 Grant Erickson [this message]
2023-11-07 15:13 ` [PATCH] Const-qualify 'connman_{network,provider}_get_index' 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=F5EB01CB-FAAC-4370-A256-D3920ABFF56C@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).