ConnMan network manager
 help / color / mirror / Atom feed
From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Subject: [PATCH] network: Const-qualify network leaf getter functions.
Date: Tue, 28 Nov 2023 11:33:48 -0800	[thread overview]
Message-ID: <20231128193348.1186889-1-gerickson@nuovations.com> (raw)

Const-qualify the network arguments in network leaf getter and
introspection functions to make it clear to the compiler, static
analyzers, and human readers that the function is strictly a getter or
introspection function with no network mutation side effects.
---
 include/network.h | 4 ++--
 src/connman.h     | 2 +-
 src/network.c     | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/network.h b/include/network.h
index f1a158afce8e..2078509e75bf 100644
--- a/include/network.h
+++ b/include/network.h
@@ -81,8 +81,8 @@ connman_network_ref_debug(struct connman_network *network,
 void connman_network_unref_debug(struct connman_network *network,
 			const char *file, int line, const char *caller);
 
-enum connman_network_type connman_network_get_type(struct connman_network *network);
-const char *connman_network_get_identifier(struct connman_network *network);
+enum connman_network_type connman_network_get_type(const struct connman_network *network);
+const char *connman_network_get_identifier(const struct connman_network *network);
 
 void connman_network_set_index(struct connman_network *network, int index);
 int connman_network_get_index(const struct connman_network *network);
diff --git a/src/connman.h b/src/connman.h
index ae04cd9a26c6..8b900ff185f8 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -623,7 +623,7 @@ int __connman_network_clear_ipconfig(struct connman_network *network,
 int __connman_network_enable_ipconfig(struct connman_network *network,
 				struct connman_ipconfig *ipconfig);
 
-const char *__connman_network_get_type(struct connman_network *network);
+const char *__connman_network_get_type(const struct connman_network *network);
 const char *__connman_network_get_group(struct connman_network *network);
 const char *__connman_network_get_ident(struct connman_network *network);
 bool __connman_network_get_weakness(struct connman_network *network);
diff --git a/src/network.c b/src/network.c
index e5fadd9cea36..3f844f76120d 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1333,7 +1333,7 @@ void connman_network_unref_debug(struct connman_network *network,
 	network_destruct(network);
 }
 
-const char *__connman_network_get_type(struct connman_network *network)
+const char *__connman_network_get_type(const struct connman_network *network)
 {
 	return type2string(network->type);
 }
@@ -1345,7 +1345,7 @@ const char *__connman_network_get_type(struct connman_network *network)
  * Get type of network
  */
 enum connman_network_type connman_network_get_type(
-				struct connman_network *network)
+				const struct connman_network *network)
 {
 	return network->type;
 }
@@ -1356,7 +1356,7 @@ enum connman_network_type connman_network_get_type(
  *
  * Get identifier of network
  */
-const char *connman_network_get_identifier(struct connman_network *network)
+const char *connman_network_get_identifier(const struct connman_network *network)
 {
 	return network->identifier;
 }
-- 
2.42.0


             reply	other threads:[~2023-11-28 19:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 19:33 Grant Erickson [this message]
2023-11-29 12:56 ` [PATCH] network: Const-qualify network leaf getter 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=20231128193348.1186889-1-gerickson@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).