diff mbox series

ipconfig: Const-qualify 'ipconfig' parameters.

Message ID 20231128185136.1171884-1-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series ipconfig: Const-qualify 'ipconfig' parameters. | expand

Commit Message

Grant Erickson Nov. 28, 2023, 6:51 p.m. UTC
Const-qualify the ipconfig arguments of '__connman_ipconfig_get_gateway'
and '__connman_ipconfig_gateway_{add,remove}' to make it clear to the
compiler, static analyzers, and human readers that the functions have
no ipconfig mutation side effects.
---
 src/connman.h  | 6 +++---
 src/ipconfig.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Marcel Holtmann Nov. 29, 2023, 12:54 p.m. UTC | #1
Hi Grant,

> Const-qualify the ipconfig arguments of '__connman_ipconfig_get_gateway'
> and '__connman_ipconfig_gateway_{add,remove}' to make it clear to the
> compiler, static analyzers, and human readers that the functions have
> no ipconfig mutation side effects.
> ---
> src/connman.h  | 6 +++---
> src/ipconfig.c | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)

patch has been applied.

Regards

Marcel
diff mbox series

Patch

diff --git a/src/connman.h b/src/connman.h
index ae04cd9a26c6..344cb15af6a2 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -378,7 +378,7 @@  const char *__connman_ipconfig_get_peer(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_peer(struct connman_ipconfig *ipconfig, const char *address);
 const char *__connman_ipconfig_get_broadcast(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_broadcast(struct connman_ipconfig *ipconfig, const char *broadcast);
-const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig);
+const char *__connman_ipconfig_get_gateway(const struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig, const char *gateway);
 unsigned char __connman_ipconfig_get_prefixlen(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_prefixlen(struct connman_ipconfig *ipconfig, unsigned char prefixlen);
@@ -410,8 +410,8 @@  enum connman_ipconfig_method __connman_ipconfig_get_method(
 int __connman_ipconfig_address_add(struct connman_ipconfig *ipconfig);
 int __connman_ipconfig_address_remove(struct connman_ipconfig *ipconfig);
 int __connman_ipconfig_address_unset(struct connman_ipconfig *ipconfig);
-int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig);
-void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig);
+int __connman_ipconfig_gateway_add(const struct connman_ipconfig *ipconfig);
+void __connman_ipconfig_gateway_remove(const struct connman_ipconfig *ipconfig);
 
 int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
 							const char *url);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 64a74310d450..25e86bca292b 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1302,7 +1302,7 @@  void __connman_ipconfig_set_broadcast(struct connman_ipconfig *ipconfig,
 	ipconfig->address->broadcast = g_strdup(broadcast);
 }
 
-const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig)
+const char *__connman_ipconfig_get_gateway(const struct connman_ipconfig *ipconfig)
 {
 	if (!ipconfig->address)
 		return NULL;
@@ -1321,7 +1321,7 @@  void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
 	ipconfig->address->gateway = g_strdup(gateway);
 }
 
-int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
+int __connman_ipconfig_gateway_add(const struct connman_ipconfig *ipconfig)
 {
 	struct connman_service *service;
 
@@ -1347,7 +1347,7 @@  int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
 	return 0;
 }
 
-void __connman_ipconfig_gateway_remove(struct connman_ipconfig *ipconfig)
+void __connman_ipconfig_gateway_remove(const struct connman_ipconfig *ipconfig)
 {
 	struct connman_service *service;